NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
|
This class is a mutable version of a string view. It can be used to replace single characters or entire parts of the string. It's possible to convert a MutableStringView into a (const) StringView but not the other way around. More...
#include <structures.hpp>
Public Member Functions | |
MutableStringView () | |
MutableStringView default constructor. More... | |
MutableStringView (std::string *data) | |
MutableStringView constructor from a std::string pointer. More... | |
MutableStringView (std::string &data) | |
MutableStringView constructor from a (non-const) std::string reference. More... | |
MutableStringView (MutableStringView &view) | |
MutableStringView copy constrcutor. More... | |
MutableStringView (MutableStringView &&view) | |
MutableStringView move constructor. More... | |
MutableStringView & | operator= (MutableStringView &view) |
Assignment operator for another MutableStringView instance. More... | |
MutableStringView & | operator= (std::string *data) |
Assignment operator for a std::string pointer. More... | |
MutableStringView & | operator= (std::string &data) |
Assignment operator for a std::string (non-const) reference. More... | |
char & | operator[] (size_t pos) |
Implementation of the random access operator. Returns a (non-const) char reference. More... | |
MutableStringView | subview (size_t pos=0, size_t len=std::string::npos) const |
This member function creates a new MutableStringView class instance using the selected position and length as a new viewed part. The position has to be part of the viewed section of this instance. This function can be used to replace std::string::substr. More... | |
MutableStringView & | replace (size_t pos, size_t len, const std::string &s) |
This member function replaces a range in the internal viewed string with the passed string. More... | |
MutableStringView & | replace (size_t pos, size_t len, const std::string &s, size_t subpos, size_t sublen) |
This member function replaces a range in the internal viewed string with the passed string. This function allows to select a smaller part of the replacing string. More... | |
MutableStringView & | replace (size_t pos, size_t len, const StringViewBase &view) |
This member function replaces a range in the internal viewed string with the passed StringViewBase. More... | |
Public Member Functions inherited from StringViewBase | |
StringViewBase () | |
StringViewBase default constructor. More... | |
virtual const std::string * | getData () const |
This member function returns a const pointer to the viewed string. Is only used internally. More... | |
bool | operator== (const StringViewBase &view) const |
This member function is an overload for the equality operator using another StringViewBase instance. More... | |
bool | operator== (const std::string &sString) const |
This member function is an overload for the equality operator using a const std::string instance. More... | |
bool | operator== (const char *sString) const |
This member function is an overload for the equality operator using a const char*. More... | |
bool | operator!= (const StringViewBase &view) const |
This member function is an overload for the inequality operator using another StringViewBase instance. More... | |
bool | operator!= (const std::string &sString) const |
This member function is an overload for the inequality operator using a const std::string instance. More... | |
bool | operator!= (const char *sString) const |
This member function is an overload for the inequality operator using a const char*. More... | |
bool | operator< (const StringViewBase &view) const |
This member function is an overload for the less operator using another StringViewBase instance. More... | |
bool | operator< (const std::string &sString) const |
This member function is an overload for the less operator using a const std::string instance. More... | |
bool | operator<= (const StringViewBase &view) const |
This member function is an overload for the less-equal operator using another StringViewBase instance. More... | |
bool | operator<= (const std::string &sString) const |
This member function is an overload for the less-equal operator using a const std::string instance. More... | |
bool | operator> (const StringViewBase &view) const |
This member function is an overload for the greater operator using another StringViewBase instance. More... | |
bool | operator> (const std::string &sString) const |
This member function is an overload for the greater operator using a const std::string instance. More... | |
bool | operator>= (const StringViewBase &view) const |
This member function is an overload for the greater-equal operator using another StringViewBase instance. More... | |
bool | operator>= (const std::string &sString) const |
This member function is an overload for the greater-equal operator using a const std::string instance. More... | |
std::string | operator+ (const StringViewBase &view) const |
This member function is an overload for the concatenation operator using another StringViewBase instance. More... | |
std::string | operator+ (const std::string &sString) const |
This member function is an overload for the concatenation operator using a const std::string instance. More... | |
const char & | front () const |
This member function provides a const char reference to the first character in the viewed section. More... | |
const char & | back () const |
This member function provides a const char reference to the last character in the viewed section. More... | |
std::string::const_iterator | begin () const |
This member function provides an iterator to the beginning of the viewed section of the internal string. More... | |
std::string::const_iterator | end () const |
This member function provides an iterator to the end of the viewed section of the internal string. More... | |
void | trim_front (size_t len) |
This member function can be used to remove characters from the front of the viewed section. More... | |
void | trim_back (size_t len) |
This member function can be used to remove characters from the back of the viewed section. More... | |
void | strip () |
This member function shrinks the viewed section to remove all leading or trailing whitespace characters. This is the corresponding member function to StripSpaces(std::string&). More... | |
size_t | length () const |
This member function simply returns the length of the viewed section. More... | |
std::string | to_string () const |
This member function returns a copy of the viewed section of the string (via std::string::substr). Note that this is an inefficient operation. More... | |
size_t | find (const std::string &findstr, size_t pos=0) const |
Wrapper member function for std::string::find() More... | |
size_t | find (char c, size_t pos=0) const |
Wrapper member function for std::string::find() More... | |
size_t | rfind (const std::string &findstr, size_t pos=std::string::npos) const |
Wrapper member function for std::string::rfind() More... | |
size_t | rfind (char c, size_t pos=std::string::npos) const |
Wrapper member function for std::string::rfind() More... | |
size_t | find_first_of (const std::string &findstr, size_t pos=0) const |
Wrapper member function for std::string::find_first_of() More... | |
size_t | find_first_of (char c, size_t pos=0) const |
Wrapper member function for std::string::find_first_of() More... | |
size_t | find_first_not_of (const std::string &findstr, size_t pos=0) const |
Wrapper member function for std::string::find_first_not_of() More... | |
size_t | find_first_not_of (char c, size_t pos=0) const |
Wrapper member function for std::string::find_first_not_of() More... | |
size_t | find_last_of (const std::string &findstr, size_t pos=std::string::npos) const |
Wrapper member function for std::string::find_last_of() More... | |
size_t | find_last_of (char c, size_t pos=std::string::npos) const |
Wrapper member function for std::string::find_last_of() More... | |
size_t | find_last_not_of (const std::string &findstr, size_t pos=std::string::npos) const |
Wrapper member function for std::string::find_last_not_of() More... | |
size_t | find_last_not_of (char c, size_t pos=std::string::npos) const |
Wrapper member function for std::string::find_last_not_of() More... | |
Protected Member Functions | |
virtual const std::string * | getData () const override |
Override to return a pointer to the internal string. More... | |
void | assign (MutableStringView &view) |
Assignment member function from another MutableStringView instance. More... | |
void | assign (std::string *data) |
Assignment member function from a std::string pointer. More... | |
virtual void | clear () override |
Override to clear the internal pointer as well. More... | |
Protected Member Functions inherited from StringViewBase | |
size_t | validizeLength (size_t pos, size_t len) const |
This private member function evaluates, whether the passed length is part of the viewed section and adapts the length correspondingly. More... | |
virtual void | clear () |
Reset function. More... | |
bool | validAbsolutePosition (size_t pos) const |
This member function checks, whether the passed (absolute) position is part of the viewed string section. Is mostly used in string find operations. More... | |
Private Member Functions | |
MutableStringView (std::string *data, size_t start, size_t len) | |
Private constructor used by the subview member function. More... | |
Private Attributes | |
std::string * | m_data |
Friends | |
class | StringView |
Additional Inherited Members | |
Protected Attributes inherited from StringViewBase | |
size_t | m_start |
size_t | m_len |
This class is a mutable version of a string view. It can be used to replace single characters or entire parts of the string. It's possible to convert a MutableStringView into a (const) StringView but not the other way around.
Definition at line 1726 of file structures.hpp.
|
inlineprivate |
Private constructor used by the subview member function.
data | std::string* |
start | size_t |
len | size_t |
Definition at line 1741 of file structures.hpp.
References StringViewBase::m_len, and StringViewBase::m_start.
|
inline |
MutableStringView default constructor.
Definition at line 1811 of file structures.hpp.
Referenced by subview().
|
inline |
MutableStringView constructor from a std::string pointer.
data | std::string* |
Definition at line 1820 of file structures.hpp.
References assign().
|
inline |
MutableStringView constructor from a (non-const) std::string reference.
data | std::string& |
Definition at line 1832 of file structures.hpp.
References assign().
|
inline |
MutableStringView copy constrcutor.
view | MutableStringView& |
Definition at line 1843 of file structures.hpp.
References assign().
|
inline |
MutableStringView move constructor.
view | MutableStringView&& |
Definition at line 1854 of file structures.hpp.
References m_data, StringViewBase::m_len, and StringViewBase::m_start.
|
inlineprotected |
Assignment member function from another MutableStringView instance.
view | MutableStringView& |
Definition at line 1768 of file structures.hpp.
References m_data, StringViewBase::m_len, and StringViewBase::m_start.
Referenced by MutableStringView(), and operator=().
|
inlineprotected |
Assignment member function from a std::string pointer.
data | std::string* |
Definition at line 1783 of file structures.hpp.
References m_data, StringViewBase::m_len, and StringViewBase::m_start.
|
inlineoverrideprotectedvirtual |
Override to clear the internal pointer as well.
Reimplemented from StringViewBase.
Definition at line 1800 of file structures.hpp.
References m_data, StringViewBase::m_len, and StringViewBase::m_start.
|
inlineoverrideprotectedvirtual |
Override to return a pointer to the internal string.
Reimplemented from StringViewBase.
Definition at line 1755 of file structures.hpp.
References m_data.
|
inline |
Assignment operator for another MutableStringView instance.
view | MutableStringView& |
Definition at line 1869 of file structures.hpp.
References assign().
|
inline |
Assignment operator for a std::string (non-const) reference.
data | std::string& |
Definition at line 1897 of file structures.hpp.
References assign().
|
inline |
Assignment operator for a std::string pointer.
data | std::string* |
Definition at line 1883 of file structures.hpp.
References assign().
|
inline |
Implementation of the random access operator. Returns a (non-const) char reference.
pos | size_t |
Definition at line 1913 of file structures.hpp.
References m_data, and StringViewBase::m_start.
|
inline |
This member function replaces a range in the internal viewed string with the passed string.
pos | size_t |
len | size_t |
s | const std::string& |
Definition at line 1958 of file structures.hpp.
References m_data, StringViewBase::m_len, StringViewBase::m_start, and StringViewBase::validizeLength().
Referenced by mu::ParserBase::compileVectors(), mu::ParserBase::compileVectorsInMultiArgFunc(), and replace().
|
inline |
This member function replaces a range in the internal viewed string with the passed string. This function allows to select a smaller part of the replacing string.
pos | size_t |
len | size_t |
s | const std::string& |
subpos | size_t |
sublen | size_t |
Definition at line 1988 of file structures.hpp.
References m_data, StringViewBase::m_len, StringViewBase::m_start, and StringViewBase::validizeLength().
|
inline |
This member function replaces a range in the internal viewed string with the passed StringViewBase.
pos | size_t |
len | size_t |
view | const StringViewBase& |
Definition at line 2019 of file structures.hpp.
References replace(), and StringViewBase::to_string().
|
inline |
This member function creates a new MutableStringView class instance using the selected position and length as a new viewed part. The position has to be part of the viewed section of this instance. This function can be used to replace std::string::substr.
pos | size_t |
len | size_t |
Definition at line 1932 of file structures.hpp.
References m_data, StringViewBase::m_len, StringViewBase::m_start, MutableStringView(), and StringViewBase::validizeLength().
Referenced by mu::ParserBase::compileVectorExpansion(), mu::ParserBase::compileVectors(), and mu::ParserBase::compileVectorsInMultiArgFunc().
|
friend |
Definition at line 1729 of file structures.hpp.
|
private |
Definition at line 1730 of file structures.hpp.
Referenced by StringView::assign(), assign(), clear(), getData(), MutableStringView(), operator[](), replace(), and subview().