]>
Commit | Line | Data |
---|---|---|
d134d2d4 JS |
1 | \section{\class{wxStringTokenizer}}\label{wxstringtokenizer} |
2 | ||
3 | wxStringTokenizer helps you to break a string up into a number of tokens. | |
4 | ||
bbf8fc53 VZ |
5 | To use this class, you should create a wxStringTokenizer object, give it the |
6 | string to tokenize and also the delimiters which separate tokens in the string | |
7 | (by default, white space characters will be used). | |
8 | ||
9 | Then \helpref{GetNextToken}{wxstringtokenizergetnexttoken} may be called | |
10 | repeatedly until it \helpref{HasMoreTokens}{wxstringtokenizerhasmoretokens} | |
11 | returns FALSE. | |
12 | ||
13 | For example: | |
14 | ||
15 | \begin{verbatim} | |
16 | ||
17 | wxStringTokenizer tkz("first:second:third::fivth", ":"); | |
18 | while ( tkz.HasMoreTokens() ) | |
19 | { | |
20 | wxString token = tkz.GetNextToken(); | |
21 | ||
22 | // process token here | |
23 | } | |
24 | \end{verbatim} | |
25 | ||
26 | Another feature of this class is that it may return the delimiter which | |
27 | was found after the token with it. In a simple case like above, you are not | |
28 | interested in this because the delimiter is always {\tt ':'}, but if the | |
29 | delimiters string has several characters, you might need to know which of them | |
30 | follows the current token. In this case, pass {\tt TRUE} to wxStringTokenizer | |
31 | constructor or \helpref{SetString}{wxstringtokenizersetstring} method and | |
32 | the delimiter will be appended to each returned token (except for the last | |
33 | one). | |
34 | ||
d134d2d4 JS |
35 | \wxheading{Derived from} |
36 | ||
37 | \helpref{wxObject}{wxobject} | |
38 | ||
954b8ae6 JS |
39 | \wxheading{Include files} |
40 | ||
41 | <wx/tokenzr.h> | |
42 | ||
d134d2d4 JS |
43 | \latexignore{\rtfignore{\wxheading{Members}}} |
44 | ||
45 | \membersection{wxStringTokenizer::wxStringTokenizer}\label{wxstringtokenizerwxstringtokenizer} | |
46 | ||
dbdb39b2 JS |
47 | \func{}{wxStringTokenizer}{\void} |
48 | ||
49 | Default constructor. | |
50 | ||
e2a6f233 | 51 | \func{}{wxStringTokenizer}{\param{const wxString\& }{to\_tokenize}, \param{const wxString\& }{delims = " $\backslash$t$\backslash$r$\backslash$n"}, \param{bool }{ret\_delim = FALSE}} |
d134d2d4 | 52 | |
dbdb39b2 | 53 | Constructor. Pass the string to tokenize, a string containing delimiters, |
bbf8fc53 | 54 | a flag specifying whether to return delimiters with tokens. |
d134d2d4 JS |
55 | |
56 | \membersection{wxStringTokenizer::\destruct{wxStringTokenizer}}\label{wxstringtokenizerdtor} | |
57 | ||
58 | \func{}{\destruct{wxStringTokenizer}}{\void} | |
59 | ||
60 | Destructor. | |
61 | ||
62 | \membersection{wxStringTokenizer::CountTokens}\label{wxstringtokenizercounttokens} | |
63 | ||
ad813b00 | 64 | \constfunc{int}{CountTokens}{\void} |
d134d2d4 JS |
65 | |
66 | Returns the number of tokens in the input string. | |
67 | ||
ad813b00 | 68 | \membersection{wxStringTokenizer::HasMoreTokens}\label{wxstringtokenizerhasmoretokens} |
d134d2d4 | 69 | |
ad813b00 | 70 | \constfunc{bool}{HasMoreTokens}{\void} |
d134d2d4 JS |
71 | |
72 | Returns TRUE if the tokenizer has further tokens. | |
73 | ||
ad813b00 | 74 | \membersection{wxStringTokenizer::GetNextToken}\label{wxstringtokenizergetnexttoken} |
d134d2d4 | 75 | |
ad813b00 | 76 | \constfunc{wxString}{GetNextToken}{\void} |
d134d2d4 | 77 | |
bbf8fc53 VZ |
78 | Returns the next token or empty string if the end of string was reached. |
79 | ||
80 | \membersection{wxStringTokenizer::GetPosition}\label{wxstringtokenizergetposition} | |
81 | ||
82 | \constfunc{size\_t}{GetPosition}{\void} | |
83 | ||
84 | Returns the current position (i.e. one index after the last returned | |
85 | token or 0 if GetNextToken() has never been called) in the original | |
86 | string. | |
d134d2d4 JS |
87 | |
88 | \membersection{wxStringTokenizer::GetString}\label{wxstringtokenizergetstring} | |
89 | ||
ad813b00 | 90 | \constfunc{wxString}{GetString}{\void} |
d134d2d4 | 91 | |
bbf8fc53 | 92 | Returns the part of the starting string without all token already extracted. |
d134d2d4 | 93 | |
dbdb39b2 JS |
94 | \membersection{wxStringTokenizer::SetString}\label{wxstringtokenizersetstring} |
95 | ||
96 | \func{void}{SetString}{\param{const wxString\& }{to\_tokenize}, \param{const wxString\& }{delims = " $\backslash$t$\backslash$r$\backslash$n"}, \param{bool }{ret\_delim = FALSE}} | |
d134d2d4 | 97 | |
dbdb39b2 JS |
98 | Initializes the tokenizer. |
99 | ||
100 | Pass the string to tokenize, a string containing delimiters, | |
bbf8fc53 | 101 | a flag specifying whether to return delimiters with tokens. |
d134d2d4 | 102 |