SUMO - Simulation of Urban MObility
StringTokenizer.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // A java-style StringTokenizer for c++ (stl)
20 /****************************************************************************/
21 #ifndef StringTokenizer_h
22 #define StringTokenizer_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <string>
35 #include <vector>
36 
63 // ===========================================================================
64 // class definitions
65 // ===========================================================================
70 public:
72  static const int NEWLINE;
73 
76  static const int WHITECHARS;
77 
79  static const int SPACE;
80 
82  static const int TAB;
83 
84 public:
87 
92  StringTokenizer(std::string tosplit);
93 
99  StringTokenizer(std::string tosplit, std::string token, bool splitAtAllChars = false);
100 
108  StringTokenizer(std::string tosplit, int special);
109 
112 
114  void reinit();
115 
117  bool hasNext();
118 
121  std::string next();
122 
124  int size() const;
125 
127  std::string front();
128 
130  std::string get(int pos) const;
131 
132  std::vector<std::string> getVector();
133 
134 private:
137  void prepare(const std::string& tosplit, const std::string& token,
138  bool splitAtAllChars);
139 
141  void prepareWhitechar(const std::string& tosplit);
142 
143 private:
145  typedef std::vector<int> SizeVector;
146 
148  std::string myTosplit;
149 
151  int myPos;
152 
154  SizeVector myStarts;
155 
157  SizeVector myLengths;
158 
159 };
160 
161 
162 #endif
163 
164 /****************************************************************************/
165 
std::string next()
static const int WHITECHARS
std::string myTosplit
static const int NEWLINE
void prepare(const std::string &tosplit, const std::string &token, bool splitAtAllChars)
SizeVector myLengths
static const int SPACE
std::vector< int > SizeVector
SizeVector myStarts
std::string front()
static const int TAB
std::vector< std::string > getVector()
void prepareWhitechar(const std::string &tosplit)