Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members

string_tokenizer.h

00001 #ifndef s11n_STRINGTOKENIZER_H
00002 #define s11n_STRINGTOKENIZER_H
00003 
00004 namespace s11n {
00005 
00006 
00007         /**
00008            string_tokenizer is a... well, a string tokenizer, modelled after
00009            Java's java.util.string_tokenizer class.
00010 
00011            This code used to be part of the KDE 1.x libraries: (named StringTokenizer)
00012            Copyright (C) 1997 Martin Jones (mjones@kde.org)
00013            (C) 1997 Torben Weis (weis@kde.org)
00014            (C) 1998 Waldo Bastian (bastian@kde.org)
00015            
00016            Then this code was part of the QUB project:
00017            Copyright (C) 2000-2003 stephan beal (stephan@s11n.net)
00018            and Rusty Ballinger (bozo@users.sourceforge.net)
00019            
00020            THIS code is part of the libessentials (a.k.a., elib):
00021            This copy is mainained by stephan@s11n.net
00022            i have explicit permission from the three original authors
00023            to release this code into the Public Domain, and this copy 
00024            falls under that "license."
00025         */
00026 
00027         class string_tokenizer
00028         {
00029         public:
00030                 string_tokenizer();
00031                 ~string_tokenizer();
00032 
00033                 /**
00034                    Sets the token list and separator to be used by
00035                    subsequent next_token() calls.
00036 
00037                    It is important that the strings not be
00038                    destroyed/freed by the client before this object is
00039                    done with them. That is, do not call tokenize(),
00040                    then free the strings, then call has_tokens() or
00041                    next_token(). (In practice, this has never happened.)
00042                  */
00043                 void tokenize( const char * sequence, const char * separator );
00044 
00045                 /**
00046                    Returns the next token in the list. Results are
00047                    undefined if this method is called when
00048                    has_tokens() returns false.
00049                 */
00050                 const char* next_token();
00051 
00052                 /**
00053                    Returns true if this object has another token to
00054                    return via next_token().
00055                  */
00056                 bool has_tokens();
00057 
00058         private:
00059                 char *pos;
00060                 char *end;
00061                 char *buffer;
00062                 int  bufLen;
00063         };
00064 
00065 }; // namespace s11n
00066 #endif // s11n_STRINGTOKENIZER_H
00067 

Generated on Tue Oct 26 18:25:59 2004 for s11n by  doxygen 1.3.9.1