|
|
Donner
C++20 SVG rendering library
|
A collection of string utils, such as case-insensitive comparison and StartsWith/EndsWith. More...
#include "donner/base/StringUtils.h"
Static Public Member Functions | |
| template<StringLike T, StringLike U> | |
| static bool | EqualsLowercase (const T &lhs, const U &lowercaseRhs) |
| Compare two strings with case-insensitive comparison, fast-path assuming that one of the strings is all-lowercase. | |
| template<StringComparison Comparison = StringComparison::Default, StringLike T, StringLike U> | |
| static bool | Equals (const T &lhs, const U &rhs) |
| Returns true if two strings are equal, optionally with a case-insensitive comparison. | |
| template<StringComparison Comparison = StringComparison::Default, StringLike T, StringLike U> | |
| static bool | StartsWith (const T &str, const U &otherStr) |
Returns true if str starts with otherStr. | |
| template<StringComparison Comparison = StringComparison::Default, StringLike T, StringLike U> | |
| static bool | EndsWith (const T &str, const U &otherStr) |
Returns true if str ends with otherStr. | |
| template<StringComparison Comparison = StringComparison::Default, StringLike T, StringLike U> | |
| static bool | Contains (const T &str, const U &otherStr) |
Returns true if str contains otherStr. | |
| template<StringComparison Comparison = StringComparison::Default, StringLike T, StringLike U> | |
| static size_t | Find (const T &str, const U &otherStr) |
Returns the position of otherStr within str, or npos if not found. | |
| template<StringLike T> | |
| static std::vector< std::string_view > | Split (const T &str, char ch=' ') |
| Splits a string by a given character, returning a range of the split strings as a std::string_view. | |
| template<StringLike T> | |
| static std::string_view | TrimWhitespace (const T &str) |
| Trims leading and trailing whitespace from a string, returning a view of the trimmed string. | |
A collection of string utils, such as case-insensitive comparison and StartsWith/EndsWith.
|
inlinestatic |
Returns true if str contains otherStr.
| str | The string to check for a suffix. |
| otherStr | The suffix to check for. |
| Comparison | The comparison type to use, defaults to StringComparison::Default. |
| T | The type of the first string, must be StringLike (have size() and data() methods). @tparam U The type of the second string, must be \ref StringLike (have size() and data() methods). |
|
inlinestatic |
Returns true if str ends with otherStr.
| str | The string to check for a suffix. |
| otherStr | The suffix to check for. |
| Comparison | The comparison type to use, defaults to StringComparison::Default. |
| T | The type of the first string, must be StringLike (have size() and data() methods). @tparam U The type of the second string, must be \ref StringLike (have size() and data() methods). |
|
inlinestatic |
Returns true if two strings are equal, optionally with a case-insensitive comparison.
| lhs | The first string to compare. |
| rhs | The second string to compare. |
| Comparison | The comparison type to use, defaults to StringComparison::Default. |
| T | The type of the first string, must be StringLike (have size() and data() methods). @tparam U The type of the second string, must be \ref StringLike (have size() and data() methods). |
|
inlinestatic |
Compare two strings with case-insensitive comparison, fast-path assuming that one of the strings is all-lowercase.
| lhs | The first string to compare, can be any case. |
| lowercaseRhs | string to compare to, must be lowercase. |
| T | The type of the first string, must be StringLike (have size() and data() methods). @tparam U The type of the second string, must be \ref StringLike (have size() and data() methods). |
lowercaseRhs is equal to the lhs, ignoring the case of the lhs.
|
inlinestatic |
Returns the position of otherStr within str, or npos if not found.
| str | The string to search within. |
| otherStr | The substring to find. |
| Comparison | The comparison type to use, defaults to StringComparison::Default. |
| T | The type of the first string, must be StringLike (have size() and data() methods). @tparam U The type of the second string, must be \ref StringLike (have size() and data() methods). |
|
inlinestatic |
Splits a string by a given character, returning a range of the split strings as a std::string_view.
| T | The string type to split, must be StringLike (have size() and data() methods). |
| str | The string to split. |
| ch | The character to split by. |
|
inlinestatic |
Returns true if str starts with otherStr.
| str | The string to check for a prefix. |
| otherStr | The prefix to check for. |
| Comparison | The comparison type to use, defaults to StringComparison::Default. |
| T | The type of the first string, must be StringLike (have size() and data() methods). @tparam U The type of the second string, must be \ref StringLike (have size() and data() methods). |
|
inlinestatic |
Trims leading and trailing whitespace from a string, returning a view of the trimmed string.
| str | The string to trim. |
| T | The type of the string, must be StringLike (have size() and data() methods). |