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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // A java-style StringTokenizer for c++ (stl)
18 /****************************************************************************/
19 #ifndef StringTokenizer_h
20 #define StringTokenizer_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <string>
29 #include <vector>
30 
57 // ===========================================================================
58 // class definitions
59 // ===========================================================================
64 public:
66  static const int NEWLINE;
67 
70  static const int WHITECHARS;
71 
73  static const int SPACE;
74 
76  static const int TAB;
77 
78 public:
81 
86  StringTokenizer(std::string tosplit);
87 
93  StringTokenizer(std::string tosplit, std::string token, bool splitAtAllChars = false);
94 
102  StringTokenizer(std::string tosplit, int special);
103 
106 
108  void reinit();
109 
111  bool hasNext();
112 
115  std::string next();
116 
118  int size() const;
119 
121  std::string front();
122 
124  std::string get(int pos) const;
125 
126  std::vector<std::string> getVector();
127 
128 private:
131  void prepare(const std::string& tosplit, const std::string& token,
132  bool splitAtAllChars);
133 
135  void prepareWhitechar(const std::string& tosplit);
136 
137 private:
139  typedef std::vector<int> SizeVector;
140 
142  std::string myTosplit;
143 
145  int myPos;
146 
148  SizeVector myStarts;
149 
151  SizeVector myLengths;
152 
153 };
154 
155 
156 #endif
157 
158 /****************************************************************************/
159 
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)