53 string::size_type index = s.find_first_not_of(delimiters, 0);
54 while( index != s.npos)
56 string::size_type newIndex = s.find_first_of(delimiters, index);
57 if (newIndex != s.npos)
59 tokens_.push_back(s.substr(index, newIndex - index));
60 if (!allowEmptyTokens) index = s.find_first_not_of(delimiters, newIndex);
61 else index = newIndex + 1;
62 splits_.push_back(s.substr(newIndex, index - newIndex));
66 tokens_.push_back(s.substr(index));
73 string::size_type index = 0;
74 while (index != s.npos)
76 string::size_type newIndex = s.find(delimiters, index);
77 if (newIndex != s.npos)
79 tokens_.push_back(s.substr(index, newIndex - index));
80 if (!allowEmptyTokens)
82 index = newIndex + delimiters.size();
83 while (index != string::npos && s.substr(index, delimiters.size()) == delimiters)
84 index += delimiters.size();
86 else index = newIndex + delimiters.size();
87 splits_.push_back(s.substr(newIndex, index - newIndex));
91 tokens_.push_back(s.substr(index));
This class allows to perform a correspondence analysis.
bool hasMoreToken() const
Tell if some tokens are still available.
const std::string & nextToken()
Get the next available token. If no token is availbale, throw an Exception.
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.