]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/tokenizr.tex
Set/GetWindowMenu added to MDI parent frame under MSW
[wxWidgets.git] / docs / latex / wx / tokenizr.tex
1 \section{\class{wxStringTokenizer}}\label{wxstringtokenizer}
2
3 wxStringTokenizer helps you to break a string up into a number of tokens.
4
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
35 \wxheading{Derived from}
36
37 \helpref{wxObject}{wxobject}
38
39 \wxheading{Include files}
40
41 <wx/tokenzr.h>
42
43 \latexignore{\rtfignore{\wxheading{Members}}}
44
45 \membersection{wxStringTokenizer::wxStringTokenizer}\label{wxstringtokenizerwxstringtokenizer}
46
47 \func{}{wxStringTokenizer}{\void}
48
49 Default constructor.
50
51 \func{}{wxStringTokenizer}{\param{const wxString\& }{to\_tokenize}, \param{const wxString\& }{delims = " $\backslash$t$\backslash$r$\backslash$n"}, \param{bool }{ret\_delim = FALSE}}
52
53 Constructor. Pass the string to tokenize, a string containing delimiters,
54 a flag specifying whether to return delimiters with tokens.
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
64 \constfunc{int}{CountTokens}{\void}
65
66 Returns the number of tokens in the input string.
67
68 \membersection{wxStringTokenizer::HasMoreTokens}\label{wxstringtokenizerhasmoretokens}
69
70 \constfunc{bool}{HasMoreTokens}{\void}
71
72 Returns TRUE if the tokenizer has further tokens.
73
74 \membersection{wxStringTokenizer::GetNextToken}\label{wxstringtokenizergetnexttoken}
75
76 \constfunc{wxString}{GetNextToken}{\void}
77
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.
87
88 \membersection{wxStringTokenizer::GetString}\label{wxstringtokenizergetstring}
89
90 \constfunc{wxString}{GetString}{\void}
91
92 Returns the part of the starting string without all token already extracted.
93
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}}
97
98 Initializes the tokenizer.
99
100 Pass the string to tokenize, a string containing delimiters,
101 a flag specifying whether to return delimiters with tokens.
102