17 string::size_type index = s.find_first_not_of(delimiters, 0);
18 while (index != s.npos)
20 string::size_type newIndex = s.find_first_of(delimiters, index);
21 if (newIndex != s.npos)
23 tokens_.push_back(s.substr(index, newIndex - index));
24 if (!allowEmptyTokens)
25 index = s.find_first_not_of(delimiters, newIndex);
28 splits_.push_back(s.substr(newIndex, index - newIndex));
32 tokens_.push_back(s.substr(index));
39 string::size_type index = 0;
40 while (index != s.npos)
42 string::size_type newIndex = s.find(delimiters, index);
43 if (newIndex != s.npos)
45 tokens_.push_back(s.substr(index, newIndex - index));
46 if (!allowEmptyTokens)
48 index = newIndex + delimiters.size();
49 while (index != string::npos && s.substr(index, delimiters.size()) == delimiters)
50 index += delimiters.size();
53 index = newIndex + delimiters.size();
54 splits_.push_back(s.substr(newIndex, index - newIndex));
58 tokens_.push_back(s.substr(index));
size_t numberOfRemainingTokens() const
Tell how many tokens are available.
void removeEmptyTokens()
remove all empty token from the current position.
std::deque< std::string > tokens_
Where the tokens are stored.
std::string unparseRemainingTokens() const
std::deque< std::string > splits_
size_t currentPosition_
the current position in the token list.