44#ifndef COMMONCPP_TOKENIZER_H_
45#define COMMONCPP_TOKENIZER_H_
47#ifndef COMMONCPP_CONFIG_H_
48#include <commoncpp/config.h>
51#ifndef COMMONCPP_THREAD_H_
55#ifndef COMMMONCPP_EXCEPTION_H_
140 : myTok(&tok),tokEnd(0),endp(end),token(0) {}
143 : myTok(&tok),tokEnd(0),endp(myTok->str-1),token(0) {
148 iterator() : myTok(0),start(0),tokEnd(0),endp(0),token(0) {}
152 {
if (token) *token=
'\0';
delete [] token; }
159 myTok(i.myTok),start(i.start),tokEnd(i.tokEnd),
160 endp(i.endp),token(0) {}
168 start = i.start; endp = i.endp; tokEnd = i.tokEnd;
196 inline
char nextDelimiter()
const
197 {
return (tokEnd) ? *tokEnd :
'\0';}
204 inline bool operator == (
const iterator &other)
const
205 {
return (endp == other.endp);}
212 inline bool operator != (
const iterator &other)
const
213 {
return (endp != other.endp);}
263 bool skipAllDelim =
false,
GNU Common C++ exception model base classes.
Splits delimited string into tokens.
void setDelimiters(const char *d)
changes the set of delimiters used in subsequent iterations.
static const char *const SPACE
a delimiter string containing all usual whitespace delimiters.
iterator begin() const
returns the begin iterator
StringTokenizer(const char *str, const char *delim, bool skipAllDelim=false, bool trim=false)
creates a new StringTokenizer for a string and a given set of delimiters.
const iterator & end() const
the iterator marking the end.
StringTokenizer(const char *s)
create a new StringTokenizer which splits the input string at whitespaces.
iterator begin(const char *d)
returns a begin iterator with an alternate set of delimiters.
Exception thrown, if someone tried to read beyond the end of the tokens.
The input forward iterator for tokens.
iterator(const iterator &i)
copy constructor.
iterator & operator++()
shifts this iterator to the next token in the string.
iterator & operator=(const iterator &i)
assignment operator.
Common C++ thread class and sychronization objects.