File: EStdStringTokenizer.h

package info (click to toggle)
miwm 1.1-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 1,296 kB
  • ctags: 910
  • sloc: cpp: 8,179; sh: 231; makefile: 148
file content (74 lines) | stat: -rw-r--r-- 2,684 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef ESTDSTRINGTOKENIZER_H
#define ESTDSTRINGTOKENIZER_H

#include <string>
#include <queue>

        using std::string;
        /**
           EStdStringTokenizer:

           License: see the file LICENSE in this directory.
           Author: stephan@wanderinghorse.net
           
           Based heavily off of work by:
           
           Martin Jones (mjones@kde.org)
           Torben Weis (weis@kde.org)
	   Waldo Bastian (bastian@kde.org)

           which i originally found as StringTokenizer in the KDE 1.x
           source tree. i have received explicit permission from each
           of those gentlemen to release the StringTokenizer code into
           into the Public Domain. (Many thanks to them for that
           permission, without which this whole library would
           necessarily be released under the GNU GPL.)

	   This class is meant to be API- and behaviour-compatible
           with StringTokenizer. This implementation is, however, MUCH
           less efficient.
           
           EStdStringTokenizer tokenizes strings in a way which is
           consistent with the way a Unix shell does. This makes it
           appropriate for use in parsing many types of arbitrary user
           input, from command-line arguments to comma-separated
           files.
        */
        class EStdStringTokenizer
        {
        public:
                EStdStringTokenizer();
                ~EStdStringTokenizer();

                /**
                   str is split up at points matching any element in
                   separators. Adjecent separators in str are
                   interpreted as empty elements. Thus the string
                   "1;;3", separated by ";", has 3 tokens:
                   ("1","","3").

                   To collect the tokens, do this:

                   EStdStringTokenizer tok( "some string", " " );
                   while( tok.hasMoreTokens() ) cout << "Token: " << tok.nextToken() << endl;
                 */
                void tokenize( const string &str, const string &separators );
                /**
                   Returns the next token in our list.
                   Calling nextToken() when hasMoreTokens() returns
                   false has undefined behaviour.
                 */
                string nextToken();
                /**
                   Returns true if this object has more tokens to give you.
                */
                bool hasMoreTokens() const;

        private:
                typedef std::queue<std::string> queue_type;
                //EStringList m_list;
                queue_type m_list;
        };

#endif // ESTDSTRINGTOKENIZER_H