internal buffer as a writable pointer without any risk of forgetting to restore
the string to the usable state later.
internal buffer as a writable pointer without any risk of forgetting to restore
the string to the usable state later.
@c GetMeaningOfLifeAsString(char *) returning the value in the provided
buffer (which must be writable, of course) you might call it like this:
@c GetMeaningOfLifeAsString(char *) returning the value in the provided
buffer (which must be writable, of course) you might call it like this:
Note that the exact usage of this depends on whether on not wxUSE_STL is
enabled. If
wxUSE_STL is enabled, wxStringBuffer creates a separate empty character buffer,
Note that the exact usage of this depends on whether on not wxUSE_STL is
enabled. If
wxUSE_STL is enabled, wxStringBuffer creates a separate empty character buffer,
if wxUSE_STL is disabled, it uses GetWriteBuf() from wxString, keeping the same
buffer
wxString uses intact. In other words, relying on wxStringBuffer containing the
if wxUSE_STL is disabled, it uses GetWriteBuf() from wxString, keeping the same
buffer
wxString uses intact. In other words, relying on wxStringBuffer containing the
wxString data is probably not a good idea if you want to build your program in
both
with and without wxUSE_STL.
wxString data is probably not a good idea if you want to build your program in
both
with and without wxUSE_STL.
is equivalent to calling wxString::GetWriteBuf and
saving the result.
*/
wxStringBuffer(const wxString& str, size_t len);
/**
is equivalent to calling wxString::GetWriteBuf and
saving the result.
*/
wxStringBuffer(const wxString& str, size_t len);
/**
Returns the writable pointer to a buffer of the size at least equal to the
length specified in the constructor.
*/
Returns the writable pointer to a buffer of the size at least equal to the
length specified in the constructor.
*/
As explained there, wxString implements most of the methods of the std::string
class.
These standard functions are not documented in this manual, please see the
STL documentation).
The behaviour of all these functions is identical to the behaviour described
there.
As explained there, wxString implements most of the methods of the std::string
class.
These standard functions are not documented in this manual, please see the
STL documentation).
The behaviour of all these functions is identical to the behaviour described
there.
- thing like, for example, wxString::Length,
+ thing like, for example, wxString::Length,
wxString::Len and @c length() which all return the string
length. In all cases of such duplication the @c std::string-compatible
method (@c length() in this case, always the lowercase version) should be
used as it will ensure smoother transition to @c std::string when wxWidgets
starts using it instead of wxString.
wxString::Len and @c length() which all return the string
length. In all cases of such duplication the @c std::string-compatible
method (@c length() in this case, always the lowercase version) should be
used as it will ensure smoother transition to @c std::string when wxWidgets
starts using it instead of wxString.
- Objects:
- wxEmptyString
-
- @seealso
- @ref overview_wxstringoverview "wxString overview", @ref overview_unicode
+ ::Objects:, ::wxEmptyString,
+
+ @see @ref overview_wxstringoverview "wxString overview", @ref overview_unicode
- @sa @ref overview_mbconvclasses "wxMBConv classes", @ref mbstr()
- mb_str, @ref wcstr() wc_str
+ @see @ref overview_mbconvclasses "wxMBConv classes", @ref mbstr()
+ mb_str, @ref wcstr() wc_str
- wxString(const wxString& x);
- wxString(wxChar ch, size_t n = 1);
- wxString(const wxChar* psz, size_t nLength = wxSTRING_MAXLEN);
- wxString(const unsigned char* psz,
- size_t nLength = wxSTRING_MAXLEN);
- wxString(const wchar_t* psz, const wxMBConv& conv,
- size_t nLength = wxSTRING_MAXLEN);
- wxString(const char* psz, const wxMBConv& conv = wxConvLibc,
- size_t nLength = wxSTRING_MAXLEN);
+ wxString(const wxString& x);
+ wxString(wxChar ch, size_t n = 1);
+ wxString(const wxChar* psz, size_t nLength = wxSTRING_MAXLEN);
+ wxString(const unsigned char* psz,
+ size_t nLength = wxSTRING_MAXLEN);
+ wxString(const wchar_t* psz, const wxMBConv& conv,
+ size_t nLength = wxSTRING_MAXLEN);
+ wxString(const char* psz, const wxMBConv& conv = wxConvLibc,
+ size_t nLength = wxSTRING_MAXLEN);
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
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 @e nLen characters are stored in it. Also, it
- does not truncate the existing string (use
+ will still expand if more than @a nLen characters are stored in it. Also, it
+ does not truncate the existing string (use
/**
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.
/**
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.
This section also contains both implicit and explicit conversions to C style
strings. Although implicit conversion is quite convenient, it is advised to use
explicit @ref cstr() c_str method for the sake of clarity. Also
This section also contains both implicit and explicit conversions to C style
strings. Although implicit conversion is quite convenient, it is advised to use
explicit @ref cstr() c_str method for the sake of clarity. Also
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 @e strcmp() function).
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 @e strcmp() function).
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 @e strcmp() function).
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 @e strcmp() function).
Matches() is a poor man's regular expression matcher:
it only understands '*' and '?' metacharacters in the sense of DOS command line
interpreter.
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 then.
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 then.
- bool operator ==(const wxString& x, const wxChar* t);
- bool operator !=(const wxString& x, const wxString& y);
- bool operator !=(const wxString& x, const wxChar* t);
- bool operator(const wxString& x, const wxString& y);
- bool operator(const wxString& x, const wxChar* t);
- bool operator =(const wxString& x, const wxString& y);
- bool operator =(const wxString& x, const wxChar* t);
- bool operator(const wxString& x, const wxString& y);
- bool operator(const wxString& x, const wxChar* t);
- bool operator =(const wxString& x, const wxString& y);
- bool operator =(const wxString& x, const wxChar* t);
+ bool operator ==(const wxString& x, const wxChar* t);
+ bool operator !=(const wxString& x, const wxString& y);
+ bool operator !=(const wxString& x, const wxChar* t);
+ bool operator(const wxString& x, const wxString& y);
+ bool operator(const wxString& x, const wxChar* t);
+ bool operator =(const wxString& x, const wxString& y);
+ bool operator =(const wxString& x, const wxChar* t);
+ bool operator(const wxString& x, const wxString& y);
+ bool operator(const wxString& x, const wxChar* t);
+ bool operator =(const wxString& x, const wxString& y);
+ bool operator =(const wxString& x, const wxChar* t);
//@}
/**
Anything may be concatenated (appended to) with a string. However, you can't
append something to a C string (including literal constants), so to do this it
should be converted to a wxString first.
//@}
/**
Anything may be concatenated (appended to) with a string. However, you can't
append something to a C string (including literal constants), so to do this it
should be converted to a wxString first.
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.
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.
/**
The string provides functions for conversion to signed and unsigned integer and
floating point numbers. All three 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.
/**
The string provides functions for conversion to signed and unsigned integer and
floating point numbers. All three 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.
- int Find(wxUniChar ch, bool fromEnd = @false);
- int Find(const wxString& sub);
+ int Find(wxUniChar ch, bool fromEnd = false) const;
+ const int Find(const wxString& sub) const;
- int First(wxChar c);
- int First(const wxChar* psz);
- int First(const wxString& str);
+ int First(wxChar c) const;
+ int First(const wxChar* psz) const;
+ const int First(const wxString& str) const;
//@{
/**
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
//@{
/**
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
- 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);
+ 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);
doesn't do any validation in release builds, it's validity is only checked in
debug builds.
*/
static wxString FromUTF8(const char* s);
doesn't do any validation in release builds, it's validity is only checked in
debug builds.
*/
static wxString FromUTF8(const char* s);
It returns a pointer to a new memory block, and the
existing data will not be copied.
It returns a pointer to a new memory block, and the
existing data will not be copied.
This method is deprecated, please use
wxStringBuffer or
wxStringBufferLength instead.
This method is deprecated, please use
wxStringBuffer or
wxStringBufferLength instead.
- bool IsSameAs(const wxChar* psz, bool caseSensitive = @true);
- bool IsSameAs(wxChar c, bool caseSensitive = @true);
+ bool IsSameAs(const wxChar* psz, bool caseSensitive = true) const;
+ const bool IsSameAs(wxChar c, bool caseSensitive = true) const;
wxStringBuffer
and wxStringBufferLength classes may be very
useful when working with some external API which requires the caller to provide
a writable buffer.
wxStringBuffer
and wxStringBufferLength classes may be very
useful when working with some external API which requires the caller to provide
a writable buffer.
-#define wxString Pad(size_t count, wxChar pad = ' ',
- bool fromRight = @true) /* implementation is private */
+ wxString Pad(size_t count, wxChar pad = ' ',
+ bool fromRight = true);
*/
wxString Prepend(const wxString& str);
/**
Similar to the standard function @e sprintf(). Returns the number of
characters written, or an integer less than zero on error.
*/
wxString Prepend(const wxString& str);
/**
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:
Note that if @c wxUSE_PRINTF_POS_PARAMS is set to 1, then this function supports
Unix98-style positional parameters:
@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.
*/
@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.
*/
This is a wxWidgets 1.xx compatibility function; you should not use it in new
code.
*/
wxString Remove(size_t pos);
This is a wxWidgets 1.xx compatibility function; you should not use it in new
code.
*/
wxString Remove(size_t pos);
Returns the number of replacements made.
*/
size_t Replace(const wxString& strOld, const wxString& strNew,
Returns the number of replacements made.
*/
size_t Replace(const wxString& strOld, const wxString& strNew,
/**
Strip characters at the front and/or end. The same as Trim except that it
doesn't change this string.
/**
Strip characters at the front and/or end. The same as Trim except that it
doesn't change this string.
This is a wxWidgets 1.xx compatibility function, use Mid()
instead (but note that parameters have different meaning).
*/
This is a wxWidgets 1.xx compatibility function, use Mid()
instead (but note that parameters have different meaning).
*/
/**
These functions allow to extract substring from this string. All of them don't
modify the original string and return a new string containing the extracted
substring.
/**
These functions allow to extract substring from this string. All of them don't
modify the original string and return a new string containing the extracted
substring.
/**
Converts the string to an 8-bit string in ISO-8859-1 encoding in the form of
a wxCharBuffer (Unicode builds only).
/**
Converts the string to an 8-bit string in ISO-8859-1 encoding in the form of
a wxCharBuffer (Unicode builds only).
//@}
//@{
/**
Converts the string to an ASCII, 7-bit string in the form of
a wxCharBuffer (Unicode builds only) or a C string (ANSI builds).
//@}
//@{
/**
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 mbstr() mb_str method provides more
powerful means of converting wxString to C string.
*/
Note that this conversion only works if the string contains only ASCII
characters. The @ref mbstr() mb_str method provides more
powerful means of converting wxString to C string.
*/
//@}
/**
Attempts to convert the string to a floating point number. Returns @true on
success (the number is stored in the location pointed to by @e val) or @false
//@}
/**
Attempts to convert the string to a floating point number. Returns @true on
success (the number is stored in the location pointed to by @e val) or @false
/**
Attempts to convert the string to a signed integer in base @e base. Returns
@true on success in which case the number is stored in the location
/**
Attempts to convert the string to a signed integer in base @e base. Returns
@true on success in which case the number is stored in the location
- pointed to by @e val or @false if the string does not represent a
- valid number in the given base (the value of @e val is not modified
+ pointed to by @a val or @false if the string does not represent a
+ valid number in the given base (the value of @a val is not modified
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
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
which may have leading zeroes as they can yield unexpected (to the user not
familiar with C) results.
which may have leading zeroes as they can yield unexpected (to the user not
familiar with C) results.
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.
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.
/**
Attempts to convert the string to an unsigned integer in base @e base.
Returns @true on success in which case the number is stored in the
/**
Attempts to convert the string to an unsigned integer in base @e base.
Returns @true on success in which case the number is stored in the
- location pointed to by @e val or @false if the string does not
- represent a valid number in the given base (the value of @e val is not
+ location pointed to by @a val or @false if the string does not
+ represent a valid number in the given base (the value of @a val is not
modified in this case). 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).
modified in this case). 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).
//@}
/**
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).
*/
//@}
/**
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).
*/
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
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
This method is deprecated, please use
wxStringBuffer or
wxStringBufferLength instead.
*/
void UngetWriteBuf();
This method is deprecated, please use
wxStringBuffer or
wxStringBufferLength instead.
*/
void UngetWriteBuf();
/**
Returns a pointer to the string data (@c const char* in ANSI build,
@c const wchar_t* in Unicode build).
/**
Returns a pointer to the string data (@c const char* in ANSI build,
@c const wchar_t* in Unicode build).
Note that the returned value is not convertible to @c char* or
@c wchar_t*, use @ref charstr() char_str or
@ref wcharstr() wchar_string if you need to pass string value
to a function expecting non-const pointer.
Note that the returned value is not convertible to @c char* or
@c wchar_t*, use @ref charstr() char_str or
@ref wcharstr() wchar_string if you need to pass string value
to a function expecting non-const pointer.
- @sa @ref mbstr() mb_str, @ref wcstr() wc_str, @ref
- fnstr() fn_str, @ref charstr() char_str, @ref
- wcharstr() wchar_string
+ @see @ref mbstr() mb_str, @ref wcstr() wc_str, @ref
+ fnstr() fn_str, @ref charstr() char_str, @ref
+ wcharstr() wchar_string
- @sa @ref mbstr() mb_str, @ref wcstr() wc_str, @ref
- fnstr() fn_str, @ref cstr() c_str, @ref
- wcharstr() wchar_str
+ @see @ref mbstr() mb_str, @ref wcstr() wc_str, @ref
+ fnstr() fn_str, @ref cstr() c_str, @ref
+ wcharstr() wchar_str
- const wchar_t* fn_str();
- const char* fn_str();
- const wxCharBuffer fn_str();
+ const wchar_t* fn_str() const;
+ const const char* fn_str() const;
+ const const wxCharBuffer fn_str() const;
- @sa wxMBConv, @ref cstr() c_str, @ref wcstr() wc_str, @ref
- fnstr() fn_str, @ref charstr() char_str
+ @see wxMBConv, @ref cstr() c_str, @ref wcstr() wc_str, @ref
+ fnstr() fn_str, @ref charstr() char_str
- const char* mb_str(const wxMBConv& conv = wxConvLibc);
- const wxCharBuffer mb_str(const wxMBConv& conv = wxConvLibc);
+ const char* mb_str(const wxMBConv& conv = wxConvLibc) const;
+ const const wxCharBuffer mb_str(const wxMBConv& conv = wxConvLibc) const;
/**
These functions work as C++ stream insertion operators: they insert the given
value into the string. Precision or format cannot be set using them, you can
/**
These functions work as C++ stream insertion operators: they insert the given
value into the string. Precision or format cannot be set using them, you can
- wxString operator(const wxChar* psz);
- wxString operator(wxChar ch);
- wxString operator(int i);
- wxString operator(float f);
- wxString operator(double d);
+ wxString operator(const wxChar* psz);
+ wxString operator(wxChar ch);
+ wxString operator(int i);
+ wxString operator(float f);
+ wxString operator(double d);
concatenation of the operands.
*/
wxString operator +(const wxString& x, const wxString& y);
concatenation of the operands.
*/
wxString operator +(const wxString& x, const wxString& y);
- wxString operator +(const wxString& x, const wxChar* y);
- wxString operator +(const wxString& x, wxChar y);
- wxString operator +(const wxChar* x, const wxString& y);
+ wxString operator +(const wxString& x, const wxChar* y);
+ wxString operator +(const wxString& x, wxChar y);
+ wxString operator +(const wxChar* x, const wxString& y);
Concatenation in place: the argument is appended to the string.
*/
void operator +=(const wxString& str);
Concatenation in place: the argument is appended to the string.
*/
void operator +=(const wxString& str);
constructor (see @ref construct() "wxString constructors").
*/
wxString operator =(const wxString& str);
constructor (see @ref construct() "wxString constructors").
*/
wxString operator =(const wxString& str);
- wxChar operator [](size_t i);
- wxChar operator [](size_t i);
- wxChar operator [](int i);
- wxChar operator [](int i);
+ wxChar operator [](size_t i) const;
+ wxChar operator [](size_t i) const;
+ const wxChar operator [](int i) const;
+ wxChar operator [](int i) const;
This allows the tests for @NULLness of a @e const wxChar * pointer and emptiness
of the string to look the same in the code and makes it easier to port old code
to wxString.
This allows the tests for @NULLness of a @e const wxChar * pointer and emptiness
of the string to look the same in the code and makes it easier to port old code
to wxString.
- @sa wxMBConv, @ref cstr() c_str, @ref wcstr() mb_str, @ref
- fnstr() fn_str, @ref wcharstr() wchar_str
+ @see wxMBConv, @ref cstr() c_str, @ref wcstr() mb_str, @ref
+ fnstr() fn_str, @ref wcharstr() wchar_str
- const wchar_t* wc_str(const wxMBConv& conv);
- const wxWCharBuffer wc_str(const wxMBConv& conv);
+ const wchar_t* wc_str(const wxMBConv& conv) const;
+ const const wxWCharBuffer wc_str(const wxMBConv& conv) const;
passing strings to legacy libraries that don't have const-correct API. Use
wxStringBuffer if you want to modify the string.
passing strings to legacy libraries that don't have const-correct API. Use
wxStringBuffer if you want to modify the string.
- @sa @ref mbstr() mb_str, @ref wcstr() wc_str, @ref
- fnstr() fn_str, @ref cstr() c_str, @ref
- charstr() char_str
+ @see @ref mbstr() mb_str, @ref wcstr() wc_str, @ref
+ fnstr() fn_str, @ref cstr() c_str, @ref
+ charstr() char_str
/**
These functions are deprecated, please consider using new wxWidgets 2.0
functions instead of them (or, even better, std::string compatible variants).
/**
These functions are deprecated, please consider using new wxWidgets 2.0
functions instead of them (or, even better, std::string compatible variants).
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.
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.
@c int GetMeaningOfLifeAsString(char *) copying the value in the provided
buffer (which must be writable, of course), and returning the actual length
of the string, you might call it like this:
@c int GetMeaningOfLifeAsString(char *) copying the value in the provided
buffer (which must be writable, of course), and returning the actual length
of the string, you might call it like this:
Note that the exact usage of this depends on whether on not wxUSE_STL is
enabled. If
wxUSE_STL is enabled, wxStringBuffer creates a separate empty character buffer,
Note that the exact usage of this depends on whether on not wxUSE_STL is
enabled. If
wxUSE_STL is enabled, wxStringBuffer creates a separate empty character buffer,
if wxUSE_STL is disabled, it uses GetWriteBuf() from wxString, keeping the same
buffer
wxString uses intact. In other words, relying on wxStringBuffer containing the
if wxUSE_STL is disabled, it uses GetWriteBuf() from wxString, keeping the same
buffer
wxString uses intact. In other words, relying on wxStringBuffer containing the
wxString data is probably not a good idea if you want to build your program in
both
with and without wxUSE_STL.
wxString data is probably not a good idea if you want to build your program in
both
with and without wxUSE_STL.
is equivalent to calling wxString::GetWriteBuf and
saving the result.
*/
wxStringBufferLength(const wxString& str, size_t len);
/**
is equivalent to calling wxString::GetWriteBuf and
saving the result.
*/
wxStringBufferLength(const wxString& str, size_t len);
/**
Returns the writable pointer to a buffer of the size at least equal to the
length specified in the constructor.
*/
Returns the writable pointer to a buffer of the size at least equal to the
length specified in the constructor.
*/
// ============================================================================
// Global functions/macros
// ============================================================================
// ============================================================================
// Global functions/macros
// ============================================================================