23 #ifndef GUL14_TOKENIZE_H_
24 #define GUL14_TOKENIZE_H_
107 template <
typename StringContainer = std::vector<std::
string>,
108 typename ContainerInsertFct =
void (*)(StringContainer&,
string_view)>
109 inline StringContainer
111 ContainerInsertFct insert_fct = detail::emplace_back<StringContainer>)
113 StringContainer tokens{ };
115 string_view::size_type token_start = 0;
116 string_view::size_type token_end = 0;
120 token_start = str.find_first_not_of(delimiters, token_end);
121 if (token_start == string_view::npos)
124 token_end = str.find_first_of(delimiters, token_start);
125 if (token_end == string_view::npos)
128 string_view{ str.data() + token_start, str.length() - token_start });
134 string_view{ str.data() + token_start, token_end - token_start });
161 template <
typename StringContainer = std::vector<
string_view>,
162 typename ContainerInsertFct =
void (*)(StringContainer&,
string_view)>
163 inline StringContainer
165 ContainerInsertFct insert_fct = detail::emplace_back<StringContainer>)
167 return tokenize<StringContainer>(str, delimiters, insert_fct);
Definition of macros used internally by GUL.
Namespace gul14 contains all functions and classes of the General Utility Library.
Definition: doxygen.h:26
GUL_EXPORT const string_view default_whitespace_characters
The default characters that are treated as whitespace by GUL.
Definition: string_util.cc:28
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:164
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:110
Declarations of string utility functions for the General Utility Library.
Provides a gul14::string_view that is fully compatible with C++17's std::string_view.