1
#ifndef ESTDSTRINGTOKENIZER_H
2
#define ESTDSTRINGTOKENIZER_H
11
License: see the file LICENSE in this directory.
12
Author: stephan@wanderinghorse.net
14
Based heavily off of work by:
16
Martin Jones (mjones@kde.org)
17
Torben Weis (weis@kde.org)
18
Waldo Bastian (bastian@kde.org)
20
which i originally found as StringTokenizer in the KDE 1.x
21
source tree. i have received explicit permission from each
22
of those gentlemen to release the StringTokenizer code into
23
into the Public Domain. (Many thanks to them for that
24
permission, without which this whole library would
25
necessarily be released under the GNU GPL.)
27
This class is meant to be API- and behaviour-compatible
28
with StringTokenizer. This implementation is, however, MUCH
31
EStdStringTokenizer tokenizes strings in a way which is
32
consistent with the way a Unix shell does. This makes it
33
appropriate for use in parsing many types of arbitrary user
34
input, from command-line arguments to comma-separated
37
class EStdStringTokenizer
40
EStdStringTokenizer();
41
~EStdStringTokenizer();
44
str is split up at points matching any element in
45
separators. Adjecent separators in str are
46
interpreted as empty elements. Thus the string
47
"1;;3", separated by ";", has 3 tokens:
50
To collect the tokens, do this:
52
EStdStringTokenizer tok( "some string", " " );
53
while( tok.hasMoreTokens() ) cout << "Token: " << tok.nextToken() << endl;
55
void tokenize( const string &str, const string &separators );
57
Returns the next token in our list.
58
Calling nextToken() when hasMoreTokens() returns
59
false has undefined behaviour.
63
Returns true if this object has more tokens to give you.
65
bool hasMoreTokens() const;
68
typedef std::queue<std::string> queue_type;
73
#endif // ESTDSTRINGTOKENIZER_H