50 myTosplit(tosplit), myPos(0) {
56 myTosplit(tosplit), myPos(0) {
57 prepare(tosplit, token, splitAtAllChars);
62 myTosplit(tosplit), myPos(0) {
74 char* buf =
new char[2];
75 buf[0] = (char) special;
142 int len = (int)token.length();
143 if (splitAtAllChars) {
146 while (beg < (
int)tosplit.length()) {
147 std::string::size_type end;
148 if (splitAtAllChars) {
149 end = tosplit.find_first_of(token, beg);
151 end = tosplit.find(token, beg);
153 if (end == std::string::npos) {
154 end = tosplit.length();
158 beg = (int)end + len;
159 if (beg == (
int)tosplit.length()) {
168 std::string::size_type len = tosplit.length();
169 std::string::size_type beg = 0;
170 while (beg < len && (
unsigned char)tosplit[beg] <=
SPACE) {
173 while (beg != std::string::npos && beg < len) {
174 std::string::size_type end = beg;
175 while (end < len && (
unsigned char)tosplit[end] >
SPACE) {
179 myLengths.push_back((
int)end - (
int)beg);
181 while (beg < len && (
unsigned char)tosplit[beg] <=
SPACE) {
188std::vector<std::string>
190 std::vector<std::string> ret;
193 ret.push_back(
next());
202 std::vector<std::string> v =
getVector();
203 return std::set<std::string>(v.begin(), v.end());
static const int NEWLINE
identifier for splitting the given string at all newline characters
std::string front()
returns the first substring without moving the iterator
std::set< std::string > getSet()
return set of strings
~StringTokenizer()
destructor
int size() const
returns the number of existing substrings
SizeVector myStarts
the list of substring starts
void reinit()
reinitialises the internal iterator
static const int WHITECHARS
identifier for splitting the given string at all whitespace characters
std::string get(int pos) const
returns the item at the given position
std::vector< std::string > getVector()
return vector of strings
bool hasNext()
returns the information whether further substrings exist
static const int TAB
the ascii index of the tab character
static const int SPACE
the ascii index of the highest whitespace character
SizeVector myLengths
the list of substring lengths
StringTokenizer()
default constructor
int myPos
the current position in the list of substrings
void prepare(const std::string &tosplit, const std::string &token, bool splitAtAllChars)
splits the first string at all occurrences of the second. If the third parameter is true split at all...
std::string myTosplit
the string to split
void prepareWhitechar(const std::string &tosplit)
splits the first string at all occurrences of whitechars
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined