ScummVM API documentation
tokenizer.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef COMMON_TOKENIZER_H
23 #define COMMON_TOKENIZER_H
24 
25 #include "common/scummsys.h"
26 #include "common/str-array.h"
27 
28 namespace Common {
29 
45 template<class T>
47 public:
54  BaseStringTokenizer(const T &str, const String &delimiters = " \t\r\n\f\v");
55  void reset();
56  bool empty() const;
57  T nextToken();
58  Array<T> split();
59 
60  T delimitersAtTokenBegin() const;
61  T delimitersAtTokenEnd() const;
62 
63 private:
64  const T _str;
65  const String _delimiters;
66  typename T::const_iterator _tokenBegin;
67  typename T::const_iterator _tokenEnd;
68 };
69 
72 
75 } // End of namespace Common
76 
77 #endif
T delimitersAtTokenBegin() const
Returns a String with all delimiters between the current and previous token.
bool empty() const
Returns true if there are no more tokens left in the string, false otherwise.
Definition: str.h:59
T delimitersAtTokenEnd() const
Returns a String with all delimiters between the current and next token.
Definition: array.h:52
T nextToken()
Returns the next token from the string (Or an empty string if there are no more tokens) ...
BaseStringTokenizer(const T &str, const String &delimiters=" \\\)
Definition: tokenizer.h:46
Definition: algorithm.h:29
void reset()
Resets the tokenizer to its initial state, i.e points boten token iterators to the beginning...
Array< T > split()
Returns an Array with all tokens. Beware of the memory usage.