![]() |
NDEVR
API Documentation
|
This class is like a string view, but may optionally store the data internally Useful if the return type of an object "might" be a non-allocating string or might be an allocating string.s. More...
Public Member Functions | |
| StringAllocatingView & | replace (const Buffer< StringView > &sub_string, const Buffer< String > &replace_sub_string, bool ignore_case=false, uint04 start_index=0) |
| Replaces ALL instances of the given substrings with the provided replacements. | |
| StringAllocatingView & | replace (const StringView &sub_string, const StringView &replace_sub_string, bool ignore_case=false, uint04 start_index=0) |
| Replaces ALL instances of a given substring with the provided replacement. | |
| Public Member Functions inherited from StringView | |
| constexpr | StringView () |
| Constructor used to create an empty StringView. | |
| constexpr | StringView (const char *const string, uint04 size) |
| String Constructor char arrays when the size is known. | |
| constexpr | StringView (const char *string) |
| String Constructor for null terminated array of chars. | |
| template<std::size_t N> | |
| constexpr | StringView (const char(&string)[N]) |
| String Constructor for static char arrays. | |
| constexpr | StringView (const String &s) |
| Constructs a StringView from an existing String object. | |
| constexpr | StringView (const StringView &other) noexcept |
| Copy constructor for StringView. | |
| StringView (String &&s)=delete | |
| Deleted move constructor from String to prevent dangling views. | |
| constexpr | StringView (StringView &&other) noexcept |
| Move constructor for StringView. | |
| void | addToSize (uint04 size) |
| Increases the reported size of the string view by the given amount. | |
| constexpr const char * | begin () const |
| Returns a pointer to the beginning of the string data. | |
| constexpr const char * | begin (uint04 idx_offset) const |
| Returns a pointer offset from the beginning of the string data. | |
| bool | beginsWith (const StringView &s, bool ignore_case=false) const |
| Tests if this String starts with the specified prefix. | |
| constexpr bool | contains (char c) const |
| Checks whether the string view contains the given character. | |
| uint04 | count (char c) const |
| Counts the number of occurrences of the given character. | |
| constexpr const char * | end () const |
| Returns a pointer to one past the last character of the string data. | |
| bool | endsWith (const StringView &s, bool ignore_case=false) const |
| Tests if this String ends with the specified suffix. | |
| void | ensureNullTerminated (String &s) |
| This makes the string null terminated, if needed, using the provided string as the new buffer. | |
| uint04 | fromHex () const |
| Converts a hex value into an unsigned 4 byte number. | |
| template<class t_type> | |
| t_type | getAs () const |
| Converts a string into an object. | |
| constexpr uint08 | hash () const |
| Creates a simple, quick hash of the object. | |
| constexpr uint08 | hashLower () const |
| Creates a simple, quick hash of the object. | |
| constexpr uint08 | hashUpper () const |
| Creates a simple, quick hash of the object. | |
| bool | hasSubString (const StringView &sub_string, bool ignore_case=false, uint04 initial_index=0) const |
| Tests if this String contains the specified substring. | |
| uint04 | indexOf (const char &sub_string) const |
| Given a substring specified by the input, returns the first index of that string, if it exists. | |
| uint04 | indexOf (const char &sub_string, uint04 start_pos) const |
| Given a substring specified by the input, returns the first index of that string, if it exists. | |
| uint04 | indexOf (const char &sub_string, uint04 start_pos, uint04 size) const |
| Given a substring specified by the input, returns the first index of that string, if it exists. | |
| uint04 | indexOf (const char *sub_string, bool ignore_case, uint04 start_index, uint04 size) const |
| Given a substring specified by the input, returns the first index of that string, if it exists. | |
| uint04 | indexOf (const char *sub_string, char escape_char, bool ignore_case=false, uint04 start_index=0) const |
| Given a substring specified by the input, returns the first index of that string, if it exists. | |
| template<size_t t_size> | |
| uint04 | indexOf (const char(&value)[t_size], bool ignore_case, uint04 start_index=0) const |
| Template overload of indexOf for static char arrays. | |
| uint04 | indexOf (const StringView &sub_string, bool ignore_case=false, uint04 start_index=0) const |
| Given a substring specified by the input, returns the first index of that string, if it exists. | |
| StringAllocatingView | insertNewLines (uint04 max_line_size) const |
| Finds key areas to insert new lines such that the rows are at most, the length provided. | |
| bool | isGreaterNoCase (const StringView &other) const |
| Case-insensitive greater-than comparison. | |
| bool | isLessNoCase (const StringView &other) const |
| Case-insensitive less-than comparison. | |
| bool | isNullTerminated () const |
| Checks whether the underlying string data is null terminated. | |
| bool | isNumeric () const |
| Checks to see if the string is a numeric string. | |
| bool | isSameNoCase (const StringView &s) const |
| Checks whether two strings match in a case-insensitive way. | |
| char | last () const |
| Returns the last character in the string view. | |
| uint04 | lastIndexOf (const char *sub_string, bool ignore_case=false) const |
| Given a substring specified by the input, returns the last index of that string, if it exists. | |
| uint04 | lastIndexOf (const char value, bool ignore_case=false) const |
| Given a value specified by the input, returns the last index of that char, if it exists. | |
| bool | matchesWildcard (const StringView &pattern) const |
| Checks whether two strings match allowing '' to be used as a wildcard pattern. | |
| constexpr bool | operator!= (const char *const value) const |
| Checks inequality with a null-terminated C string. | |
| template<std::size_t t_size> | |
| constexpr bool | operator!= (const char(&string)[t_size]) |
| Checks inequality with a static char array. | |
| bool | operator!= (const String &value) const |
| Checks inequality with a String object. | |
| constexpr bool | operator!= (const StringView &value) const |
| Checks inequality with another StringView. | |
| bool | operator< (const StringView &value) const |
| Less-than comparison operator using lexicographic ordering. | |
| constexpr StringView & | operator= (const char *value) |
| Assignment operator from a null-terminated C string. | |
| template<std::size_t t_size> | |
| constexpr StringView & | operator= (const char(&string)[t_size]) |
| Assignment operator from a static char array. | |
| StringView & | operator= (const String &value) |
| Assignment operator from a String object. | |
| constexpr StringView & | operator= (const StringView &value) |
| Copy assignment operator from another StringView. | |
| StringView & | operator= (String &&value)=delete |
| Deleted move assignment from String to prevent dangling views. | |
| constexpr bool | operator== (const char *const value) const |
| Checks equality with a null-terminated C string. | |
| template<std::size_t t_size> | |
| constexpr bool | operator== (const char(&string)[t_size]) |
| Checks equality with a static char array. | |
| bool | operator== (const String &value) const |
| Checks equality with a String object. | |
| constexpr bool | operator== (const StringView &value) const |
| Checks equality with another StringView. | |
| bool | operator> (const StringView &value) const |
| Greater-than comparison operator using lexicographic ordering. | |
| constexpr const char & | operator[] (const uint04 idx) const |
| Accesses the character at the given index. | |
| String | predictNextStringIncrement () const |
| Looks in the string for key markers that might be an index, and attempts to increment the index. | |
| void | removeFirst (uint04 count=1) |
| Removes the specified number of characters from the beginning of the view. | |
| void | removeLast (uint04 count=1) |
| Removes the specified number of characters from the end of the view. | |
| StringAllocatingView | shortenString (uint04 size) const |
| Shortans the string to the max size provided. | |
| constexpr uint04 | size () const |
| Returns the byte size of this string view. | |
| StringViewBuffer | split (char delimiter, bool preserve_empty=true) const |
| Given a delimiter, breaks the string into subsections, returning an array of each subsection. | |
| StringViewBuffer | split (const Buffer< char > &delimiter, bool preserve_empty=true) const |
| Given multiple delimiter, breaks the string view into subsections, returning an array of each subsection. | |
| StringView | splitPart (char delimiter, uint04 index) const |
| Returns a single part from splitting the string by the given delimiter. | |
| void | splitString (char delimiter, StringViewBuffer &strings, bool preserve_empty=true) const |
| Given multiple delimiter, breaks the string into subsections, and APPENDS each substring to the given Buffer. | |
| void | splitString (const Buffer< char > &delimiter, StringViewBuffer &strings, bool preserve_empty=true) const |
| Given multiple delimiter, breaks the string into subsections, and APPENDS each substring to the given Buffer. | |
| StringView | substr (uint04 start) const |
| Creates a substring from a given start position, to the end of the string. | |
| StringView | substr (uint04 start, uint04 end) const |
| Creates a substring from a given start position, to the given end position, non-inclusive of the end index. | |
| StringAllocatingView | toLower () const |
| changes all upper case characters into lower case characters. | |
| String | toTitleString () const |
| Formats the string to be a title, capitalizing important characters and replacing underscores with spaces. | |
| StringAllocatingView | toUpper () const |
| changes all lower case characters into upper case characters. | |
| StringView & | trimWhiteSpace () |
| Trims leading and trailing whitespace from the string view. | |
Additional Inherited Members | |
| Static Public Member Functions inherited from StringView | |
| static bool | AlphaNumericCompare (const StringView &left, const StringView &right) |
| Compares two strings given their alpha-numeric determined value. | |
| static StringViewBuffer | Convert (const StringBuffer &strings) |
| Converts a StringBuffer into a StringViewBuffer. | |
| static StringBuffer | Convert (const StringViewBuffer &views) |
| Converts a StringViewBuffer into a StringBuffer by copying each view into a String. | |
| static void | Convert (StringBuffer &&strings)=delete |
| Deleted overload to prevent converting from rvalue StringBuffer which would create dangling views. | |
| static constexpr uint08 | hash (const char *value) |
| constexpr method to hash a value. | |
| static constexpr uint04 | str_len (const char *value) |
| constexpr method to get the length of a null-terminated string at compile time | |
| static constexpr uint04 | str_len (const wchar *value) |
| constexpr method to get the UTF8 length of a null-terminated string at compile time | |
| Protected Attributes inherited from StringView | |
| uint04 | m_size = 0 |
| The byte length of the string view. | |
| const char * | m_start = nullptr |
| Pointer to the beginning of the string data. | |
This class is like a string view, but may optionally store the data internally Useful if the return type of an object "might" be a non-allocating string or might be an allocating string.s.
| StringAllocatingView & StringAllocatingView::replace | ( | const Buffer< StringView > & | sub_string, |
| const Buffer< String > & | replace_sub_string, | ||
| bool | ignore_case = false, | ||
| uint04 | start_index = 0 ) |
Replaces ALL instances of the given substrings with the provided replacements.
This allows safe replacement when the replacement string might contain the same data being replaced.
| [in] | sub_string | The subsrings to replace |
| [in] | replace_sub_string | The strings to replace ALL instances of the provided sub_string with. |
| [in] | ignore_case | whether or not to check using case sensitivity checks. This will not affect the replacement value, only which parts to replace. |
References StringView::m_size, and StringView::m_start.
| StringAllocatingView & StringAllocatingView::replace | ( | const StringView & | sub_string, |
| const StringView & | replace_sub_string, | ||
| bool | ignore_case = false, | ||
| uint04 | start_index = 0 ) |
Replaces ALL instances of a given substring with the provided replacement.
| [in] | sub_string | The subsring to replace |
| [in] | replace_sub_string | The string to replace ALL instances of the provided sub_string with. |
| [in] | ignore_case | whether or not to check using case sensitivity checks. This will not affect the replacement value, only which parts to replace. |
References StringView::StringView().