mario::konrad
programming / C++ / sailing / nerd stuff
C++ String Tokenizer
© 2005 / Mario Konrad

A simple string tokenizer. Searches for tokens, delemited with definable characters.

The usage of this class should be self explained. Example:

1
2
3
4
5
utils::string_tokenizer st("foo:bar:foobar", false, ":");
while (st.hasMoreTokens()) {
    cout << st.next() << "_" << endl;
    next();
}

It is also possible to use the automatic advancing feature:

1
2
3
4
utils::string_tokenizer st("foo:bar:foobar", true, ":");
while (st.hasMoreTokens()) {
    cout << st.next() << "_" << endl;
}