StringTokenizer.h
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef StringTokenizer_h
00020 #define StringTokenizer_h
00021
00022
00023
00024
00025
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031
00032 #include <string>
00033 #include <vector>
00034
00061
00062
00063
00067 class StringTokenizer {
00068 public:
00070 static const int NEWLINE;
00071
00074 static const int WHITECHARS;
00075
00076 public:
00078 StringTokenizer() { }
00079
00084 StringTokenizer(std::string tosplit);
00085
00091 StringTokenizer(std::string tosplit, std::string token, bool splitAtAllChars=false);
00092
00100 StringTokenizer(std::string tosplit, int special);
00101
00103 ~StringTokenizer();
00104
00106 void reinit();
00107
00109 bool hasNext();
00110
00113 std::string next();
00114
00116 size_t size() const;
00117
00119 std::string front();
00120
00122 std::string get(size_t pos) const;
00123
00124 std::vector<std::string> getVector();
00125
00126 private:
00129 void prepare(const std::string &tosplit, const std::string &token,
00130 bool splitAtAllChars);
00131
00133 void prepareWhitechar(const std::string &tosplit);
00134
00135 private:
00137 typedef std::vector<size_t> SizeVector;
00138
00140 std::string myTosplit;
00141
00143 size_t myPos;
00144
00146 SizeVector myStarts;
00147
00149 SizeVector myLengths;
00150
00151 };
00152
00153
00154 #endif
00155
00156
00157