]> git.saurik.com Git - wxWidgets.git/blob - include/wx/tokenzr.h
b1d8ed65cc1ae33a69eeb70e32d81738ca3d3c64
[wxWidgets.git] / include / wx / tokenzr.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: tokenzr.h
3 // Purpose: String tokenizer
4 // Author: Guilhem Lavaux
5 // Modified by: Gregory Pietsch
6 // Created: 04/22/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TOKENZRH
13 #define _WX_TOKENZRH
14
15 #ifdef __GNUG__
16 #pragma interface "tokenzr.h"
17 #endif
18
19 #include "wx/object.h"
20 #include "wx/string.h"
21 #include "wx/filefn.h"
22
23 class WXDLLEXPORT wxStringTokenizer : public wxObject
24 {
25 public:
26 wxStringTokenizer(const wxString& to_tokenize,
27 const wxString& delims = " \t\r\n",
28 bool ret_delim = FALSE);
29 wxStringTokenizer() { m_retdelims = FALSE; m_pos = 0; }
30 virtual ~wxStringTokenizer();
31
32 int CountTokens() const;
33 bool HasMoreTokens();
34
35 wxString NextToken();
36 wxString GetNextToken() { return NextToken(); };
37
38 wxString GetString() const { return m_string; }
39 // One note about GetString -- it returns the string
40 // remaining after the previous tokens have been removed,
41 // not the original string
42
43 void SetString(const wxString& to_tokenize,
44 const wxString& delims = " \t\r\n",
45 bool ret_delim = FALSE)
46 {
47 m_string = to_tokenize;
48 m_delims = delims;
49 m_retdelims = ret_delim;
50 m_pos = 0;
51 }
52
53 // Here's the desired function. It returns the position
54 // of the next token in the original string by keeping track
55 // of everything that's been deleted by GetNextToken.
56 wxUint32 GetPosition() { return m_pos; }
57
58 protected:
59 wxString m_string, m_delims;
60 bool m_retdelims;
61 wxUint32 m_pos; // the position
62 };
63
64 #endif // _WX_TOKENZRH