X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ae3c17b4013e80b99976c750c19fca47729517f6..81a887a895e89622649ff394820800e2071fe6df:/interface/wx/tokenzr.h?ds=inline diff --git a/interface/wx/tokenzr.h b/interface/wx/tokenzr.h index f576de6b5e..f27ba1a5f6 100644 --- a/interface/wx/tokenzr.h +++ b/interface/wx/tokenzr.h @@ -3,7 +3,7 @@ // Purpose: interface of wxStringTokenizer // Author: wxWidgets team // RCS-ID: $Id$ -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// /** @@ -28,8 +28,8 @@ enum wxStringTokenizerMode /** In this mode, the empty tokens in the middle of the string will be returned, - i.e. @c "a::b:" will be tokenized in three tokens @c 'a', " and @c 'b'. Notice - that all trailing delimiters are ignored in this mode, not just the last one, + i.e. @c "a::b:" will be tokenized in three tokens @c 'a', @c '' and @c 'b'. + Notice that all trailing delimiters are ignored in this mode, not just the last one, i.e. a string @c "a::b::" would still result in the same set of tokens. */ wxTOKEN_RET_EMPTY, @@ -59,9 +59,11 @@ enum wxStringTokenizerMode wxTOKEN_STRTOK }; +/// Default wxStringTokenizer delimiters are the usual white space characters. +#define wxDEFAULT_DELIMITERS " \t\r\n" + /** @class wxStringTokenizer - @wxheader{tokenzr.h} wxStringTokenizer helps you to break a string up into a number of tokens. It replaces the standard C function @c strtok() and also extends it in a @@ -89,7 +91,7 @@ enum wxStringTokenizerMode @library{wxbase} @category{data} - @see wxStringTokenize() + @see ::wxStringTokenize() */ class wxStringTokenizer : public wxObject { @@ -107,7 +109,7 @@ public: @see SetString() */ wxStringTokenizer(const wxString& str, - const wxString& delims = " \t\r\n", + const wxString& delims = wxDEFAULT_DELIMITERS, wxStringTokenizerMode mode = wxTOKEN_DEFAULT); /** @@ -116,7 +118,7 @@ public: GetNextToken() is called and when it reaches 0, HasMoreTokens() returns @false. */ - int CountTokens() const; + size_t CountTokens() const; /** Returns the delimiter which ended scan for the last token returned by @@ -126,12 +128,12 @@ public: @since 2.7.0 */ - wxChar GetLastDelimiter(); + wxChar GetLastDelimiter() const; /** Returns the next token or empty string if the end of string was reached. */ - wxString GetNextToken() const; + wxString GetNextToken(); /** Returns the current position (i.e. one index after the last returned @@ -155,7 +157,29 @@ public: containing delimiters, and the @a mode specifying how the string should be tokenized. */ - void SetString(const wxString& to_tokenize, - const wxString& delims = " \t\r\n", + void SetString(const wxString& str, + const wxString& delims = wxDEFAULT_DELIMITERS, wxStringTokenizerMode mode = wxTOKEN_DEFAULT); }; + + +/** @addtogroup group_funcmacro_string */ +//@{ + +/** + This is a convenience function wrapping wxStringTokenizer which simply + returns all tokens found in the given @a str as an array. + + Please see wxStringTokenizer::wxStringTokenizer for the description + of the other parameters. + + @return The array with the parsed tokens. + + @header{wx/string.h} +*/ +wxArrayString +wxStringTokenize(const wxString& str, + const wxString& delims = wxDEFAULT_DELIMITERS, + wxStringTokenizerMode mode = wxTOKEN_DEFAULT); + +//@}