23 #ifndef GUL14_TOKENIZE_H_
24 #define GUL14_TOKENIZE_H_
114 template <
typename StringContainer = std::vector<std::
string>,
115 typename ContainerInsertFct =
void (*)(StringContainer&,
string_view)>
116 inline StringContainer
118 ContainerInsertFct insert_fct = detail::emplace_back<StringContainer>)
120 StringContainer tokens{ };
122 string_view::size_type token_start = 0;
123 string_view::size_type token_end = 0;
127 token_start = str.find_first_not_of(delimiters, token_end);
128 if (token_start == string_view::npos)
131 token_end = str.find_first_of(delimiters, token_start);
132 if (token_end == string_view::npos)
135 string_view{ str.data() + token_start, str.length() - token_start });
141 string_view{ str.data() + token_start, token_end - token_start });
168 template <
typename StringContainer = std::vector<
string_view>,
169 typename ContainerInsertFct =
void (*)(StringContainer&,
string_view)>
170 inline StringContainer
172 ContainerInsertFct insert_fct = detail::emplace_back<StringContainer>)
174 return tokenize<StringContainer>(str, delimiters, insert_fct);
GUL_EXPORT const string_view default_whitespace_characters
The default characters that are treated as whitespace by GUL.
Definition: string_util.cc:29
StringContainer tokenize_sv(string_view str, string_view delimiters=default_whitespace_characters, ContainerInsertFct insert_fct=detail::emplace_back< StringContainer >)
Split the given string into a vector of substrings (tokens) delimited by any of the characters in the...
Definition: tokenize.h:171
StringContainer tokenize(string_view str, string_view delimiters=default_whitespace_characters, ContainerInsertFct insert_fct=detail::emplace_back< StringContainer >)
Split the given string into a vector of substrings (tokens) delimited by any of the characters in the...
Definition: tokenize.h:117
Definition of macros used internally by GUL.
Namespace gul14 contains all functions and classes of the General Utility Library.
Definition: doxygen.h:26
Declaration of string utility functions.
Provides a gul14::string_view that is fully compatible with C++17's std::string_view.