// Name: tokenzr.h
// Purpose: interface of wxStringTokenizer
// Author: wxWidgets team
-// RCS-ID: $Id$
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
/**
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,
wxTOKEN_STRTOK
};
+/// Default wxStringTokenizer delimiters are the usual white space characters.
+#define wxDEFAULT_DELIMITERS " \t\r\n"
+
/**
@class wxStringTokenizer
@library{wxbase}
@category{data}
- @see wxStringTokenize()
+ @see ::wxStringTokenize()
*/
class wxStringTokenizer : public wxObject
{
@see SetString()
*/
wxStringTokenizer(const wxString& str,
- const wxString& delims = " \t\r\n",
+ const wxString& delims = wxDEFAULT_DELIMITERS,
wxStringTokenizerMode mode = wxTOKEN_DEFAULT);
/**
wxString GetNextToken();
/**
- Returns the current position (i.e. one index after the last returned
+ 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.
*/
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/tokenzr.h}
+*/
+wxArrayString
+wxStringTokenize(const wxString& str,
+ const wxString& delims = wxDEFAULT_DELIMITERS,
+ wxStringTokenizerMode mode = wxTOKEN_DEFAULT);
+
+//@}