]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/tokenizr.tex
*** empty log message ***
[wxWidgets.git] / docs / latex / wx / tokenizr.tex
CommitLineData
d134d2d4
JS
1\section{\class{wxStringTokenizer}}\label{wxstringtokenizer}
2
3wxStringTokenizer helps you to break a string up into a number of tokens.
4
bbf8fc53
VZ
5To use this class, you should create a wxStringTokenizer object, give it the
6string to tokenize and also the delimiters which separate tokens in the string
7(by default, white space characters will be used).
8
9Then \helpref{GetNextToken}{wxstringtokenizergetnexttoken} may be called
10repeatedly until it \helpref{HasMoreTokens}{wxstringtokenizerhasmoretokens}
11returns FALSE.
12
13For example:
14
15\begin{verbatim}
16
17wxStringTokenizer tkz("first:second:third::fivth", ":");
18while ( tkz.HasMoreTokens() )
19{
20 wxString token = tkz.GetNextToken();
21
22 // process token here
23}
24\end{verbatim}
25
26Another feature of this class is that it may return the delimiter which
27was found after the token with it. In a simple case like above, you are not
28interested in this because the delimiter is always {\tt ':'}, but if the
29delimiters string has several characters, you might need to know which of them
30follows the current token. In this case, pass {\tt TRUE} to wxStringTokenizer
31constructor or \helpref{SetString}{wxstringtokenizersetstring} method and
32the delimiter will be appended to each returned token (except for the last
33one).
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
49Default 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 53Constructor. Pass the string to tokenize, a string containing delimiters,
bbf8fc53 54a 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
60Destructor.
61
62\membersection{wxStringTokenizer::CountTokens}\label{wxstringtokenizercounttokens}
63
ad813b00 64\constfunc{int}{CountTokens}{\void}
d134d2d4
JS
65
66Returns 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
72Returns 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
78Returns 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
84Returns the current position (i.e. one index after the last returned
85token or 0 if GetNextToken() has never been called) in the original
86string.
d134d2d4
JS
87
88\membersection{wxStringTokenizer::GetString}\label{wxstringtokenizergetstring}
89
ad813b00 90\constfunc{wxString}{GetString}{\void}
d134d2d4 91
bbf8fc53 92Returns 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
98Initializes the tokenizer.
99
100Pass the string to tokenize, a string containing delimiters,
bbf8fc53 101a flag specifying whether to return delimiters with tokens.
d134d2d4 102