SUMO - Simulation of Urban MObility
StringTokenizer.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A java-style StringTokenizer for c++ (stl)
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef StringTokenizer_h
23 #define StringTokenizer_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <vector>
37 
64 // ===========================================================================
65 // class definitions
66 // ===========================================================================
71 public:
73  static const int NEWLINE;
74 
77  static const int WHITECHARS;
78 
80  static const int SPACE;
81 
83  static const int TAB;
84 
85 public:
88 
93  StringTokenizer(std::string tosplit);
94 
100  StringTokenizer(std::string tosplit, std::string token, bool splitAtAllChars = false);
101 
109  StringTokenizer(std::string tosplit, int special);
110 
113 
115  void reinit();
116 
118  bool hasNext();
119 
122  std::string next();
123 
125  int size() const;
126 
128  std::string front();
129 
131  std::string get(int pos) const;
132 
133  std::vector<std::string> getVector();
134 
135 private:
138  void prepare(const std::string& tosplit, const std::string& token,
139  bool splitAtAllChars);
140 
142  void prepareWhitechar(const std::string& tosplit);
143 
144 private:
146  typedef std::vector<int> SizeVector;
147 
149  std::string myTosplit;
150 
152  int myPos;
153 
155  SizeVector myStarts;
156 
158  SizeVector myLengths;
159 
160 };
161 
162 
163 #endif
164 
165 /****************************************************************************/
166 
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)