TDME2  1.9.200
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>
9 
10 using std::string;
11 using std::vector;
12 
13 /**
14  * String tokenizer class
15  * @author Andreas Drewke
16  */
18 {
19 
20 private:
21  vector<string> tokens;
22  int idx { 0 };
23 
24 public:
25  /**
26  * Public constructor
27  */
29 
30  /**
31  * Tokenize
32  * @param str string to tokenize
33  * @param delimiters delimiters
34  * @param emptyTokens include empty tokens
35  */
36  void tokenize(const string& str, const string& delimiters, bool emptyTokens = false);
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 };
String tokenizer class.
const vector< string > & getTokens()
StringTokenizer()
Public constructor.
void tokenize(const string &str, const string &delimiters, bool emptyTokens=false)
Tokenize.