TDME2
1.9.121
src
tdme
utilities
StringTokenizer.h
Go to the documentation of this file.
1
2
#pragma once
3
4
#include <string>
5
#include <vector>
6
7
#include <
tdme/tdme.h
>
8
#include <
tdme/utilities/fwd-tdme.h
>
9
10
using
std::string;
11
using
std::vector;
12
13
/**
14
* String tokenizer class
15
* @author Andreas Drewke
16
* @version $Id$
17
*/
18
class
tdme::utilities::StringTokenizer
19
{
20
21
private
:
22
vector<string>
tokens
;
23
int
idx
{ 0 };
24
25
public
:
26
/**
27
* Public constructor
28
*/
29
StringTokenizer
();
30
31
/**
32
* Tokenize
33
* @param str string to tokenize
34
* @param delimiters delimiters
35
*/
36
void
tokenize
(
const
string
& str,
const
string
& delimiters);
37
38
/**
39
* @return number of tokens
40
*/
41
inline
int32_t
countTokens
() {
42
return
tokens
.size();
43
}
44
45
/**
46
* @return has more tokens
47
*/
48
inline
bool
hasMoreTokens
() {
49
return
idx
!=
tokens
.size();
50
}
51
52
/**
53
* @return next token
54
*/
55
inline
const
string
&
nextToken
() {
56
return
tokens
[
idx
++];
57
}
58
59
/**
60
* @return tokens
61
*/
62
inline
const
vector<string>&
getTokens
() {
63
return
tokens
;
64
}
65
66
};
tdme::utilities::StringTokenizer
String tokenizer class.
Definition:
StringTokenizer.h:19
tdme::utilities::StringTokenizer::countTokens
int32_t countTokens()
Definition:
StringTokenizer.h:41
tdme::utilities::StringTokenizer::StringTokenizer
StringTokenizer()
Public constructor.
Definition:
StringTokenizer.cpp:11
tdme::utilities::StringTokenizer::nextToken
const string & nextToken()
Definition:
StringTokenizer.h:55
tdme::utilities::StringTokenizer::tokens
vector< string > tokens
Definition:
StringTokenizer.h:22
tdme::utilities::StringTokenizer::tokenize
void tokenize(const string &str, const string &delimiters)
Tokenize.
Definition:
StringTokenizer.cpp:14
tdme::utilities::StringTokenizer::getTokens
const vector< string > & getTokens()
Definition:
StringTokenizer.h:62
tdme::utilities::StringTokenizer::idx
int idx
Definition:
StringTokenizer.h:23
tdme::utilities::StringTokenizer::hasMoreTokens
bool hasMoreTokens()
Definition:
StringTokenizer.h:48
tdme.h
fwd-tdme.h
Generated by
1.9.3