1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: String tokenizer
4 // Author: Guilhem Lavaux
5 // Modified by: Vadim Zeitlin
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "tokenzr.h"
19 #include "wx/object.h"
20 #include "wx/string.h"
22 // default: delimiters are usual white space characters
23 #define wxDEFAULT_DELIMITERS (_T(" \t\r\n"))
25 class WXDLLEXPORT wxStringTokenizer
: public wxObject
29 wxStringTokenizer() { m_retdelims
= FALSE
; m_pos
= 0; }
30 wxStringTokenizer(const wxString
& to_tokenize
,
31 const wxString
& delims
= wxDEFAULT_DELIMITERS
,
32 bool ret_delim
= FALSE
);
33 void SetString(const wxString
& to_tokenize
,
34 const wxString
& delims
= wxDEFAULT_DELIMITERS
,
35 bool ret_delim
= FALSE
);
36 virtual ~wxStringTokenizer();
38 // count tokens/get next token
39 size_t CountTokens() const;
40 bool HasMoreTokens() { return m_hasMore
; }
41 wxString
GetNextToken();
43 // One note about GetString -- it returns the string
44 // remaining after the previous tokens have been removed,
45 // not the original string
46 wxString
GetString() const { return m_string
; }
48 // returns the current position (i.e. one index after the last returned
49 // token or 0 if GetNextToken() has never been called) in the original
51 size_t GetPosition() const { return m_pos
; }
53 // for compatibility only, use GetNextToken() instead
54 wxString
NextToken() { return GetNextToken(); }
57 wxString m_string
, // the (rest of) string to tokenize
58 m_delims
; // all delimiters
60 size_t m_pos
; // the position in the original string
62 bool m_retdelims
; // if TRUE, return delims with tokens
63 bool m_hasMore
; // do we have more tokens?
66 #endif // _WX_TOKENZRH