6 : str(s.c_str()), strSize(s.length())
20 if (other.size() > size() + offset)
return NoPosition;
22 auto found = std::search(begin()+offset, end(), other.begin(), other.end());
25 return std::distance(begin(), found);
34 if (pos < N) N = pos + 1;
36 size_t k = NoPosition;
37 for (
size_t i = 0; i < N; i++) {
39 for (
size_t j = 0; j < characters.size(); j++) {
40 if (characters[j] == ch) { k = i; }
48 for (
size_t len = length(); pos < len; ++pos) {
49 if(data()[pos] == character) {
59 if (pos < N) N = pos + 1;
61 size_t k = NoPosition;
62 for (
size_t i = 0; i < N; i++) {
63 if(data()[i] == character) { k = i; }
70 const size_t lSize = size();
71 const size_t rSize = other.size();
72 const int result = compareMemory(str, other.str, std::min(lSize, rSize));
73 if (result != 0)
return result;
74 if (lSize < rSize)
return -1;
75 if (lSize > rSize)
return 1;
82 const char * read = data();
83 const char * token =
nullptr;
85 for (
const char *
const end = read + size(); read != end; ++read) {
86 const bool isSplitter = delimiters.
find_first_of(*read) != NoPosition;
88 if (!isSplitter && !token) {
91 else if (isSplitter && token) {
92 tokens.push_back(
StringView(token, read - token));
97 tokens.push_back(
StringView(token, read - token));
105 const char * read = data();
106 const char * token = read;
108 for (
const char *
const end = read + size(); read != end; ++read) {
110 tokens.push_back(
StringView(token, read - token));
114 tokens.push_back(
StringView(token, read - token));
120 while (strSize && isWhiteSpace(*str)) {
129 while (strSize && isWhiteSpace(str[strSize - 1])) {
Provides a weakly referenced view over the contents of a string.
size_t find_first_of(char character, size_t pos=0) const noexcept
Find the first occurance of the given character from the specified starting position.
size_t strSize
Length of the string data pointed to.
StringView & trimStart() noexcept
Remove any whitespace from the start of this StringView's contents.
size_t find_last_of(const StringView characters, size_t pos=NoPosition) const noexcept
See std::basic_string::find_last_of.
constexpr StringView() noexcept=default
Constructs an empty string view.
StringView & trim() noexcept
Remove any whitespace from the start and end of this StringView's contents.
int compare(const StringView &other) const noexcept
Lexicographically compares the content of this string view with the given other.
size_t hashLowercase(size_t hashValue=Cogs::hash()) const noexcept
Get the hash code of the string converted to lowercase.
StringView & trimEnd() noexcept
Remove any whitespace from the end of this StringView's contents.
Vector splitAll(const StringView &delimiters) const
Split this string into parts, empty parts will be retained.
Vector split(const StringView &delimiters) const
Split this string into parts.
size_t find(const StringView &other, size_t offset=0) const noexcept
Find the given string segment inside the string.
const char * str
Pointer to the string this view is over.
std::string to_string() const
String conversion method.
COGSFOUNDATION_API size_t hashLowercase(std::string_view str, size_t hashValue=Cogs::hash()) noexcept
Get the hash code of the string converted to lowercase.