2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: string.h
|
2008-10-07 16:57:34 +00:00
|
|
|
// Purpose: interface of wxStringBuffer, wxString
|
2008-03-08 13:52:38 +00:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
2010-07-13 13:29:13 +00:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
@class wxString
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-08-29 12:46:41 +00:00
|
|
|
The wxString class has been completely rewritten for wxWidgets 3.0
|
|
|
|
and this change was actually the main reason for the calling that
|
|
|
|
version wxWidgets 3.0.
|
|
|
|
|
2008-06-06 21:19:23 +00:00
|
|
|
wxString is a class representing a Unicode character string.
|
2008-12-06 16:24:52 +00:00
|
|
|
wxString uses @c std::basic_string internally (even if @c wxUSE_STL is not defined)
|
|
|
|
to store its content (unless this is not supported by the compiler or disabled
|
|
|
|
specifically when building wxWidgets) and it therefore inherits
|
|
|
|
many features from @c std::basic_string. (Note that most implementations of
|
|
|
|
@c std::basic_string are thread-safe and don't use reference counting.)
|
|
|
|
|
|
|
|
These @c std::basic_string standard functions are only listed here, but
|
|
|
|
they are not fully documented in this manual; see the STL documentation
|
|
|
|
(http://www.cppreference.com/wiki/string/start) for more info.
|
2008-05-07 17:36:28 +00:00
|
|
|
The behaviour of all these functions is identical to the behaviour
|
|
|
|
described there.
|
2008-04-25 13:09:35 +00:00
|
|
|
|
2008-05-07 18:52:58 +00:00
|
|
|
You may notice that wxString sometimes has several functions which do
|
2008-12-06 16:24:52 +00:00
|
|
|
the same thing like Length(), Len() and length() which all return the
|
|
|
|
string length. In all cases of such duplication the @c std::string
|
|
|
|
compatible methods should be used.
|
|
|
|
|
|
|
|
For informations about the internal encoding used by wxString and
|
|
|
|
for important warnings and advices for using it, please read
|
|
|
|
the @ref overview_string.
|
|
|
|
|
2009-01-31 15:57:45 +00:00
|
|
|
Since wxWidgets 3.0 wxString always stores Unicode strings, so you should
|
2008-12-06 16:24:52 +00:00
|
|
|
be sure to read also @ref overview_unicode.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-10-07 16:57:34 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@section string_index Index of the member groups
|
|
|
|
|
|
|
|
Links for quick access to the various categories of wxString functions:
|
|
|
|
- @ref_member_group{ctor, Constructors and assignment operators}
|
|
|
|
- @ref_member_group{length, Length functions}
|
|
|
|
- @ref_member_group{ch_access, Character access functions}
|
|
|
|
- @ref_member_group{conv, Conversions functions}
|
|
|
|
- @ref_member_group{concat, Concatenation functions}
|
|
|
|
- @ref_member_group{cmp, Comparison functions}
|
|
|
|
- @ref_member_group{substring, Substring extraction functions}
|
|
|
|
- @ref_member_group{caseconv, Case conversion functions}
|
|
|
|
- @ref_member_group{search, Searching and replacing functions}
|
|
|
|
- @ref_member_group{numconv, Conversion to numbers functions}
|
|
|
|
- @ref_member_group{fmt, Formatting and printing functions}
|
|
|
|
- @ref_member_group{mem, Memory management functions}
|
|
|
|
- @ref_member_group{misc, Miscellaneous functions}
|
|
|
|
- @ref_member_group{iter, Iterator interface functions}
|
|
|
|
- @ref_member_group{stl, STL interface functions}
|
2008-10-07 16:57:34 +00:00
|
|
|
|
2008-04-25 19:52:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxbase}
|
|
|
|
@category{data}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@stdobjects
|
2008-10-07 16:57:34 +00:00
|
|
|
::wxEmptyString
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2009-04-21 00:05:06 +00:00
|
|
|
@see @ref overview_string, @ref overview_unicode,
|
2009-03-19 14:51:46 +00:00
|
|
|
@ref group_funcmacro_string "String-related functions", wxUString,
|
|
|
|
wxCharBuffer, wxUniChar, wxStringTokenizer, wxStringBuffer, wxStringBufferLength
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
class wxString
|
2008-03-08 13:52:38 +00:00
|
|
|
{
|
|
|
|
public:
|
2008-06-06 21:19:23 +00:00
|
|
|
/**
|
2008-05-06 12:51:35 +00:00
|
|
|
@name Standard types
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
Types used with wxString.
|
2008-05-06 10:42:50 +00:00
|
|
|
*/
|
2008-05-06 12:51:35 +00:00
|
|
|
//@{
|
2008-05-06 10:42:50 +00:00
|
|
|
typedef wxUniChar value_type;
|
|
|
|
typedef wxUniChar char_type;
|
|
|
|
typedef wxUniCharRef reference;
|
|
|
|
typedef wxChar* pointer;
|
|
|
|
typedef const wxChar* const_pointer;
|
|
|
|
typedef size_t size_type;
|
|
|
|
typedef wxUniChar const_reference;
|
|
|
|
//@}
|
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
@member_group_name{ctor, Constructors and assignment operators}
|
|
|
|
|
|
|
|
A string may be constructed either from a C string, (some number of copies of)
|
|
|
|
a single character or a wide (Unicode) string. For all constructors (except the
|
|
|
|
default which creates an empty string) there is also a corresponding assignment
|
|
|
|
operator.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
See also the assign() STL-like function.
|
|
|
|
*/
|
|
|
|
//@{
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2008-04-25 13:09:35 +00:00
|
|
|
Default constructor
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
wxString();
|
2008-06-06 21:19:23 +00:00
|
|
|
|
2008-04-25 13:09:35 +00:00
|
|
|
/**
|
2008-10-07 16:57:34 +00:00
|
|
|
Creates a string from another string.
|
2009-03-19 14:51:46 +00:00
|
|
|
Just increases the ref count by 1.
|
2008-04-25 13:09:35 +00:00
|
|
|
*/
|
|
|
|
wxString(const wxString& stringSrc);
|
2008-06-06 21:19:23 +00:00
|
|
|
|
2009-09-12 10:42:04 +00:00
|
|
|
/**
|
|
|
|
Construct a string consisting of @a nRepeat copies of ch.
|
|
|
|
*/
|
|
|
|
wxString(wxUniChar ch, size_t nRepeat = 1);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Construct a string consisting of @a nRepeat copies of ch.
|
|
|
|
*/
|
|
|
|
wxString(wxUniCharRef ch, size_t nRepeat = 1);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Construct a string consisting of @a nRepeat copies of ch
|
|
|
|
converted to Unicode using the current locale encoding.
|
|
|
|
*/
|
|
|
|
wxString(char ch, size_t nRepeat = 1);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Construct a string consisting of @a nRepeat copies of ch.
|
|
|
|
*/
|
|
|
|
wxString(wchar_t ch, size_t nRepeat = 1);
|
2008-04-25 13:09:35 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Constructs a string from the string literal @a psz using
|
2008-05-07 18:52:58 +00:00
|
|
|
the current locale encoding to convert it to Unicode (wxConvLibc).
|
2008-04-25 13:09:35 +00:00
|
|
|
*/
|
|
|
|
wxString(const char *psz);
|
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Constructs a string from the string literal @a psz using
|
|
|
|
@a conv to convert it Unicode.
|
2008-04-25 13:09:35 +00:00
|
|
|
*/
|
|
|
|
wxString(const char *psz, const wxMBConv& conv);
|
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Constructs a string from the first @a nLength character of the string literal @a psz using
|
2008-05-07 18:52:58 +00:00
|
|
|
the current locale encoding to convert it to Unicode (wxConvLibc).
|
2008-04-25 13:09:35 +00:00
|
|
|
*/
|
|
|
|
wxString(const char *psz, size_t nLength);
|
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Constructs a string from the first @a nLength character of the string literal @a psz using
|
|
|
|
@a conv to convert it Unicode.
|
2008-04-25 13:09:35 +00:00
|
|
|
*/
|
|
|
|
wxString(const char *psz, const wxMBConv& conv, size_t nLength);
|
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Constructs a string from the string literal @a pwz.
|
2008-04-25 13:09:35 +00:00
|
|
|
*/
|
|
|
|
wxString(const wchar_t *pwz);
|
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Constructs a string from the first @a nLength characters of the string literal @a pwz.
|
2008-04-25 13:09:35 +00:00
|
|
|
*/
|
|
|
|
wxString(const wchar_t *pwz, size_t nLength);
|
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Constructs a string from @a buf using the using the current locale
|
2008-10-07 16:57:34 +00:00
|
|
|
encoding to convert it to Unicode.
|
2008-04-25 13:09:35 +00:00
|
|
|
*/
|
|
|
|
wxString(const wxCharBuffer& buf);
|
2008-06-06 21:19:23 +00:00
|
|
|
|
2008-04-25 13:09:35 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Constructs a string from @a buf.
|
2008-04-25 13:09:35 +00:00
|
|
|
*/
|
|
|
|
wxString(const wxWCharBuffer& buf);
|
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Constructs a string from @a str using the using the current locale encoding
|
2008-05-07 18:52:58 +00:00
|
|
|
to convert it to Unicode (wxConvLibc).
|
2010-04-11 11:08:49 +00:00
|
|
|
|
|
|
|
@see ToStdString()
|
2008-04-25 13:09:35 +00:00
|
|
|
*/
|
|
|
|
wxString(const std::string& str);
|
2008-06-06 21:19:23 +00:00
|
|
|
|
2008-04-25 13:09:35 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Constructs a string from @a str.
|
2010-04-11 11:08:49 +00:00
|
|
|
|
|
|
|
@see ToStdWstring()
|
2008-04-25 13:09:35 +00:00
|
|
|
*/
|
|
|
|
wxString(const std::wstring& str);
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2008-10-07 16:57:34 +00:00
|
|
|
String destructor.
|
|
|
|
|
|
|
|
Note that this is not virtual, so wxString must not be inherited from.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
~wxString();
|
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Assignment: see the relative wxString constructor.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString operator =(const wxString& str);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Assignment: see the relative wxString constructor.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString operator =(wxUniChar c);
|
2008-04-05 17:50:16 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
//@}
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-04-05 17:50:16 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
@member_group_name{length, String length}
|
2008-05-21 08:10:00 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
These functions return the string length and/or check whether the string
|
|
|
|
is empty.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
See also the length(), size() or empty() STL-like functions.
|
2008-05-21 08:10:00 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
//@{
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-05-21 08:10:00 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns the length of the string.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
size_t Len() const;
|
2008-05-21 08:10:00 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns the length of the string (same as Len).
|
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
2008-05-21 08:10:00 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
size_t Length() const;
|
2008-05-21 08:10:00 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns @true if the string is empty.
|
2008-05-21 08:10:00 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
bool IsEmpty() const;
|
2008-05-21 08:10:00 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns @true if the string is empty (same as wxString::IsEmpty).
|
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
2008-05-21 08:10:00 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
bool IsNull() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Empty string is @false, so !string will only return @true if the
|
|
|
|
string is empty.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@see IsEmpty().
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
bool operator!() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
//@}
|
2008-08-01 23:39:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
@member_group_name{ch_access, Character access}
|
|
|
|
|
2009-04-21 00:05:06 +00:00
|
|
|
Many functions below take a character index in the string.
|
|
|
|
As with C strings and arrays, the indices start from 0, so the first character
|
2009-03-19 14:51:46 +00:00
|
|
|
of a string is string[0]. An attempt to access a character beyond the end of the
|
|
|
|
string (which may even be 0 if the string is empty) will provoke an assert
|
|
|
|
failure in @ref overview_debugging "debug builds", but no checks are
|
|
|
|
done in release builds.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
//@{
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-04-24 07:16:48 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns the character at position @a n (read-only).
|
|
|
|
*/
|
|
|
|
wxUniChar GetChar(size_t n) const;
|
2008-04-24 07:16:48 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
wxWidgets compatibility conversion. Same as c_str().
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
const wxCStrData GetData() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns a reference to the character at position @a n.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxUniCharRef GetWritableChar(size_t n);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns a writable buffer of at least @a len bytes.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
It returns a pointer to a new memory block, and the existing data will not be copied.
|
|
|
|
Call UngetWriteBuf() as soon as possible to put the string back into a reasonable state.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This method is deprecated, please use wxStringBuffer or wxStringBufferLength instead.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxStringCharType* GetWriteBuf(size_t len);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Puts the string back into a reasonable state (in which it can be used
|
|
|
|
normally), after GetWriteBuf() was called.
|
|
|
|
|
|
|
|
The version of the function without the @a len parameter will calculate the
|
|
|
|
new string length itself assuming that the string is terminated by the first
|
|
|
|
@c NUL character in it while the second one will use the specified length
|
|
|
|
and thus is the only version which should be used with the strings with
|
|
|
|
embedded @c NULs (it is also slightly more efficient as @c strlen()
|
|
|
|
doesn't have to be called).
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This method is deprecated, please use wxStringBuffer or wxStringBufferLength instead.
|
|
|
|
*/
|
|
|
|
void UngetWriteBuf();
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
@overload
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
void UngetWriteBuf(size_t len);
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Sets the character at position @e n.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
void SetChar(size_t n, wxUniChar ch);
|
2008-06-06 21:19:23 +00:00
|
|
|
|
2008-05-21 08:10:00 +00:00
|
|
|
/**
|
2011-03-22 14:08:30 +00:00
|
|
|
Returns the last character.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This is a wxWidgets 1.xx compatibility function;
|
|
|
|
you should not use it in new code.
|
2008-05-21 08:10:00 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxUniChar Last() const;
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns a reference to the last character (writable).
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-06-06 21:19:23 +00:00
|
|
|
This is a wxWidgets 1.xx compatibility function;
|
2008-05-06 10:42:50 +00:00
|
|
|
you should not use it in new code.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxUniCharRef Last();
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns the @a i-th character of the string.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxUniChar operator [](size_t i) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns a writable reference to the @a i-th character of the string.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxUniCharRef operator [](size_t i);
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
//@}
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
@member_group_name{conv, Conversions}
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This section contains both implicit and explicit conversions to C style
|
|
|
|
strings. Although implicit conversion is quite convenient, you are advised
|
|
|
|
to use wc_str() for the sake of clarity.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
//@{
|
2009-03-19 14:51:46 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns a lightweight intermediate class which is in turn implicitly
|
|
|
|
convertible to both @c const @c char* and to @c const @c wchar_t*.
|
|
|
|
Given this ambiguity it is mostly better to use wc_str(), mb_str() or
|
|
|
|
utf8_str() instead.
|
2008-05-04 21:03:50 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
Please see the @ref overview_unicode for more information about it.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
Note that the returned value is not convertible to @c char* or
|
|
|
|
@c wchar_t*, use char_str() or wchar_str() if you need to pass
|
|
|
|
string value to a function expecting non-const pointer.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@see wc_str(), utf8_str(), c_str(), mb_str(), fn_str()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxCStrData c_str() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns an object with string data that is implicitly convertible to
|
|
|
|
@c char* pointer. Note that any change to the returned buffer is lost and so
|
|
|
|
this function is only usable for passing strings to legacy libraries that
|
|
|
|
don't have const-correct API. Use wxStringBuffer if you want to modify
|
|
|
|
the string.
|
|
|
|
|
|
|
|
@see c_str()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxWritableCharBuffer char_str(const wxMBConv& conv = wxConvLibc) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns buffer of the specified type containing the string data.
|
2008-07-19 19:59:59 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This method is only useful in template code, otherwise you should
|
|
|
|
directly call mb_str() or wc_str() if you need to retrieve a narrow or
|
|
|
|
wide string from this wxString. The template parameter @a t should be
|
|
|
|
either @c char or @c wchar_t.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
Notice that retrieving a char buffer in UTF-8 build will return the
|
|
|
|
internal string representation in UTF-8 while in wchar_t build the char
|
|
|
|
buffer will contain the conversion of the string to the encoding of the
|
|
|
|
current locale (and so can fail).
|
2008-07-19 19:59:59 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@param len
|
|
|
|
If non-@NULL, filled with the length of the returned buffer.
|
2008-07-19 19:59:59 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@return
|
|
|
|
buffer containing the string contents in the specified type,
|
|
|
|
notice that it may be @NULL if the conversion failed (e.g. Unicode
|
|
|
|
string couldn't be converted to the current encoding when @a T is
|
|
|
|
@c char).
|
|
|
|
*/
|
|
|
|
template <typename T>
|
|
|
|
wxCharTypeBuffer<T> tchar_str(size_t *len = NULL) const;
|
2008-07-19 19:59:59 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns a string representation suitable for passing to OS' functions
|
|
|
|
for file handling.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
const wchar_t* fn_str() const;
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
@overload
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
const char* fn_str() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
@overload
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
const wxCharBuffer fn_str() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns the multibyte (C string) representation of the string
|
|
|
|
using @e conv's wxMBConv::cWC2MB method and returns wxCharBuffer.
|
|
|
|
|
|
|
|
@see wc_str(), utf8_str(), c_str(), wxMBConv
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
const wxCharBuffer mb_str(const wxMBConv& conv = wxConvLibc) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Converts the strings contents to UTF-8 and returns it either as a
|
|
|
|
temporary wxCharBuffer object or as a pointer to the internal
|
|
|
|
string contents in UTF-8 build.
|
2009-01-31 15:57:45 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@see wc_str(), c_str(), mb_str()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-30 18:28:42 +00:00
|
|
|
const wxScopedCharBuffer utf8_str() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2011-03-22 14:08:30 +00:00
|
|
|
Converts the strings contents to the wide character representation
|
2009-03-19 14:51:46 +00:00
|
|
|
and returns it as a temporary wxWCharBuffer object (Unix and OS X)
|
|
|
|
or returns a pointer to the internal string contents in wide character
|
|
|
|
mode (Windows).
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
The macro wxWX2WCbuf is defined as the correct return type (without const).
|
|
|
|
|
|
|
|
@see utf8_str(), c_str(), mb_str(), fn_str(), wchar_str()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
const wchar_t* wc_str() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
@overload
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
const wxWCharBuffer wc_str() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns an object with string data that is implicitly convertible to
|
|
|
|
@c char* pointer. Note that changes to the returned buffer may or may
|
|
|
|
not be lost (depending on the build) and so this function is only usable for
|
|
|
|
passing strings to legacy libraries that don't have const-correct API. Use
|
|
|
|
wxStringBuffer if you want to modify the string.
|
|
|
|
|
|
|
|
@see mb_str(), wc_str(), fn_str(), c_str(), char_str()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxWritableWCharBuffer wchar_str() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Explicit conversion to C string in the internal representation (either
|
|
|
|
wchar_t* or UTF-8-encoded char*, depending on the build).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
const wxStringCharType *wx_str() const;
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Converts the string to an 8-bit string in ISO-8859-1 encoding in the
|
|
|
|
form of a wxCharBuffer (Unicode builds only).
|
|
|
|
|
|
|
|
This is a convenience method useful when storing binary data in
|
|
|
|
wxString. It should be used @em only for this purpose. It is only valid
|
|
|
|
to call this method on strings created using From8BitData().
|
|
|
|
|
|
|
|
@since 2.8.4
|
|
|
|
|
|
|
|
@see wxString::From8BitData()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2010-07-01 15:28:30 +00:00
|
|
|
const wxScopedCharBuffer To8BitData() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Converts the string to an ASCII, 7-bit string in the form of
|
|
|
|
a wxCharBuffer (Unicode builds only) or a C string (ANSI builds).
|
|
|
|
Note that this conversion only works if the string contains only ASCII
|
|
|
|
characters. The @ref mb_str() "mb_str" method provides more
|
|
|
|
powerful means of converting wxString to C string.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
const char* ToAscii() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
@overload
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
const wxCharBuffer ToAscii() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2010-04-11 11:08:49 +00:00
|
|
|
/**
|
|
|
|
Return the string as an std::string in current locale encoding.
|
|
|
|
|
|
|
|
Note that if the conversion of (Unicode) string contents to the current
|
|
|
|
locale fails, the return string will be empty. Be sure to check for
|
|
|
|
this to avoid silent data loss.
|
|
|
|
|
|
|
|
Instead of using this function it's also possible to write
|
|
|
|
@code
|
|
|
|
std::string s;
|
|
|
|
wxString wxs;
|
|
|
|
...
|
|
|
|
s = std::string(wxs);
|
|
|
|
@endcode
|
|
|
|
but using ToStdString() may make the code more clear.
|
|
|
|
|
|
|
|
@since 2.9.1
|
|
|
|
*/
|
|
|
|
std::string ToStdString() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Return the string as an std::wstring.
|
|
|
|
|
|
|
|
Unlike ToStdString(), there is no danger of data loss when using this
|
|
|
|
function.
|
|
|
|
|
|
|
|
@since 2.9.1
|
|
|
|
*/
|
|
|
|
std::wstring ToStdWstring() const;
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Same as utf8_str().
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-30 18:28:42 +00:00
|
|
|
const wxScopedCharBuffer ToUTF8() const;
|
2008-08-01 23:39:11 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
//@}
|
2008-08-01 23:39:11 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
@member_group_name{concat, Concatenation}
|
2008-08-01 23:39:11 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
Almost anything may be concatenated (appended to) with a string!
|
2009-04-21 00:05:06 +00:00
|
|
|
|
|
|
|
Note that the various operator<<() overloads work as C++ stream insertion
|
|
|
|
operators. They insert the given value into the string.
|
2009-03-19 14:51:46 +00:00
|
|
|
Precision and format cannot be set using them. Use Printf() instead.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
See also the insert() and append() STL-like functions.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
//@{
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Appends the string literal @a psz.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString& Append(const char* psz);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Appends the wide string literal @a pwz.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString& Append(const wchar_t* pwz);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Appends the string literal @a psz with max length @a nLen.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString& Append(const char* psz, size_t nLen);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Appends the wide string literal @a psz with max length @a nLen.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString& Append(const wchar_t* pwz, size_t nLen);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Appends the string @a s.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString& Append(const wxString& s);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Appends the character @a ch @a count times.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString &Append(wxUniChar ch, size_t count = 1u);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Prepends @a str to this string, returning a reference to this string.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString& Prepend(const wxString& str);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Concatenation: returns a new string equal to the concatenation of the operands.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString operator +(const wxString& x, const wxString& y);
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
@overload
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString operator +(const wxString& x, wxUniChar y);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString& operator<<(const wxString& s);
|
|
|
|
wxString& operator<<(const char* psz);
|
|
|
|
wxString& operator<<(const wchar_t* pwz);
|
|
|
|
wxString& operator<<(const wxCStrData& psz);
|
|
|
|
wxString& operator<<(char ch);
|
|
|
|
wxString& operator<<(unsigned char ch);
|
|
|
|
wxString& operator<<(wchar_t ch);
|
|
|
|
wxString& operator<<(const wxCharBuffer& s);
|
|
|
|
wxString& operator<<(const wxWCharBuffer& s);
|
2009-12-27 19:40:08 +00:00
|
|
|
wxString& operator<<(wxUniChar ch);
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString& operator<<(wxUniCharRef ch);
|
|
|
|
wxString& operator<<(unsigned int ui);
|
|
|
|
wxString& operator<<(long l);
|
|
|
|
wxString& operator<<(unsigned long ul);
|
|
|
|
wxString& operator<<(wxLongLong_t ll);
|
|
|
|
wxString& operator<<(wxULongLong_t ul);
|
|
|
|
wxString& operator<<(float f);
|
|
|
|
wxString& operator<<(double d);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Concatenation in place: the argument is appended to the string.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
void operator +=(const wxString& str);
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
/**
|
|
|
|
@overload
|
|
|
|
*/
|
|
|
|
void operator +=(wxUniChar c);
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
//@}
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
@member_group_name{cmp, Comparison}
|
|
|
|
|
|
|
|
The default comparison function Cmp() is case-sensitive and so is the default
|
|
|
|
version of IsSameAs(). For case insensitive comparisons you should use CmpNoCase()
|
|
|
|
or give a second parameter to IsSameAs(). This last function is maybe more
|
|
|
|
convenient if only equality of the strings matters because it returns a boolean
|
|
|
|
@true value if the strings are the same and not 0 (which is usually @false
|
|
|
|
in C) as Cmp() does.
|
|
|
|
|
|
|
|
Matches() is a poor man's regular expression matcher: it only understands
|
|
|
|
'*' and '?' metacharacters in the sense of DOS command line interpreter.
|
|
|
|
|
|
|
|
StartsWith() is helpful when parsing a line of text which should start
|
|
|
|
with some predefined prefix and is more efficient than doing direct string
|
|
|
|
comparison as you would also have to precalculate the length of the prefix.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
See also the compare() STL-like function.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
//@{
|
|
|
|
|
|
|
|
/**
|
|
|
|
Case-sensitive comparison.
|
|
|
|
Returns a positive value if the string is greater than the argument,
|
|
|
|
zero if it is equal to it or a negative value if it is less than the
|
|
|
|
argument (same semantics as the standard @c strcmp() function).
|
|
|
|
|
|
|
|
@see CmpNoCase(), IsSameAs().
|
|
|
|
*/
|
|
|
|
int Cmp(const wxString& s) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Case-insensitive comparison.
|
|
|
|
Returns a positive value if the string is greater than the argument,
|
|
|
|
zero if it is equal to it or a negative value if it is less than the
|
|
|
|
argument (same semantics as the standard @c strcmp() function).
|
|
|
|
|
|
|
|
@see Cmp(), IsSameAs().
|
|
|
|
*/
|
|
|
|
int CmpNoCase(const wxString& s) const;
|
|
|
|
|
|
|
|
/**
|
2009-04-21 00:05:06 +00:00
|
|
|
Test whether the string is equal to another string @a s.
|
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
The test is case-sensitive if @a caseSensitive is @true (default) or not if it is
|
|
|
|
@false.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
|
|
|
@return @true if the string is equal to the other one, @false otherwise.
|
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@see Cmp(), CmpNoCase()
|
|
|
|
*/
|
2009-04-21 00:05:06 +00:00
|
|
|
bool IsSameAs(const wxString& s, bool caseSensitive = true) const;
|
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
/**
|
2009-04-21 00:05:06 +00:00
|
|
|
Test whether the string is equal to the single character @a ch.
|
|
|
|
|
|
|
|
The test is case-sensitive if @a caseSensitive is @true (default) or not if it is
|
|
|
|
@false.
|
|
|
|
|
|
|
|
@return @true if the string is equal to this character, @false otherwise.
|
|
|
|
|
|
|
|
@see Cmp(), CmpNoCase()
|
2009-03-19 14:51:46 +00:00
|
|
|
*/
|
|
|
|
bool IsSameAs(wxUniChar ch, bool caseSensitive = true) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the string contents matches a mask containing '*' and '?'.
|
|
|
|
*/
|
|
|
|
bool Matches(const wxString& mask) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
This function can be used to test if the string starts with the specified
|
2009-04-21 00:05:06 +00:00
|
|
|
@a prefix.
|
|
|
|
|
|
|
|
If it does, the function will return @true and put the rest of the string
|
2009-03-19 14:51:46 +00:00
|
|
|
(i.e. after the prefix) into @a rest string if it is not @NULL.
|
|
|
|
Otherwise, the function returns @false and doesn't modify the @a rest.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-05-26 11:17:08 +00:00
|
|
|
bool StartsWith(const wxString& prefix, wxString *rest = NULL) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
This function can be used to test if the string ends with the specified
|
|
|
|
@e suffix. If it does, the function will return @true and put the
|
|
|
|
beginning of the string before the suffix into @e rest string if it is not
|
|
|
|
@NULL. Otherwise, the function returns @false and doesn't
|
|
|
|
modify the @e rest.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
bool EndsWith(const wxString& suffix, wxString *rest = NULL) const;
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
//@}
|
2009-04-21 00:05:06 +00:00
|
|
|
|
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
/**
|
|
|
|
@member_group_name{substring, Substring extraction}
|
|
|
|
|
|
|
|
These functions allow you to extract a substring from the string. The
|
|
|
|
original string is not modified and the function returns the extracted
|
|
|
|
substring.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
See also the at() and the substr() STL-like functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a substring starting at @e first, with length @e count, or the rest of
|
|
|
|
the string if @a count is the default value.
|
|
|
|
*/
|
|
|
|
wxString Mid(size_t first, size_t nCount = wxString::npos) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns the part of the string between the indices @a from and @a to
|
2008-03-08 13:52:38 +00:00
|
|
|
inclusive.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
This is a wxWidgets 1.xx compatibility function, use Mid()
|
|
|
|
instead (but note that parameters have different meaning).
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString SubString(size_t from, size_t to) const;
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
/**
|
|
|
|
Same as Mid() (substring extraction).
|
|
|
|
*/
|
|
|
|
wxString operator()(size_t start, size_t len) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the first @a count characters of the string.
|
|
|
|
*/
|
|
|
|
wxString Left(size_t count) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the last @a count characters.
|
|
|
|
*/
|
|
|
|
wxString Right(size_t count) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Gets all the characters after the first occurrence of @e ch.
|
|
|
|
Returns the empty string if @e ch is not found.
|
|
|
|
*/
|
|
|
|
wxString AfterFirst(wxUniChar ch) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Gets all the characters after the last occurrence of @e ch.
|
|
|
|
Returns the whole string if @e ch is not found.
|
|
|
|
*/
|
|
|
|
wxString AfterLast(wxUniChar ch) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Gets all characters before the first occurrence of @e ch.
|
|
|
|
Returns the whole string if @a ch is not found.
|
2010-10-22 14:17:37 +00:00
|
|
|
|
|
|
|
@param ch The character to look for.
|
|
|
|
@param rest Filled with the part of the string following the first
|
|
|
|
occurrence of @a ch or cleared if it was not found. The same string
|
|
|
|
is returned by AfterFirst() but it is more efficient to use this
|
|
|
|
output parameter if both the "before" and "after" parts are needed
|
|
|
|
than calling both functions one after the other. This parameter is
|
|
|
|
available in wxWidgets version 2.9.2 and later only.
|
|
|
|
@return Part of the string before the first occurrence of @a ch.
|
2009-03-19 14:51:46 +00:00
|
|
|
*/
|
2010-10-22 14:17:37 +00:00
|
|
|
wxString BeforeFirst(wxUniChar ch, wxString *rest = NULL) const;
|
2009-03-19 14:51:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets all characters before the last occurrence of @e ch.
|
|
|
|
Returns the empty string if @a ch is not found.
|
2010-10-22 14:17:37 +00:00
|
|
|
|
|
|
|
@param ch The character to look for.
|
|
|
|
@param rest Filled with the part of the string following the last
|
|
|
|
occurrence of @a ch or the copy of this string if it was not found.
|
|
|
|
The same string is returned by AfterLast() but it is more efficient
|
|
|
|
to use this output parameter if both the "before" and "after" parts
|
|
|
|
are needed than calling both functions one after the other. This
|
|
|
|
parameter is available in wxWidgets version 2.9.2 and later only.
|
|
|
|
@return Part of the string before the last occurrence of @a ch.
|
2009-03-19 14:51:46 +00:00
|
|
|
*/
|
2010-10-22 14:17:37 +00:00
|
|
|
wxString BeforeLast(wxUniChar ch, wxString *rest = NULL) const;
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
//@}
|
2009-04-21 00:05:06 +00:00
|
|
|
|
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
/**
|
|
|
|
@member_group_name{caseconv, Case conversion}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
The MakeXXX() variants modify the string in place, while the other functions
|
|
|
|
return a new string which contains the original text converted to the upper or
|
|
|
|
lower case and leave the original string unchanged.
|
|
|
|
*/
|
2008-03-08 13:52:38 +00:00
|
|
|
//@{
|
2009-03-19 14:51:46 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Return the copy of the string with the first string character in the
|
|
|
|
upper case and the subsequent ones in the lower case.
|
2008-05-04 21:03:50 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@since 2.9.0
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@see MakeCapitalized()
|
|
|
|
*/
|
|
|
|
wxString Capitalize() const;
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
/**
|
|
|
|
Returns this string converted to the lower case.
|
|
|
|
|
|
|
|
@see MakeLower()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString Lower() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Same as MakeLower.
|
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
|
|
|
*/
|
|
|
|
void LowerCase();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Converts the first characters of the string to the upper case and all
|
|
|
|
the subsequent ones to the lower case and returns the result.
|
|
|
|
|
|
|
|
@since 2.9.0
|
|
|
|
|
|
|
|
@see Capitalize()
|
|
|
|
*/
|
|
|
|
wxString& MakeCapitalized();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Converts all characters to lower case and returns the reference to the
|
|
|
|
modified string.
|
|
|
|
|
|
|
|
@see Lower()
|
|
|
|
*/
|
|
|
|
wxString& MakeLower();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Converts all characters to upper case and returns the reference to the
|
|
|
|
modified string.
|
|
|
|
|
|
|
|
@see Upper()
|
|
|
|
*/
|
|
|
|
wxString& MakeUpper();
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
/**
|
|
|
|
Returns this string converted to upper case.
|
|
|
|
|
|
|
|
@see MakeUpper()
|
|
|
|
*/
|
|
|
|
wxString Upper() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The same as MakeUpper().
|
|
|
|
|
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
|
|
|
*/
|
|
|
|
void UpperCase();
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
2009-04-21 00:05:06 +00:00
|
|
|
|
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
/**
|
|
|
|
@member_group_name{search, Searching and replacing}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
These functions replace the standard @c strchr() and @c strstr()
|
|
|
|
functions.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
See also the find(), rfind(), replace() STL-like functions.
|
|
|
|
*/
|
2008-03-08 13:52:38 +00:00
|
|
|
//@{
|
2009-03-19 14:51:46 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-04-21 00:05:06 +00:00
|
|
|
Searches for the given character @a ch.
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns the position or @c wxNOT_FOUND if not found.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
int Find(wxUniChar ch, bool fromEnd = false) const;
|
|
|
|
|
|
|
|
/**
|
2009-04-21 00:05:06 +00:00
|
|
|
Searches for the given string @a sub.
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns the starting position or @c wxNOT_FOUND if not found.
|
|
|
|
*/
|
|
|
|
int Find(const wxString& sub) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Same as Find().
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This is a wxWidgets 1.xx compatibility function;
|
|
|
|
you should not use it in new code.
|
|
|
|
*/
|
|
|
|
int First(wxUniChar ch) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Same as Find().
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This is a wxWidgets 1.xx compatibility function;
|
|
|
|
you should not use it in new code.
|
|
|
|
*/
|
|
|
|
int First(const wxString& str) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Replace first (or all) occurrences of substring with another one.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@param strOld
|
|
|
|
The string to search for replacing.
|
|
|
|
@param strNew
|
|
|
|
The substitution string.
|
|
|
|
@param replaceAll
|
2009-04-21 00:05:06 +00:00
|
|
|
If @true a global replace will be done (default), otherwise only the
|
2009-03-19 14:51:46 +00:00
|
|
|
first occurrence will be replaced.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns the number of replacements made.
|
|
|
|
*/
|
|
|
|
size_t Replace(const wxString& strOld, const wxString& strNew,
|
|
|
|
bool replaceAll = true);
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@member_group_name{numconv, Conversion to numbers}
|
|
|
|
|
|
|
|
The string provides functions for conversion to signed and unsigned integer and
|
2009-08-30 17:25:19 +00:00
|
|
|
floating point numbers.
|
|
|
|
|
|
|
|
All functions take a pointer to the variable to put the numeric value
|
|
|
|
in and return @true if the @b entire string could be converted to a
|
|
|
|
number. Notice if there is a valid number in the beginning of the
|
|
|
|
string, it is returned in the output parameter even if the function
|
|
|
|
returns @false because there is more text following it.
|
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
//@{
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-04-21 00:05:06 +00:00
|
|
|
Attempts to convert the string to a floating point number.
|
|
|
|
|
|
|
|
Returns @true on success (the number is stored in the location pointed to by
|
|
|
|
@a val) or @false if the string does not represent such number (the value of
|
2009-08-30 17:25:19 +00:00
|
|
|
@a val may still be modified in this case).
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-20 14:50:06 +00:00
|
|
|
Note that unlike ToCDouble() this function uses a localized version of
|
|
|
|
@c wxStrtod() and thus needs as decimal point (and thousands separator) the
|
|
|
|
locale-specific decimal point. Thus you should use this function only when
|
|
|
|
you are sure that this string contains a floating point number formatted with
|
|
|
|
the rules of the locale currently in use (see wxLocale).
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2011-01-19 10:47:40 +00:00
|
|
|
Also notice that even this function is locale-specific it does not
|
|
|
|
support strings with thousands separators in them, even if the current
|
|
|
|
locale uses digits grouping. You may use wxNumberFormatter::FromString()
|
|
|
|
to parse such strings.
|
|
|
|
|
|
|
|
Please refer to the documentation of the standard function @c strtod()
|
|
|
|
for more details about the supported syntax.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2009-03-20 14:50:06 +00:00
|
|
|
@see ToCDouble(), ToLong(), ToULong()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-10-29 15:34:31 +00:00
|
|
|
bool ToDouble(double* val) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-08-30 17:25:19 +00:00
|
|
|
Variant of ToDouble() always working in "C" locale.
|
|
|
|
|
2009-03-20 14:50:06 +00:00
|
|
|
Works like ToDouble() but unlike it this function expects the floating point
|
|
|
|
number to be formatted always with the rules dictated by the "C" locale
|
|
|
|
(in particular, the decimal point must be a dot), independently from the
|
|
|
|
current application-wide locale (see wxLocale).
|
|
|
|
|
|
|
|
@see ToDouble(), ToLong(), ToULong()
|
|
|
|
*/
|
|
|
|
bool ToCDouble(double* val) const;
|
|
|
|
|
|
|
|
/**
|
2009-04-21 00:05:06 +00:00
|
|
|
Attempts to convert the string to a signed integer in base @a base.
|
|
|
|
|
2009-03-20 14:50:06 +00:00
|
|
|
Returns @true on success in which case the number is stored in the location
|
2008-03-09 12:33:59 +00:00
|
|
|
pointed to by @a val or @false if the string does not represent a
|
2009-08-30 17:25:19 +00:00
|
|
|
valid number in the given base (the value of @a val may still be
|
|
|
|
modified in this case).
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
The value of @a base must be comprised between 2 and 36, inclusive, or
|
2008-03-08 13:52:38 +00:00
|
|
|
be a special value 0 which means that the usual rules of @c C numbers are
|
|
|
|
applied: if the number starts with @c 0x it is considered to be in base
|
|
|
|
16, if it starts with @c 0 - in base 8 and in base 10 otherwise. Note
|
|
|
|
that you may not want to specify the base 0 if you are parsing the numbers
|
|
|
|
which may have leading zeroes as they can yield unexpected (to the user not
|
|
|
|
familiar with C) results.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-20 14:50:06 +00:00
|
|
|
Note that unlike ToCLong() this function uses a localized version of
|
2009-04-21 00:05:06 +00:00
|
|
|
@c wxStrtol(). Thus you should use this function only when you are sure
|
2009-03-20 14:50:06 +00:00
|
|
|
that this string contains an integer number formatted with
|
|
|
|
the rules of the locale currently in use (see wxLocale).
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2011-01-19 10:47:40 +00:00
|
|
|
As with ToDouble(), this function does not support strings containing
|
|
|
|
thousands separators even if the current locale uses digits grouping.
|
|
|
|
You may use wxNumberFormatter::FromString() to parse such strings.
|
|
|
|
|
|
|
|
Please refer to the documentation of the standard function @c strtol()
|
|
|
|
for more details about the supported syntax.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2009-03-20 14:50:06 +00:00
|
|
|
@see ToCDouble(), ToDouble(), ToULong()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-10-29 15:34:31 +00:00
|
|
|
bool ToLong(long* val, int base = 10) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-08-30 17:25:19 +00:00
|
|
|
Variant of ToLong() always working in "C" locale.
|
|
|
|
|
2009-03-20 14:50:06 +00:00
|
|
|
Works like ToLong() but unlike it this function expects the integer
|
2009-04-21 00:05:06 +00:00
|
|
|
number to be formatted always with the rules dictated by the "C" locale,
|
2009-03-20 14:50:06 +00:00
|
|
|
independently from the current application-wide locale (see wxLocale).
|
|
|
|
|
|
|
|
@see ToDouble(), ToLong(), ToULong()
|
|
|
|
*/
|
|
|
|
bool ToCLong(long* val, int base = 10) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
This is exactly the same as ToLong() but works with 64 bit integer numbers.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Notice that currently it doesn't work (always returns @false) if parsing of 64
|
|
|
|
bit numbers is not supported by the underlying C run-time library. Compilers
|
|
|
|
with C99 support and Microsoft Visual C++ version 7 and higher do support this.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see ToLong(), ToULongLong()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-10-29 15:34:31 +00:00
|
|
|
bool ToLongLong(wxLongLong_t* val, int base = 10) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-20 14:50:06 +00:00
|
|
|
Attempts to convert the string to an unsigned integer in base @a base.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Returns @true on success in which case the number is stored in the
|
2008-03-09 12:33:59 +00:00
|
|
|
location pointed to by @a val or @false if the string does not
|
2009-08-30 17:25:19 +00:00
|
|
|
represent a valid number in the given base (the value of @a val may
|
|
|
|
still be modified in this case).
|
2008-10-07 16:57:34 +00:00
|
|
|
|
|
|
|
Please notice that this function behaves in the same way as the standard
|
|
|
|
@c strtoul() and so it simply converts negative numbers to unsigned
|
|
|
|
representation instead of rejecting them (e.g. -1 is returned as @c ULONG_MAX).
|
|
|
|
|
2009-03-20 14:50:06 +00:00
|
|
|
See ToLong() for the more detailed description of the @a base parameter
|
|
|
|
(and of the locale-specific behaviour of this function).
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2009-03-20 14:50:06 +00:00
|
|
|
@see ToCULong(), ToDouble(), ToLong()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-10-29 15:34:31 +00:00
|
|
|
bool ToULong(unsigned long* val, int base = 10) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2009-03-20 14:50:06 +00:00
|
|
|
/**
|
2009-08-30 17:25:19 +00:00
|
|
|
Variant of ToULong() always working in "C" locale.
|
|
|
|
|
2009-03-20 14:50:06 +00:00
|
|
|
Works like ToULong() but unlike it this function expects the integer
|
2009-04-21 00:05:06 +00:00
|
|
|
number to be formatted always with the rules dictated by the "C" locale,
|
2009-03-20 14:50:06 +00:00
|
|
|
independently from the current application-wide locale (see wxLocale).
|
|
|
|
|
|
|
|
@see ToDouble(), ToLong(), ToULong()
|
|
|
|
*/
|
|
|
|
bool ToCULong(unsigned long* val, int base = 10) const;
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-08-30 17:25:19 +00:00
|
|
|
This is exactly the same as ToULong() but works with 64 bit integer
|
|
|
|
numbers.
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Please see ToLongLong() for additional remarks.
|
|
|
|
*/
|
2008-10-29 15:34:31 +00:00
|
|
|
bool ToULongLong(wxULongLong_t* val, int base = 10) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
@member_group_name{fmt, Formatting and printing}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
Both formatted versions (Printf/() and stream-like insertion operators
|
2009-04-21 00:05:06 +00:00
|
|
|
exist (for basic types only).
|
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
See also the static Format() and FormatV() functions.
|
|
|
|
*/
|
2008-03-08 13:52:38 +00:00
|
|
|
//@{
|
2008-10-07 16:57:34 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
/**
|
|
|
|
Similar to the standard function @e sprintf(). Returns the number of
|
|
|
|
characters written, or an integer less than zero on error.
|
|
|
|
Note that if @c wxUSE_PRINTF_POS_PARAMS is set to 1, then this function supports
|
|
|
|
Unix98-style positional parameters:
|
2008-10-07 16:57:34 +00:00
|
|
|
|
2010-05-12 08:18:17 +00:00
|
|
|
@code
|
|
|
|
wxString str;
|
|
|
|
|
|
|
|
str.Printf(wxT("%d %d %d"), 1, 2, 3);
|
|
|
|
// str now contains "1 2 3"
|
|
|
|
|
|
|
|
str.Printf(wxT("%2$d %3$d %1$d"), 1, 2, 3);
|
|
|
|
// str now contains "2 3 1"
|
|
|
|
@endcode
|
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@note This function will use a safe version of @e vsprintf() (usually called
|
|
|
|
@e vsnprintf()) whenever available to always allocate the buffer of correct
|
|
|
|
size. Unfortunately, this function is not available on all platforms and the
|
|
|
|
dangerous @e vsprintf() will be used then which may lead to buffer overflows.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
int Printf(const wxString& pszFormat, ...);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Similar to vprintf. Returns the number of characters written, or an integer
|
|
|
|
less than zero
|
|
|
|
on error.
|
|
|
|
*/
|
|
|
|
int PrintfV(const wxString& pszFormat, va_list argPtr);
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
2009-04-21 00:05:06 +00:00
|
|
|
|
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
/**
|
|
|
|
@member_group_name{mem, Memory management}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2009-04-21 00:05:06 +00:00
|
|
|
The following are "advanced" functions and they will be needed rarely.
|
|
|
|
Alloc() and Shrink() are only interesting for optimization purposes.
|
|
|
|
wxStringBuffer and wxStringBufferLength classes may be very useful when working
|
2009-03-19 14:51:46 +00:00
|
|
|
with some external API which requires the caller to provide a writable buffer.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
See also the reserve() and resize() STL-like functions.
|
|
|
|
*/
|
|
|
|
//@{
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Preallocate enough space for wxString to store @a nLen characters.
|
2008-08-01 23:39:11 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
Please note that this method does the same thing as the standard
|
|
|
|
reserve() one and shouldn't be used in new code.
|
|
|
|
|
|
|
|
This function may be used to increase speed when the string is
|
|
|
|
constructed by repeated concatenation as in
|
|
|
|
|
|
|
|
@code
|
|
|
|
// delete all vowels from the string
|
|
|
|
wxString DeleteAllVowels(const wxString& original)
|
|
|
|
{
|
|
|
|
wxString result;
|
|
|
|
|
|
|
|
size_t len = original.length();
|
|
|
|
|
|
|
|
result.Alloc(len);
|
|
|
|
|
|
|
|
for ( size_t n = 0; n < len; n++ )
|
|
|
|
{
|
|
|
|
if ( strchr("aeuio", tolower(original[n])) == NULL )
|
|
|
|
result += original[n];
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
because it will avoid the need to reallocate string memory many times
|
|
|
|
(in case of long strings). Note that it does not set the maximal length
|
|
|
|
of a string -- it will still expand if more than @a nLen characters are
|
|
|
|
stored in it. Also, it does not truncate the existing string (use
|
|
|
|
Truncate() for this) even if its current length is greater than @a nLen.
|
|
|
|
|
|
|
|
@return @true if memory was successfully allocated, @false otherwise.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
bool Alloc(size_t nLen);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Minimizes the string's memory. This can be useful after a call to
|
|
|
|
Alloc() if too much memory were preallocated.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
bool Shrink();
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns a deep copy of the string.
|
2008-08-01 23:39:11 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
That is, the returned string is guaranteed to not share data with this
|
|
|
|
string when using reference-counted wxString implementation.
|
2008-08-01 23:39:11 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This method is primarily useful for passing strings between threads
|
|
|
|
(because wxString is not thread-safe). Unlike creating a copy using
|
|
|
|
@c wxString(c_str()), Clone() handles embedded NULs correctly.
|
2008-08-01 23:39:11 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@since 2.9.0
|
|
|
|
*/
|
|
|
|
wxString Clone() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Empties the string and frees memory occupied by it.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@see Empty()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
void Clear();
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
@member_group_name{misc, Miscellaneous}
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
Miscellaneous other string functions.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
//@{
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-06-06 21:19:23 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns @true if target appears anywhere in wxString; else @false.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
|
|
|
|
*/
|
|
|
|
bool Contains(const wxString& str) const;
|
2008-06-06 21:19:23 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
/**
|
|
|
|
Makes the string empty, but doesn't free memory occupied by the string.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@see Clear().
|
|
|
|
*/
|
|
|
|
void Empty();
|
2008-06-06 21:19:23 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
/**
|
|
|
|
Returns the number of occurrences of @e ch in the string.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
|
|
|
|
*/
|
|
|
|
int Freq(wxUniChar ch) const;
|
2008-06-06 21:19:23 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
/**
|
|
|
|
Returns @true if the string contains only ASCII characters.
|
|
|
|
See wxUniChar::IsAscii for more details.
|
2008-10-07 16:57:34 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
|
|
|
*/
|
|
|
|
bool IsAscii() const;
|
2008-06-06 21:19:23 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns @true if the string is an integer (with possible sign).
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
bool IsNumber() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Returns @true if the string is a word.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
|
|
|
|
*/
|
|
|
|
bool IsWord() const;
|
2008-08-01 23:39:11 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
/**
|
|
|
|
Adds @a count copies of @a chPad to the beginning, or to the end of the
|
|
|
|
string (the default).
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
Removes spaces from the left or from the right (default).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString& Pad(size_t count, wxUniChar chPad = ' ', bool fromRight = true);
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
/**
|
|
|
|
Removes all characters from the string starting at @a pos.
|
|
|
|
Use Truncate() as a more readable alternative.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
|
|
|
|
*/
|
|
|
|
wxString& Remove(size_t pos);
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
/**
|
|
|
|
Removes @a len characters from the string, starting at @a pos.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
|
|
|
|
*/
|
|
|
|
wxString& Remove(size_t pos, size_t len);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Removes the last character.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString& RemoveLast(size_t n = 1);
|
2008-07-06 18:34:50 +00:00
|
|
|
|
|
|
|
/**
|
2009-04-21 00:05:06 +00:00
|
|
|
Strip characters at the front and/or end.
|
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This is the same as Trim() except that it doesn't change this string.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
|
2008-07-06 18:34:50 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString Strip(stripType s = trailing) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Removes white-space (space, tabs, form feed, newline and carriage return) from
|
|
|
|
the left or from the right end of the string (right is default).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString& Trim(bool fromRight = true);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Truncate the string to the given length.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString& Truncate(size_t len);
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
@member_group_name{iter, Iterator interface}
|
|
|
|
|
2011-03-22 14:08:30 +00:00
|
|
|
These methods return iterators to the beginning or end of the string.
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
Please see any STL reference (e.g. http://www.cppreference.com/wiki/string/start)
|
|
|
|
for their documentation.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
//@{
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
const_iterator begin() const;
|
|
|
|
iterator begin();
|
|
|
|
const_iterator end() const;
|
|
|
|
iterator end();
|
|
|
|
|
|
|
|
const_reverse_iterator rbegin() const;
|
|
|
|
reverse_iterator rbegin();
|
|
|
|
const_reverse_iterator rend() const;
|
|
|
|
reverse_iterator rend();
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
@member_group_name{stl, STL interface}
|
|
|
|
|
2009-04-21 00:05:06 +00:00
|
|
|
The supported STL functions are listed here.
|
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
Please see any STL reference (e.g. http://www.cppreference.com/wiki/string/start)
|
|
|
|
for their documentation.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
//@{
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
wxString& append(const wxString& str, size_t pos, size_t n);
|
|
|
|
wxString& append(const wxString& str);
|
|
|
|
wxString& append(const char *sz, size_t n);
|
|
|
|
wxString& append(const wchar_t *sz, size_t n);
|
|
|
|
wxString& append(size_t n, wxUniChar ch);
|
|
|
|
wxString& append(const_iterator first, const_iterator last);
|
|
|
|
|
|
|
|
wxString& assign(const wxString& str, size_t pos, size_t n);
|
|
|
|
wxString& assign(const wxString& str);
|
|
|
|
wxString& assign(const char *sz, size_t n);
|
|
|
|
wxString& assign(const wchar_t *sz, size_t n);
|
|
|
|
wxString& assign(size_t n, wxUniChar ch);
|
|
|
|
wxString& assign(const_iterator first, const_iterator last);
|
|
|
|
|
|
|
|
wxUniChar at(size_t n) const;
|
|
|
|
wxUniCharRef at(size_t n);
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
size_type capacity() const;
|
|
|
|
|
|
|
|
int compare(const wxString& str) const;
|
|
|
|
int compare(size_t nStart, size_t nLen, const wxString& str) const;
|
|
|
|
int compare(size_t nStart, size_t nLen,
|
|
|
|
const wxString& str, size_t nStart2, size_t nLen2) const;
|
|
|
|
int compare(size_t nStart, size_t nLen,
|
|
|
|
const char* sz, size_t nCount = npos) const;
|
|
|
|
int compare(size_t nStart, size_t nLen,
|
|
|
|
const wchar_t* sz, size_t nCount = npos) const;
|
|
|
|
|
|
|
|
wxCStrData data() const;
|
|
|
|
|
|
|
|
bool empty() const;
|
|
|
|
|
|
|
|
wxString& erase(size_type pos = 0, size_type n = npos);
|
|
|
|
iterator erase(iterator first, iterator last);
|
|
|
|
iterator erase(iterator first);
|
|
|
|
|
|
|
|
size_t find(const wxString& str, size_t nStart = 0) const;
|
|
|
|
size_t find(const char* sz, size_t nStart = 0, size_t n = npos) const;
|
|
|
|
size_t find(const wchar_t* sz, size_t nStart = 0, size_t n = npos) const;
|
|
|
|
size_t find(wxUniChar ch, size_t nStart = 0) const;
|
|
|
|
size_t find_first_of(const char* sz, size_t nStart = 0) const;
|
|
|
|
size_t find_first_of(const wchar_t* sz, size_t nStart = 0) const;
|
|
|
|
size_t find_first_of(const char* sz, size_t nStart, size_t n) const;
|
|
|
|
size_t find_first_of(const wchar_t* sz, size_t nStart, size_t n) const;
|
|
|
|
size_t find_first_of(wxUniChar c, size_t nStart = 0) const;
|
|
|
|
size_t find_last_of (const wxString& str, size_t nStart = npos) const;
|
|
|
|
size_t find_last_of (const char* sz, size_t nStart = npos) const;
|
|
|
|
size_t find_last_of (const wchar_t* sz, size_t nStart = npos) const;
|
|
|
|
size_t find_last_of(const char* sz, size_t nStart, size_t n) const;
|
|
|
|
size_t find_last_of(const wchar_t* sz, size_t nStart, size_t n) const;
|
|
|
|
size_t find_last_of(wxUniChar c, size_t nStart = npos) const;
|
|
|
|
size_t find_first_not_of(const wxString& str, size_t nStart = 0) const;
|
|
|
|
size_t find_first_not_of(const char* sz, size_t nStart = 0) const;
|
|
|
|
size_t find_first_not_of(const wchar_t* sz, size_t nStart = 0) const;
|
|
|
|
size_t find_first_not_of(const char* sz, size_t nStart, size_t n) const;
|
|
|
|
size_t find_first_not_of(const wchar_t* sz, size_t nStart, size_t n) const;
|
|
|
|
size_t find_first_not_of(wxUniChar ch, size_t nStart = 0) const;
|
|
|
|
size_t find_last_not_of(const wxString& str, size_t nStart = npos) const;
|
|
|
|
size_t find_last_not_of(const char* sz, size_t nStart = npos) const;
|
|
|
|
size_t find_last_not_of(const wchar_t* sz, size_t nStart = npos) const;
|
|
|
|
size_t find_last_not_of(const char* sz, size_t nStart, size_t n) const;
|
|
|
|
size_t find_last_not_of(const wchar_t* sz, size_t nStart, size_t n) const;
|
|
|
|
|
|
|
|
wxString& insert(size_t nPos, const wxString& str);
|
|
|
|
wxString& insert(size_t nPos, const wxString& str, size_t nStart, size_t n);
|
|
|
|
wxString& insert(size_t nPos, const char *sz, size_t n);
|
|
|
|
wxString& insert(size_t nPos, const wchar_t *sz, size_t n);
|
|
|
|
wxString& insert(size_t nPos, size_t n, wxUniChar ch);
|
|
|
|
iterator insert(iterator it, wxUniChar ch);
|
|
|
|
void insert(iterator it, const_iterator first, const_iterator last);
|
|
|
|
void insert(iterator it, size_type n, wxUniChar ch);
|
|
|
|
|
|
|
|
size_t length() const;
|
|
|
|
|
|
|
|
size_type max_size() const;
|
|
|
|
|
|
|
|
void reserve(size_t sz);
|
|
|
|
void resize(size_t nSize, wxUniChar ch = '\0');
|
|
|
|
|
|
|
|
wxString& replace(size_t nStart, size_t nLen, const wxString& str);
|
|
|
|
wxString& replace(size_t nStart, size_t nLen, size_t nCount, wxUniChar ch);
|
|
|
|
wxString& replace(size_t nStart, size_t nLen,
|
|
|
|
const wxString& str, size_t nStart2, size_t nLen2);
|
|
|
|
wxString& replace(size_t nStart, size_t nLen,
|
|
|
|
const char* sz, size_t nCount);
|
|
|
|
wxString& replace(size_t nStart, size_t nLen,
|
|
|
|
const wchar_t* sz, size_t nCount);
|
|
|
|
wxString& replace(size_t nStart, size_t nLen,
|
|
|
|
const wxString& s, size_t nCount);
|
|
|
|
wxString& replace(iterator first, iterator last, const wxString& s);
|
|
|
|
wxString& replace(iterator first, iterator last, const char* s, size_type n);
|
|
|
|
wxString& replace(iterator first, iterator last, const wchar_t* s, size_type n);
|
|
|
|
wxString& replace(iterator first, iterator last, size_type n, wxUniChar ch);
|
|
|
|
wxString& replace(iterator first, iterator last,
|
|
|
|
const_iterator first1, const_iterator last1);
|
|
|
|
wxString& replace(iterator first, iterator last,
|
|
|
|
const char *first1, const char *last1);
|
|
|
|
wxString& replace(iterator first, iterator last,
|
|
|
|
const wchar_t *first1, const wchar_t *last1);
|
|
|
|
|
|
|
|
size_t rfind(const wxString& str, size_t nStart = npos) const;
|
|
|
|
size_t rfind(const char* sz, size_t nStart = npos, size_t n = npos) const;
|
|
|
|
size_t rfind(const wchar_t* sz, size_t nStart = npos, size_t n = npos) const;
|
|
|
|
size_t rfind(wxUniChar ch, size_t nStart = npos) const;
|
|
|
|
|
|
|
|
size_type size() const;
|
|
|
|
wxString substr(size_t nStart = 0, size_t nLen = npos) const;
|
|
|
|
void swap(wxString& str);
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
2009-04-21 00:05:06 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
// STATIC FUNCTIONS
|
2011-03-22 14:08:30 +00:00
|
|
|
// Keep these functions separated from the other groups or Doxygen gets confused
|
2009-03-19 14:51:46 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
An 'invalid' value for string index
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
static const size_t npos;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
This static function returns the string containing the result of calling
|
|
|
|
Printf() with the passed parameters on it.
|
2008-06-06 21:19:23 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@see FormatV(), Printf()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
static wxString Format(const wxString& format, ...);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
This static function returns the string containing the result of calling
|
|
|
|
PrintfV() with the passed parameters on it.
|
2008-08-01 23:39:11 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@see Format(), PrintfV()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
static wxString FormatV(const wxString& format, va_list argptr);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Converts given buffer of binary data from 8-bit string to wxString. In
|
|
|
|
Unicode build, the string is interpreted as being in ISO-8859-1
|
|
|
|
encoding. The version without @e len parameter takes NUL-terminated
|
|
|
|
data.
|
2008-06-06 21:19:23 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This is a convenience method useful when storing binary data in
|
|
|
|
wxString. It should be used @em only for that purpose and only in
|
|
|
|
conjunction with To8BitData(). Use mb_str() for conversion of character
|
|
|
|
data to known encoding.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@since 2.8.4
|
|
|
|
|
|
|
|
@see wxString::To8BitData()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
static wxString From8BitData(const char* buf, size_t len);
|
|
|
|
static wxString From8BitData(const char* buf);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
//@{
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Converts the string or character from an ASCII, 7-bit form
|
|
|
|
to the native wxString representation.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
static wxString FromAscii(const char* s);
|
|
|
|
static wxString FromAscii(const unsigned char* s);
|
|
|
|
static wxString FromAscii(const char* s, size_t len);
|
|
|
|
static wxString FromAscii(const unsigned char* s, size_t len);
|
|
|
|
static wxString FromAscii(char c);
|
|
|
|
//@}
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2010-05-31 11:55:48 +00:00
|
|
|
/**
|
|
|
|
Returns a string with the textual representation of the number in C
|
|
|
|
locale.
|
|
|
|
|
|
|
|
Unlike FromDouble() the string returned by this function always uses
|
|
|
|
the period character as decimal separator, independently of the current
|
2011-03-13 13:53:54 +00:00
|
|
|
locale. Otherwise its behaviour is identical to the other function.
|
2010-05-31 11:55:48 +00:00
|
|
|
|
|
|
|
@since 2.9.1
|
|
|
|
|
|
|
|
@see ToCDouble()
|
|
|
|
*/
|
2011-03-13 13:53:54 +00:00
|
|
|
static wxString FromCDouble(double val, int precision = -1);
|
2010-05-31 11:55:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a string with the textual representation of the number.
|
|
|
|
|
2011-03-13 13:53:54 +00:00
|
|
|
For the default value of @a precision, this function behaves as a
|
|
|
|
simple wrapper for @code wxString::Format("%g", val) @endcode. If @a
|
|
|
|
precision is positive (or zero), the @c %.Nf format is used with the
|
|
|
|
given precision value.
|
2010-05-31 11:55:48 +00:00
|
|
|
|
|
|
|
Notice that the string returned by this function uses the decimal
|
|
|
|
separator appropriate for the current locale, e.g. @c "," and not a
|
|
|
|
period in French locale. Use FromCDouble() if this is unwanted.
|
|
|
|
|
2011-03-13 13:53:54 +00:00
|
|
|
@param val
|
|
|
|
The value to format.
|
|
|
|
@param precision
|
|
|
|
The number of fractional digits to use in or -1 to use the most
|
|
|
|
appropriate format. This parameter is new in wxWidgets 2.9.2.
|
|
|
|
|
2010-05-31 11:55:48 +00:00
|
|
|
@since 2.9.1
|
|
|
|
|
|
|
|
@see ToDouble()
|
|
|
|
*/
|
2011-03-13 13:53:54 +00:00
|
|
|
static wxString FromDouble(double val, int precision = -1);
|
2010-05-31 11:55:48 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
//@{
|
2008-08-01 23:39:11 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Converts C string encoded in UTF-8 to wxString.
|
2008-07-03 13:44:55 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
If @a s is not a valid UTF-8 string, an empty string is returned.
|
2008-07-03 13:44:55 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
Notice that when using UTF-8 wxWidgets build there is a more efficient
|
|
|
|
alternative to this function called FromUTF8Unchecked() which, unlike
|
|
|
|
this one, doesn't check that the input string is valid.
|
2008-06-06 21:19:23 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
@since 2.8.4
|
2008-05-06 10:42:50 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
static wxString FromUTF8(const char* s);
|
|
|
|
static wxString FromUTF8(const char* s, size_t len);
|
2008-05-06 12:51:35 +00:00
|
|
|
//@}
|
2008-05-06 10:42:50 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
//@{
|
2008-05-06 12:51:35 +00:00
|
|
|
/**
|
2009-03-19 14:51:46 +00:00
|
|
|
Converts C string encoded in UTF-8 to wxString without checking its
|
|
|
|
validity.
|
2008-06-06 21:19:23 +00:00
|
|
|
|
2009-03-19 14:51:46 +00:00
|
|
|
This method assumes that @a s is a valid UTF-8 sequence and doesn't do
|
|
|
|
any validation (although an assert failure is triggered in debug builds
|
|
|
|
if the string is invalid). Only use it if you are absolutely sure that
|
|
|
|
@a s is a correct UTF-8 string (e.g. because it comes from another
|
|
|
|
library using UTF-8) and if the performance matters, otherwise use
|
|
|
|
slower (in UTF-8 build) but safer FromUTF8(). Passing a bad UTF-8
|
|
|
|
string to this function will result in creating a corrupted wxString
|
|
|
|
and all the subsequent operations on it will be undefined.
|
|
|
|
|
|
|
|
@since 2.8.9
|
2008-05-06 12:51:35 +00:00
|
|
|
*/
|
2009-03-19 14:51:46 +00:00
|
|
|
static wxString FromUTF8Unchecked(const char* s);
|
|
|
|
static wxString FromUTF8Unchecked(const char* s, size_t len);
|
2008-05-06 10:42:50 +00:00
|
|
|
//@}
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
|
|
|
|
2009-02-04 22:50:11 +00:00
|
|
|
|
|
|
|
|
2009-01-10 22:10:54 +00:00
|
|
|
//@{
|
|
|
|
/**
|
2009-02-04 22:50:11 +00:00
|
|
|
Comparison operator for string types.
|
2009-01-10 22:10:54 +00:00
|
|
|
*/
|
|
|
|
inline bool operator==(const wxString& s1, const wxString& s2);
|
|
|
|
inline bool operator!=(const wxString& s1, const wxString& s2);
|
|
|
|
inline bool operator< (const wxString& s1, const wxString& s2);
|
|
|
|
inline bool operator> (const wxString& s1, const wxString& s2);
|
|
|
|
inline bool operator<=(const wxString& s1, const wxString& s2);
|
|
|
|
inline bool operator>=(const wxString& s1, const wxString& s2);
|
|
|
|
inline bool operator==(const wxString& s1, const wxCStrData& s2);
|
|
|
|
inline bool operator==(const wxCStrData& s1, const wxString& s2);
|
|
|
|
inline bool operator!=(const wxString& s1, const wxCStrData& s2);
|
|
|
|
inline bool operator!=(const wxCStrData& s1, const wxString& s2);
|
|
|
|
inline bool operator==(const wxString& s1, const wxWCharBuffer& s2);
|
|
|
|
inline bool operator==(const wxWCharBuffer& s1, const wxString& s2);
|
|
|
|
inline bool operator!=(const wxString& s1, const wxWCharBuffer& s2);
|
|
|
|
inline bool operator!=(const wxWCharBuffer& s1, const wxString& s2);
|
|
|
|
inline bool operator==(const wxString& s1, const wxCharBuffer& s2);
|
|
|
|
inline bool operator==(const wxCharBuffer& s1, const wxString& s2);
|
|
|
|
inline bool operator!=(const wxString& s1, const wxCharBuffer& s2);
|
|
|
|
inline bool operator!=(const wxCharBuffer& s1, const wxString& s2);
|
2009-02-04 22:50:11 +00:00
|
|
|
//@}
|
2009-01-10 22:10:54 +00:00
|
|
|
|
2009-02-04 22:50:11 +00:00
|
|
|
//@{
|
2009-01-10 22:10:54 +00:00
|
|
|
/**
|
2009-02-04 22:50:11 +00:00
|
|
|
Comparison operators char types.
|
2009-01-10 22:10:54 +00:00
|
|
|
*/
|
|
|
|
inline bool operator==(const wxUniChar& c, const wxString& s);
|
|
|
|
inline bool operator==(const wxUniCharRef& c, const wxString& s);
|
|
|
|
inline bool operator==(char c, const wxString& s);
|
|
|
|
inline bool operator==(wchar_t c, const wxString& s);
|
|
|
|
inline bool operator==(int c, const wxString& s);
|
|
|
|
inline bool operator==(const wxString& s, const wxUniChar& c);
|
|
|
|
inline bool operator==(const wxString& s, const wxUniCharRef& c);
|
|
|
|
inline bool operator==(const wxString& s, char c);
|
|
|
|
inline bool operator==(const wxString& s, wchar_t c);
|
|
|
|
inline bool operator!=(const wxUniChar& c, const wxString& s);
|
|
|
|
inline bool operator!=(const wxUniCharRef& c, const wxString& s);
|
|
|
|
inline bool operator!=(char c, const wxString& s);
|
|
|
|
inline bool operator!=(wchar_t c, const wxString& s);
|
|
|
|
inline bool operator!=(int c, const wxString& s);
|
|
|
|
inline bool operator!=(const wxString& s, const wxUniChar& c);
|
|
|
|
inline bool operator!=(const wxString& s, const wxUniCharRef& c);
|
|
|
|
inline bool operator!=(const wxString& s, char c);
|
|
|
|
inline bool operator!=(const wxString& s, wchar_t c);
|
|
|
|
//@}
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
/**
|
2008-10-07 16:57:34 +00:00
|
|
|
The global wxString instance of an empty string.
|
|
|
|
Used extensively in the entire wxWidgets API.
|
2008-03-10 15:24:38 +00:00
|
|
|
*/
|
|
|
|
wxString wxEmptyString;
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
@class wxStringBufferLength
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-10-07 16:57:34 +00:00
|
|
|
This tiny class allows you to conveniently access the wxString internal buffer
|
|
|
|
as a writable pointer without any risk of forgetting to restore the string to
|
|
|
|
the usable state later, and allows the user to set the internal length of the string.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
|
|
|
For example, assuming you have a low-level OS function called
|
2008-10-07 16:57:34 +00:00
|
|
|
@c "int GetMeaningOfLifeAsString(char *)" copying the value in the provided
|
2008-03-08 13:52:38 +00:00
|
|
|
buffer (which must be writable, of course), and returning the actual length
|
|
|
|
of the string, you might call it like this:
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@code
|
2008-10-07 16:57:34 +00:00
|
|
|
wxString theAnswer;
|
2009-07-22 23:23:01 +00:00
|
|
|
wxStringBufferLength theAnswerBuffer(theAnswer, 1024);
|
2008-03-08 13:52:38 +00:00
|
|
|
int nLength = GetMeaningOfLifeAsString(theAnswerBuffer);
|
|
|
|
theAnswerBuffer.SetLength(nLength);
|
|
|
|
if ( theAnswer != "42" )
|
|
|
|
wxLogError("Something is very wrong!");
|
|
|
|
@endcode
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-07-06 18:34:50 +00:00
|
|
|
Note that the exact usage of this depends on whether or not wxUSE_STL is
|
2008-08-01 23:39:11 +00:00
|
|
|
enabled. If wxUSE_STL is enabled, wxStringBuffer creates a separate empty
|
2008-07-06 18:34:50 +00:00
|
|
|
character buffer, and if wxUSE_STL is disabled, it uses GetWriteBuf() from
|
2008-08-01 23:39:11 +00:00
|
|
|
wxString, keeping the same buffer wxString uses intact. In other words,
|
|
|
|
relying on wxStringBuffer containing the old wxString data is not a good
|
2008-07-06 18:34:50 +00:00
|
|
|
idea if you want to build your program both with and without wxUSE_STL.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-10-07 16:57:34 +00:00
|
|
|
Note that wxStringBuffer::SetLength @b must be called before
|
|
|
|
wxStringBufferLength destructs.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxbase}
|
2008-07-06 18:34:50 +00:00
|
|
|
@category{data}
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
class wxStringBufferLength
|
2008-03-08 13:52:38 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructs a writable string buffer object associated with the given string
|
2008-10-07 16:57:34 +00:00
|
|
|
and containing enough space for at least @a len characters.
|
|
|
|
|
|
|
|
Basically, this is equivalent to calling wxString::GetWriteBuf and
|
2008-03-08 13:52:38 +00:00
|
|
|
saving the result.
|
|
|
|
*/
|
|
|
|
wxStringBufferLength(const wxString& str, size_t len);
|
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
Restores the string passed to the constructor to the usable state by calling
|
2008-03-08 13:52:38 +00:00
|
|
|
wxString::UngetWriteBuf on it.
|
|
|
|
*/
|
|
|
|
~wxStringBufferLength();
|
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
Sets the internal length of the string referred to by wxStringBufferLength to
|
2008-03-09 12:33:59 +00:00
|
|
|
@a nLength characters.
|
2008-10-07 16:57:34 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Must be called before wxStringBufferLength destructs.
|
|
|
|
*/
|
|
|
|
void SetLength(size_t nLength);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the writable pointer to a buffer of the size at least equal to the
|
|
|
|
length specified in the constructor.
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
wxChar* operator wxChar *();
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
|
|
|
|
2008-12-06 16:24:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxStringBuffer
|
|
|
|
|
|
|
|
This tiny class allows you to conveniently access the wxString internal buffer
|
|
|
|
as a writable pointer without any risk of forgetting to restore the string
|
|
|
|
to the usable state later.
|
|
|
|
|
|
|
|
For example, assuming you have a low-level OS function called
|
|
|
|
@c "GetMeaningOfLifeAsString(char *)" returning the value in the provided
|
|
|
|
buffer (which must be writable, of course) you might call it like this:
|
|
|
|
|
|
|
|
@code
|
|
|
|
wxString theAnswer;
|
|
|
|
GetMeaningOfLifeAsString(wxStringBuffer(theAnswer, 1024));
|
|
|
|
if ( theAnswer != "42" )
|
|
|
|
wxLogError("Something is very wrong!");
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
Note that the exact usage of this depends on whether or not @c wxUSE_STL is
|
|
|
|
enabled. If @c wxUSE_STL is enabled, wxStringBuffer creates a separate empty
|
|
|
|
character buffer, and if @c wxUSE_STL is disabled, it uses GetWriteBuf() from
|
|
|
|
wxString, keeping the same buffer wxString uses intact. In other words,
|
|
|
|
relying on wxStringBuffer containing the old wxString data is not a good
|
|
|
|
idea if you want to build your program both with and without @c wxUSE_STL.
|
|
|
|
|
|
|
|
@library{wxbase}
|
|
|
|
@category{data}
|
|
|
|
*/
|
|
|
|
class wxStringBuffer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructs a writable string buffer object associated with the given string
|
|
|
|
and containing enough space for at least @a len characters.
|
|
|
|
Basically, this is equivalent to calling wxString::GetWriteBuf() and
|
|
|
|
saving the result.
|
|
|
|
*/
|
|
|
|
wxStringBuffer(const wxString& str, size_t len);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Restores the string passed to the constructor to the usable state by calling
|
|
|
|
wxString::UngetWriteBuf() on it.
|
|
|
|
*/
|
|
|
|
~wxStringBuffer();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the writable pointer to a buffer of the size at least equal to the
|
|
|
|
length specified in the constructor.
|
|
|
|
*/
|
|
|
|
wxStringCharType* operator wxStringCharType *();
|
|
|
|
};
|
2009-01-31 21:19:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
/** @addtogroup group_funcmacro_string */
|
|
|
|
//@{
|
|
|
|
|
|
|
|
/**
|
|
|
|
Allows to extend a function with the signature:
|
|
|
|
@code bool SomeFunc(const wxUniChar& c) @endcode
|
|
|
|
which operates on a single character, to an entire wxString.
|
|
|
|
|
|
|
|
E.g. if you want to check if an entire string contains only digits,
|
|
|
|
you can do:
|
|
|
|
@code
|
|
|
|
if (wxStringCheck<wxIsdigit>(myString))
|
2012-12-01 00:14:31 +00:00
|
|
|
... // the entire string contains only digits!
|
2009-01-31 21:19:37 +00:00
|
|
|
else
|
|
|
|
... // at least one character of myString is not a digit
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
@return @true if the given function returns a non-zero value for all
|
|
|
|
characters of the @a val string.
|
|
|
|
*/
|
|
|
|
template<bool (T)(const wxUniChar& c)>
|
2009-02-01 19:56:06 +00:00
|
|
|
inline bool wxStringCheck(const wxString& val);
|
2009-01-31 21:19:37 +00:00
|
|
|
|
|
|
|
//@}
|