X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e2a6f23364aefcd5095dc6558e3ab8144363fa96..7eb4e9cc0f3590fffda78bf02c47b25c41583eba:/docs/latex/wx/tokenizr.tex diff --git a/docs/latex/wx/tokenizr.tex b/docs/latex/wx/tokenizr.tex index 5fa0df6e01..b066262a52 100644 --- a/docs/latex/wx/tokenizr.tex +++ b/docs/latex/wx/tokenizr.tex @@ -2,18 +2,56 @@ wxStringTokenizer helps you to break a string up into a number of tokens. +To use this class, you should create a wxStringTokenizer object, give it the +string to tokenize and also the delimiters which separate tokens in the string +(by default, white space characters will be used). + +Then \helpref{GetNextToken}{wxstringtokenizergetnexttoken} may be called +repeatedly until it \helpref{HasMoreTokens}{wxstringtokenizerhasmoretokens} +returns FALSE. + +For example: + +\begin{verbatim} + +wxStringTokenizer tkz("first:second:third::fivth", ":"); +while ( tkz.HasMoreTokens() ) +{ + wxString token = tkz.GetNextToken(); + + // process token here +} +\end{verbatim} + +Another feature of this class is that it may return the delimiter which +was found after the token with it. In a simple case like above, you are not +interested in this because the delimiter is always {\tt ':'}, but if the +delimiters string has several characters, you might need to know which of them +follows the current token. In this case, pass {\tt TRUE} to wxStringTokenizer +constructor or \helpref{SetString}{wxstringtokenizersetstring} method and +the delimiter will be appended to each returned token (except for the last +one). + \wxheading{Derived from} \helpref{wxObject}{wxobject} +\wxheading{Include files} + + + \latexignore{\rtfignore{\wxheading{Members}}} \membersection{wxStringTokenizer::wxStringTokenizer}\label{wxstringtokenizerwxstringtokenizer} +\func{}{wxStringTokenizer}{\void} + +Default constructor. + \func{}{wxStringTokenizer}{\param{const wxString\& }{to\_tokenize}, \param{const wxString\& }{delims = " $\backslash$t$\backslash$r$\backslash$n"}, \param{bool }{ret\_delim = FALSE}} -Constructor. Pass the string to tokenze, a string containing delimiters, -a flag specifying whether delimiters are retained. +Constructor. Pass the string to tokenize, a string containing delimiters, +a flag specifying whether to return delimiters with tokens. \membersection{wxStringTokenizer::\destruct{wxStringTokenizer}}\label{wxstringtokenizerdtor} @@ -23,27 +61,42 @@ Destructor. \membersection{wxStringTokenizer::CountTokens}\label{wxstringtokenizercounttokens} -\constfunc{virtual int}{CountTokens}{\void} +\constfunc{int}{CountTokens}{\void} Returns the number of tokens in the input string. -\membersection{wxStringTokenizer::HasMoreToken}\label{wxstringtokenizerhasmoretoken} +\membersection{wxStringTokenizer::HasMoreTokens}\label{wxstringtokenizerhasmoretokens} -\constfunc{virtual bool}{HasMoreToken}{\void} +\constfunc{bool}{HasMoreTokens}{\void} Returns TRUE if the tokenizer has further tokens. -\membersection{wxStringTokenizer::NextToken}\label{wxstringtokenizernexttoken} +\membersection{wxStringTokenizer::GetNextToken}\label{wxstringtokenizergetnexttoken} + +\constfunc{wxString}{GetNextToken}{\void} -\constfunc{virtual wxString}{NextToken}{\void} +Returns the next token or empty string if the end of string was reached. -Returns the next token. +\membersection{wxStringTokenizer::GetPosition}\label{wxstringtokenizergetposition} + +\constfunc{size\_t}{GetPosition}{\void} + +Returns the current position (i.e. one index after the last returned +token or 0 if GetNextToken() has never been called) in the original +string. \membersection{wxStringTokenizer::GetString}\label{wxstringtokenizergetstring} -\constfunc{virtual wxString}{GetString}{\void} +\constfunc{wxString}{GetString}{\void} + +Returns the part of the starting string without all token already extracted. + +\membersection{wxStringTokenizer::SetString}\label{wxstringtokenizersetstring} -Returns the input string. +\func{void}{SetString}{\param{const wxString\& }{to\_tokenize}, \param{const wxString\& }{delims = " $\backslash$t$\backslash$r$\backslash$n"}, \param{bool }{ret\_delim = FALSE}} +Initializes the tokenizer. +Pass the string to tokenize, a string containing delimiters, +a flag specifying whether to return delimiters with tokens.