SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-sim.org/
12 // Copyright (C) 2001-2013 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 
82 public:
85 
90  StringTokenizer(std::string tosplit);
91 
97  StringTokenizer(std::string tosplit, std::string token, bool splitAtAllChars = false);
98 
106  StringTokenizer(std::string tosplit, int special);
107 
110 
112  void reinit();
113 
115  bool hasNext();
116 
119  std::string next();
120 
122  size_t size() const;
123 
125  std::string front();
126 
128  std::string get(size_t pos) const;
129 
130  std::vector<std::string> getVector();
131 
132 private:
135  void prepare(const std::string& tosplit, const std::string& token,
136  bool splitAtAllChars);
137 
139  void prepareWhitechar(const std::string& tosplit);
140 
141 private:
143  typedef std::vector<size_t> SizeVector;
144 
146  std::string myTosplit;
147 
149  size_t myPos;
150 
153 
156 
157 };
158 
159 
160 #endif
161 
162 /****************************************************************************/
163 
std::string next()
static const int WHITECHARS
std::string myTosplit
static const int NEWLINE
std::vector< size_t > SizeVector
void prepare(const std::string &tosplit, const std::string &token, bool splitAtAllChars)
SizeVector myLengths
static const int SPACE
size_t size() const
SizeVector myStarts
std::string front()
std::vector< std::string > getVector()
void prepareWhitechar(const std::string &tosplit)