60 prepare(tosplit, token, splitAtAllChars);
77 char* buf =
new char[2];
78 buf[0] = (char) special;
145 int len = (int)token.length();
146 if (splitAtAllChars) {
149 while (beg < (
int)tosplit.length()) {
150 std::string::size_type end;
151 if (splitAtAllChars) {
152 end = tosplit.find_first_of(token, beg);
154 end = tosplit.find(token, beg);
156 if (end == std::string::npos) {
157 end = tosplit.length();
161 beg = (int)end + len;
162 if (beg == (
int)tosplit.length()) {
171 std::string::size_type len = tosplit.length();
172 std::string::size_type beg = 0;
173 while (beg < len && tosplit[beg] <=
SPACE) {
176 while (beg != std::string::npos && beg < len) {
177 std::string::size_type end = beg;
178 while (end < len && tosplit[end] >
SPACE) {
182 myLengths.push_back((
int)end - (
int)beg);
184 while (beg < len && tosplit[beg] <=
SPACE) {
191 std::vector<std::string>
193 std::vector<std::string> ret;
196 ret.push_back(
next());
void reinit()
reinitialises the internal iterator
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
static const int WHITECHARS
identifier for splitting the given string at all whitespace characters
std::string myTosplit
the string to split
std::string get(int pos) const
returns the item at the given position
static const int NEWLINE
identifier for splitting the given string at all newline characters
bool hasNext()
returns the information whether further substrings exist
StringTokenizer()
default constructor
void prepare(const std::string &tosplit, const std::string &token, bool splitAtAllChars)
splits the first string at all occurences of the second. If the third parameter is true split at all ...
~StringTokenizer()
destructor
int size() const
returns the number of existing substrings
SizeVector myLengths
the list of substring lengths
static const int SPACE
the ascii index of the highest whitespace character
SizeVector myStarts
the list of substring starts
std::string front()
returns the first substring without moving the iterator
static const int TAB
the ascii index of the tab character
std::vector< std::string > getVector()
return vector of strings
void prepareWhitechar(const std::string &tosplit)
splits the first string at all occurences of whitechars
int myPos
the current position in the list of substrings