#include <wx/string.h>
String class for passing textual data to or receiving it from wxWidgets.
std::string
or std::wstring
in your applications and convert them to and from wxString only when interacting with wxWidgets.wxString is a class representing a Unicode character string but with methods taking or returning both wchar_t
wide characters and wchar_t*
wide strings and traditional char
characters and char*
strings. The dual nature of wxString API makes it simple to use in all cases and, importantly, allows the code written for either ANSI or Unicode builds of the previous wxWidgets versions to compile and work correctly with the single unified build of wxWidgets 3.0 and later. It is also mostly transparent when using wxString with the few exceptions described below.
wxString tries to be similar to both std::string
and std::wstring
and can mostly be used as either class. It provides practically all of the methods of these classes, which behave exactly the same as in the standard C++, and so are not documented here (please see documentation at https://en.cppreference.com/w/cpp/string/basic_string for this).
In addition to these standard methods, wxString adds functions dealing with the conversions between different string encodings, described below, as well as many extra helpers such as functions for formatted output (Printf(), Format(), ...), case conversion (MakeUpper(), Capitalize(), ...) and various others (Trim(), StartsWith(), Matches(), ...). All of the non-standard methods follow wxWidgets "CamelCase" naming convention and are documented here.
Notice that some wxString methods exist in several versions for compatibility reasons. For example all of length(), Length() and Len() are provided. In such cases it is recommended to use the standard string-like method, i.e. length() in this case.
wxString can be created from:
char*
string in the current locale encoding using implicit wxString::wxString(const char*) constructor or using more explicit wxString::wxString(const char*, const wxMBConv&) constructor passing it wxConvLibc as the second argument.char*
string in UTF-8 encoding using wxString::FromUTF8().char*
string in the given encoding using wxString::wxString(const char*, const wxMBConv&) constructor passing a wxCSConv corresponding to the encoding as the second argument.std::string
using implicit wxString::wxString(const std::string&) constructor. Notice that this constructor supposes that the string contains data in the current locale encoding, use FromUTF8() if the string contains UTF-8-encoded data instead.std::string_view
using implicit wxString::wxString(std::string_view) constructor. Notice that this constructor supposes that the string contains data in the current locale encoding, use FromUTF8() if the string contains UTF-8-encoded data instead.wchar_t*
string using implicit wxString::wxString(const wchar_t*) constructor.std::wstring
using implicit wxString::wxString(const std::wstring&) constructor.std::wstring_view
using implicit wxString::wxString(std::wstring_view) constructor.Notice that many of the constructors are implicit, meaning that you don't even need to write them at all to pass the existing string to some wxWidgets function taking a wxString. This is convenient, but can also be dangerous when constructing wxString from char*
or std::string
if it doesn't have the expected encoding, as the resulting string will be empty if the conversion from the current locale encoding fails. If you want to disable all such conversions at compile-time, you may predefine wxNO_IMPLICIT_WXSTRING_ENCODING
when compiling the application code and the corresponding conversions become inaccessible, i.e.
The only case in which such conversions are fully safe is when the library is compiled with wxUSE_UTF8_LOCALE_ONLY
option set to 1, as all the strings are assumed to be in UTF-8 encoding then.
Similarly, wxString can be converted to:
std::string
using wxString::ToStdString(). The encoding of the returned string is specified with a wxMBConv object, so this conversion is potentially destructive as well. To ensure that there is no data loss, use wxConvUTF8
conversion or wxString::utf8_string().std::wstring
using wxString::ToStdWstring() or its synonym wxString::wc_string().As above, defining wxNO_IMPLICIT_WXSTRING_ENCODING
when compiling application code prevents the implicit use of the current locale encoding and disables implicit conversions to char*
and std::string
as well as using mb_str() and ToStdString() without explicitly specifying the encoding:
However, if completely disabling conversions to narrow strings by defining wxNO_IMPLICIT_WXSTRING_ENCODING
is undesirable, it is also possible to disable implicit conversions by predefining wxNO_UNSAFE_WXSTRING_CONV
instead, i.e. with this symbol defined implicit conversion to const char*
becomes unavailable – but explicit conversions using c_str() and mb_str() still work.
Finally, please note that implicit conversion to both const char*
(which is unsafe for the reasons explained above) and to const wchar_t*
(which is safe from this point of view, but may still be considered dangerous, as any implicit conversion) may be entirely disabled by defining wxNO_IMPLICIT_WXSTRING_CONV_TO_PTR
when building the application.
To summarize, the safest way to use wxString is to always define wxNO_IMPLICIT_WXSTRING_ENCODING
in the application compilation options to disable all implicit uses of encoding and specify it explicitly, typically by using utf8_str() or utf8_string() and FromUTF8() for conversions, for every operation. If this is impossible, for example because it would require too many changes to the existing code, consider defining wxNO_UNSAFE_WXSTRING_CONV
to at least disable implicit unsafe conversions.
As mentioned above, wxString tries to be compatible with both narrow and wide standard string classes and mostly does it transparently, but there are some exceptions.
Some problems are caused by wxString::operator[]() which returns an object of a special proxy class allowing to assign either a simple char
or a wchar_t
to the given index. Because of this, the return type of this operator is neither char
nor wchar_t
nor a reference to one of these types but wxUniCharRef which is not a primitive type and hence can't be used in the switch
statement. So the following code does not compile
and you need to use
instead. Alternatively, you can use an explicit cast:
but notice that this will result in an assert failure if the character at the given position is not representable as a single char
in the current encoding, so you may want to cast to int
instead if non-ASCII values can be used.
Another consequence of this unusual return type arises when it is used with template deduction or C++11 auto
keyword. Unlike with the normal references which are deduced to be of the referenced type, the deduced type for wxUniCharRef is wxUniCharRef itself. This results in potentially unexpected behaviour, for example:
Due to this, either explicitly specify the variable type:
or explicitly convert the return value:
A different class of problems happens due to the dual nature of the return value of wxString::c_str() method, which is also used for implicit conversions. The result of calls to this method is convertible to either narrow char*
string or wide wchar_t*
string and so, again, has neither the former nor the latter type. Usually, the correct type will be chosen depending on how you use the result but sometimes the compiler can't choose it because of an ambiguity, e.g.:
In this case you need to explicitly convert to the type that you need to use or use a different, non-ambiguous, conversion function (which is usually the best choice):
A special subclass of the problems arising due to the polymorphic nature of wxString::c_str() result type happens when using functions taking an arbitrary number of arguments, such as the standard printf()
. Due to the rules of the C++ language, the types for the "variable" arguments of such functions are not specified and hence the compiler cannot convert wxString objects, or the objects returned by wxString::c_str(), to these unknown types automatically. Hence neither wxString objects nor the results of most of the conversion functions can be passed as vararg arguments:
Instead you need to either explicitly cast to the needed type:
But a better solution is to use wxWidgets-provided functions, if possible, as is the case for printf
family of functions:
Notice that wxPrintf() replaces both printf()
and wprintf()
and accepts wxString objects, results of c_str() calls but also char*
and wchar_t*
strings directly.
wxWidgets provides wx-prefixed equivalents to all the standard vararg functions and a few more, notably wxString::Format(), wxLogMessage(), wxLogError() and other log functions. But if you can't use one of those functions and need to pass wxString objects to non-wx vararg functions, you need to use the explicit casts as explained above.
wxString uses std::basic_string
internally to store its content and it therefore inherits many features from the standard class. In particular, most implementations of std::basic_string
use small string optimization, meaning that they avoid allocating heap memory for short strings, and this is also true for wxString.
By default, wxString uses std::basic_string
specialized for the platform-dependent wchar_t
type, meaning that it is not memory-efficient for ASCII strings, especially under Unix platforms where every ASCII character, normally fitting in a byte, is represented by a 4 byte wchar_t
.
It is possible to build wxWidgets with wxUSE_UNICODE_UTF8
set to 1 in which case an UTF-8-encoded string representation is stored in std::basic_string
specialized for char
, i.e. the usual std::string
. In this case the memory efficiency problem mentioned above doesn't arise but run-time performance of many wxString methods changes dramatically, in particular accessing the N-th character of the string becomes an operation taking O(N) time instead of O(1), i.e. constant, time by default. Thus, if you do use this so called UTF-8 build, you should avoid using indices to access the strings whenever possible and use the iterators instead. As an example, traversing the string using iterators is an O(N), where N is the string length, operation in both the normal ("wchar_t") and UTF-8 builds but doing it using indices becomes O(N^2) in UTF-8 case meaning that simply checking every character of a reasonably long (e.g. a couple of millions elements) string can take an unreasonably long time.
However, if you do use iterators, UTF-8 build can be a better choice than the default build, especially for the memory-constrained embedded systems. Notice also that GTK+ and DirectFB use UTF-8 internally, so using this build not only saves memory for ASCII strings but also avoids conversions between wxWidgets and the underlying toolkit.
Links for quick access to the various categories of wxString functions:
Predefined objects/pointers: wxEmptyString
Concatenation | |
Almost anything may be concatenated (appended to) with a string! Note that the various operator<<() overloads work as C++ stream insertion operators. They insert the given value into the string. Precision and format cannot be set using them. Use Printf() instead. | |
wxString & | Append (const char *psz) |
Appends the string literal psz. More... | |
wxString & | Append (const wchar_t *pwz) |
Appends the wide string literal pwz. More... | |
wxString & | Append (const char *psz, size_t nLen) |
Appends the string literal psz with max length nLen. More... | |
wxString & | Append (const wchar_t *pwz, size_t nLen) |
Appends the wide string literal psz with max length nLen. More... | |
wxString & | Append (const wxString &s) |
Appends the string s. More... | |
wxString & | Append (wxUniChar ch, size_t count=1u) |
Appends the character ch count times. More... | |
wxString & | Prepend (const wxString &str) |
Prepends str to this string, returning a reference to this string. More... | |
wxString & | operator<< (const wxString &s) |
Appends the string literal psz. More... | |
wxString & | operator<< (const char *psz) |
Appends the string literal psz. More... | |
wxString & | operator<< (const wchar_t *pwz) |
Appends the string literal psz. More... | |
wxString & | operator<< (const wxCStrData &psz) |
Appends the string literal psz. More... | |
wxString & | operator<< (char ch) |
Appends the string literal psz. More... | |
wxString & | operator<< (unsigned char ch) |
Appends the string literal psz. More... | |
wxString & | operator<< (wchar_t ch) |
Appends the string literal psz. More... | |
wxString & | operator<< (const wxCharBuffer &s) |
Appends the string literal psz. More... | |
wxString & | operator<< (const wxWCharBuffer &s) |
Appends the string literal psz. More... | |
wxString & | operator<< (wxUniChar ch) |
Appends the string literal psz. More... | |
wxString & | operator<< (wxUniCharRef ch) |
Appends the string literal psz. More... | |
wxString & | operator<< (unsigned int ui) |
Appends the string literal psz. More... | |
wxString & | operator<< (long l) |
Appends the string literal psz. More... | |
wxString & | operator<< (unsigned long ul) |
Appends the string literal psz. More... | |
wxString & | operator<< (wxLongLong_t ll) |
Appends the string literal psz. More... | |
wxString & | operator<< (wxULongLong_t ul) |
Appends the string literal psz. More... | |
wxString & | operator<< (float f) |
Appends the string literal psz. More... | |
wxString & | operator<< (double d) |
Appends the string literal psz. More... | |
void | operator+= (const wxString &str) |
Concatenation in place: the argument is appended to the string. More... | |
void | operator+= (wxUniChar c) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
wxString | operator+ (const wxString &x, const wxString &y) |
Concatenation: returns a new string equal to the concatenation of the operands. More... | |
wxString | operator+ (const wxString &x, wxUniChar y) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
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. See also the compare() STL-like function. | |
int | Cmp (const wxString &s) const |
Case-sensitive comparison. More... | |
int | CmpNoCase (const wxString &s) const |
Case-insensitive comparison. More... | |
bool | IsSameAs (const wxString &s, bool caseSensitive=true) const |
Test whether the string is equal to another string s. More... | |
bool | IsSameAs (wxUniChar ch, bool caseSensitive=true) const |
Test whether the string is equal to the single character ch. More... | |
bool | operator== (const wxString &s1, const wxString &s2) |
Comparison operator for string types. More... | |
bool | operator!= (const wxString &s1, const wxString &s2) |
Case-sensitive comparison. More... | |
bool | operator< (const wxString &s1, const wxString &s2) |
Case-sensitive comparison. More... | |
bool | operator> (const wxString &s1, const wxString &s2) |
Case-sensitive comparison. More... | |
bool | operator<= (const wxString &s1, const wxString &s2) |
Case-sensitive comparison. More... | |
bool | operator>= (const wxString &s1, const wxString &s2) |
Case-sensitive comparison. More... | |
bool | operator== (const wxString &s1, const wxCStrData &s2) |
Case-sensitive comparison. More... | |
bool | operator== (const wxCStrData &s1, const wxString &s2) |
Case-sensitive comparison. More... | |
bool | operator!= (const wxString &s1, const wxCStrData &s2) |
Case-sensitive comparison. More... | |
bool | operator!= (const wxCStrData &s1, const wxString &s2) |
Case-sensitive comparison. More... | |
bool | operator== (const wxString &s1, const wxWCharBuffer &s2) |
Case-sensitive comparison. More... | |
bool | operator== (const wxWCharBuffer &s1, const wxString &s2) |
Case-sensitive comparison. More... | |
bool | operator!= (const wxString &s1, const wxWCharBuffer &s2) |
Case-sensitive comparison. More... | |
bool | operator!= (const wxWCharBuffer &s1, const wxString &s2) |
Case-sensitive comparison. More... | |
bool | operator== (const wxString &s1, const wxCharBuffer &s2) |
Case-sensitive comparison. More... | |
bool | operator== (const wxCharBuffer &s1, const wxString &s2) |
Case-sensitive comparison. More... | |
bool | operator!= (const wxString &s1, const wxCharBuffer &s2) |
Case-sensitive comparison. More... | |
bool | operator!= (const wxCharBuffer &s1, const wxString &s2) |
Case-sensitive comparison. More... | |
Public Types | |
Standard types | |
Types used with wxString. | |
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 |
Public Member Functions | |
bool | Matches (const wxString &mask) const |
Returns true if the string contents matches a mask containing '*' and '?'. More... | |
bool | StartsWith (const wxString &prefix, wxString *rest=nullptr) const |
This function can be used to test if the string starts with the specified prefix. More... | |
bool | EndsWith (const wxString &suffix, wxString *rest=nullptr) const |
This function can be used to test if the string ends with the specified suffix. More... | |
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. See also the assign() STL-like function. | |
wxString () | |
Default constructor. More... | |
wxString (const wxString &stringSrc) | |
Creates a string from another string. More... | |
wxString (wxUniChar ch, size_t nRepeat=1) | |
Construct a string consisting of nRepeat copies of ch. More... | |
wxString (wxUniCharRef ch, size_t nRepeat=1) | |
Construct a string consisting of nRepeat copies of ch. More... | |
wxString (char ch, size_t nRepeat=1) | |
Construct a string consisting of nRepeat copies of ch converted to Unicode using the current locale encoding. More... | |
wxString (wchar_t ch, size_t nRepeat=1) | |
Construct a string consisting of nRepeat copies of ch. More... | |
wxString (const char *psz) | |
Constructs a string from the string literal psz using the current locale encoding to convert it to Unicode (wxConvLibc). More... | |
wxString (const char *psz, const wxMBConv &conv) | |
Constructs a string from the string literal psz using conv to convert it Unicode. More... | |
wxString (const char *psz, size_t nLength) | |
Constructs a string from the first nLength bytes of the string literal psz using the current locale encoding to convert it to Unicode (wxConvLibc). More... | |
wxString (const char *psz, const wxMBConv &conv, size_t nLength) | |
Constructs a string from the first nLength bytes of the string literal psz using conv to convert it Unicode. More... | |
wxString (const wchar_t *pwz) | |
Constructs a string from the string literal pwz. More... | |
wxString (const wchar_t *pwz, size_t nLength) | |
Constructs a string from the first nLength characters of the string literal pwz. More... | |
wxString (const wxCharBuffer &buf) | |
Constructs a string from buf using the using the current locale encoding to convert it to Unicode. More... | |
wxString (const wxWCharBuffer &buf) | |
Constructs a string from buf. More... | |
wxString (const std::string &str) | |
Constructs a string from str using the using the current locale encoding to convert it to Unicode (wxConvLibc). More... | |
wxString (std::string_view str) | |
Constructs a string from str using the using the current locale encoding to convert it to Unicode (wxConvLibc). More... | |
wxString (const std::wstring &str) | |
Constructs a string from str. More... | |
wxString (std::wstring_view str) | |
Constructs a string from str. More... | |
~wxString () | |
String destructor. More... | |
wxString | operator= (const wxString &str) |
Assignment: see the relative wxString constructor. More... | |
wxString | operator= (wxUniChar c) |
Assignment: see the relative wxString constructor. More... | |
String length | |
size_t | Len () const |
Returns the length of the string. More... | |
size_t | Length () const |
Returns the length of the string (same as Len). More... | |
bool | IsEmpty () const |
Returns true if the string is empty. More... | |
bool | IsNull () const |
Returns true if the string is empty (same as wxString::IsEmpty). More... | |
bool | operator! () const |
Empty string is false, so !string will only return true if the string is empty. More... | |
Character access | |
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 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 debug builds, but no checks are done in release builds. | |
wxUniChar | GetChar (size_t n) const |
Returns the character at position n (read-only). More... | |
const wxCStrData | GetData () const |
wxWidgets compatibility conversion. More... | |
wxUniCharRef | GetWritableChar (size_t n) |
Returns a reference to the character at position n. More... | |
void | SetChar (size_t n, wxUniChar ch) |
Sets the character at position n. More... | |
wxUniChar | Last () const |
Returns the last character. More... | |
wxUniCharRef | Last () |
Returns a reference to the last character (writable). More... | |
wxUniChar | operator[] (size_t i) const |
Returns the i-th character of the string. More... | |
wxUniCharRef | operator[] (size_t i) |
Returns a writable reference to the i-th character of the string. More... | |
Conversions | |
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. | |
wxCStrData | c_str () const |
Returns a lightweight intermediate class which is in turn implicitly convertible to both const char* and to const wchar_t* . More... | |
wxWritableCharBuffer | char_str (const wxMBConv &conv=wxConvLibc) const |
Returns an object with string data that is implicitly convertible to char* pointer. More... | |
template<typename T > | |
wxCharTypeBuffer< T > | tchar_str (size_t *len=nullptr) const |
Returns buffer of the specified type containing the string data. More... | |
const TYPE | fn_str () const |
Returns a string representation suitable for passing to OS' functions for file handling. More... | |
const wxCharBuffer | mb_str (const wxMBConv &conv=wxConvLibc) const |
Returns the multibyte (C string) representation of the string using conv's wxMBConv::cWC2MB method and returns wxCharBuffer. More... | |
const wxScopedCharBuffer | utf8_str () const |
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. More... | |
const std::string | utf8_string () const |
Return the string as an std::string using UTF-8 encoding. More... | |
const wxWX2WCbuf | wc_str () const |
Returns the strings contents as a wide character string. More... | |
std::wstring | wc_string () const |
Returns the strings contents as a wide character string. More... | |
wxWritableWCharBuffer | wchar_str () const |
Returns an object with string data that is implicitly convertible to char* pointer. More... | |
const wxStringCharType * | wx_str () const |
Explicit conversion to C string in the internal representation (either wchar_t* or UTF-8-encoded char*, depending on the build). More... | |
const wxScopedCharBuffer | To8BitData () const |
Converts the string to an 8-bit string in ISO-8859-1 encoding in the form of a wxCharBuffer. More... | |
const wxCharBuffer | ToAscii (char replaceWith='_') const |
Converts the string to an ASCII, 7-bit string. More... | |
std::string | ToStdString (const wxMBConv &conv=wxConvLibc) const |
Return the string as a std::string using conv's wxMBConv::cWC2MB method. More... | |
std::wstring | ToStdWstring () const |
Return the string as a std::wstring. More... | |
const wxScopedCharBuffer | ToUTF8 () const |
Same as utf8_str(). More... | |
Substring extraction | |
wxString | Mid (size_t first, size_t nCount=wxString::npos) const |
Returns a substring starting at first, with length count, or the rest of the string if count is the default value. More... | |
wxString | SubString (size_t from, size_t to) const |
Returns the part of the string between the indices from and to inclusive. More... | |
wxString | operator() (size_t start, size_t len) const |
Same as Mid() (substring extraction). More... | |
wxString | Left (size_t count) const |
Returns the first count characters of the string. More... | |
wxString | Right (size_t count) const |
Returns the last count characters. More... | |
wxString | AfterFirst (wxUniChar ch) const |
Gets all the characters after the first occurrence of ch. More... | |
wxString | AfterLast (wxUniChar ch) const |
Gets all the characters after the last occurrence of ch. More... | |
wxString | BeforeFirst (wxUniChar ch, wxString *rest=nullptr) const |
Gets all characters before the first occurrence of ch. More... | |
wxString | BeforeLast (wxUniChar ch, wxString *rest=nullptr) const |
Gets all characters before the last occurrence of ch. More... | |
Case conversion | |
wxString | Capitalize () const |
Return the copy of the string with the first string character in the upper case and the subsequent ones in the lower case. More... | |
wxString | Lower () const |
Returns this string converted to the lower case. More... | |
void | LowerCase () |
Same as MakeLower. More... | |
wxString & | MakeCapitalized () |
Converts the first characters of the string to the upper case and all the subsequent ones to the lower case and returns the result. More... | |
wxString & | MakeLower () |
Converts all characters to lower case and returns the reference to the modified string. More... | |
wxString & | MakeUpper () |
Converts all characters to upper case and returns the reference to the modified string. More... | |
wxString | Upper () const |
Returns this string converted to upper case. More... | |
void | UpperCase () |
The same as MakeUpper(). More... | |
Searching and replacing | |
int | Find (wxUniChar ch, bool fromEnd=false) const |
Searches for the given character ch. More... | |
int | Find (const wxString &sub) const |
Searches for the given string sub. More... | |
int | First (wxUniChar ch) const |
Same as Find(). More... | |
int | First (const wxString &str) const |
Same as Find(). More... | |
size_t | Replace (const wxString &strOld, const wxString &strNew, bool replaceAll=true) |
Replace first (or all) occurrences of substring with another one. More... | |
Conversion to numbers | |
The string provides functions for conversion to signed and unsigned integer and floating point numbers. All functions take a pointer to the variable to put the numeric value in and return true if the 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. | |
bool | ToDouble (double *val) const |
Attempts to convert the string to a floating point number. More... | |
bool | ToCDouble (double *val) const |
Variant of ToDouble(), always working in "C" locale. More... | |
bool | ToInt (int *val, int base=10) const |
Works like ToLong() but for signed integers. More... | |
bool | ToUInt (unsigned int *val, int base=10) const |
Works like ToULong() but for unsigned integers. More... | |
bool | ToLong (long *val, int base=10) const |
Attempts to convert the string to a signed integer in base base. More... | |
bool | ToCLong (long *val, int base=10) const |
Variant of ToLong() always working in "C" locale. More... | |
bool | ToLongLong (wxLongLong_t *val, int base=10) const |
This is exactly the same as ToLong() but works with 64 bit integer numbers. More... | |
bool | ToULong (unsigned long *val, int base=10) const |
Attempts to convert the string to an unsigned integer in base base. More... | |
bool | ToCULong (unsigned long *val, int base=10) const |
Variant of ToULong() always working in "C" locale. More... | |
bool | ToULongLong (wxULongLong_t *val, int base=10) const |
This is exactly the same as ToULong() but works with 64 bit integer numbers. More... | |
Formatting and printing | |
int | Printf (const wxString &pszFormat,...) |
Similar to the standard function sprintf(). More... | |
int | PrintfV (const wxString &pszFormat, va_list argPtr) |
Similar to vprintf. More... | |
Memory management | |
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 with some external API which requires the caller to provide a writable buffer. See also the | |
bool | Alloc (size_t nLen) |
Preallocate enough space for wxString to store nLen characters. More... | |
bool | Shrink () |
Minimizes the string's memory. More... | |
wxString | Clone () const |
Returns a copy of the string. More... | |
void | Clear () |
Clears the string's content, setting its length to zero. More... | |
Miscellaneous | |
bool | Contains (const wxString &str) const |
Returns true if target appears anywhere in wxString; else false. More... | |
void | Empty () |
This is a synonym for Clear(). More... | |
int | Freq (wxUniChar ch) const |
Returns the number of occurrences of ch in the string. More... | |
bool | IsAscii () const |
Returns true if the string contains only ASCII characters. More... | |
bool | IsNumber () const |
Returns true if the string is an integer (with possible sign). More... | |
bool | IsWord () const |
Returns true if the string is a word. More... | |
wxString & | Pad (size_t count, wxUniChar chPad=' ', bool fromRight=true) |
Adds count copies of chPad to the beginning, or to the end of the string (the default). More... | |
wxString & | Remove (size_t pos) |
Removes all characters from the string starting at pos. More... | |
wxString & | Remove (size_t pos, size_t len) |
Removes len characters from the string, starting at pos. More... | |
wxString & | RemoveLast (size_t n=1) |
Removes the last character. More... | |
wxString | Strip (stripType s=trailing) const |
Strip characters at the front and/or end. More... | |
wxString & | Trim (bool fromRight=true) |
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). More... | |
wxString & | Truncate (size_t len) |
Truncate the string to the given length. More... | |
Iterator interface | |
These methods return iterators to the beginning or end of the string. Please see any STL reference (e.g. http://www.cppreference.com/wiki/string/start) for their documentation. | |
const_iterator | begin () const |
iterator | begin () |
const_iterator | cbegin () const |
const_iterator | end () const |
iterator | end () |
const_iterator | cend () const |
const_reverse_iterator | rbegin () const |
reverse_iterator | rbegin () |
const_reverse_iterator | crbegin () const |
const_reverse_iterator | rend () const |
reverse_iterator | rend () |
const_reverse_iterator | crend () const |
STL interface | |
The supported STL functions are listed here. Please see any STL reference (e.g. http://www.cppreference.com/wiki/string/start) for their documentation. | |
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) |
bool | starts_with (const wxString &str) const |
bool | starts_with (const char *sz) const |
bool | starts_with (const wchar_t *sz) const |
bool | ends_with (const wxString &str) const |
bool | ends_with (const char *sz) const |
bool | ends_with (const wchar_t *sz) const |
Static Public Member Functions | |
static wxString | Format (const wxString &format,...) |
This static function returns the string containing the result of calling Printf() with the passed parameters on it. More... | |
static wxString | FormatV (const wxString &format, va_list argptr) |
This static function returns the string containing the result of calling PrintfV() with the passed parameters on it. More... | |
static wxString | FromCDouble (double val, int precision=-1) |
Returns a string with the textual representation of the number in C locale. More... | |
static wxString | FromDouble (double val, int precision=-1) |
Returns a string with the textual representation of the number. More... | |
static wxString | From8BitData (const char *buf, size_t len) |
Converts given buffer of binary data from 8-bit string to wxString. More... | |
static wxString | From8BitData (const char *buf) |
Converts given buffer of binary data from 8-bit string to wxString. More... | |
static wxString | FromAscii (const char *s) |
Converts the string or character from an ASCII, 7-bit form to the native wxString representation. More... | |
static wxString | FromAscii (const unsigned char *s) |
Converts the string or character from an ASCII, 7-bit form to the native wxString representation. More... | |
static wxString | FromAscii (const char *s, size_t len) |
Converts the string or character from an ASCII, 7-bit form to the native wxString representation. More... | |
static wxString | FromAscii (const unsigned char *s, size_t len) |
Converts the string or character from an ASCII, 7-bit form to the native wxString representation. More... | |
static wxString | FromAscii (char c) |
Converts the string or character from an ASCII, 7-bit form to the native wxString representation. More... | |
static wxString | FromUTF8 (const char *s) |
Converts C string encoded in UTF-8 to wxString. More... | |
static wxString | FromUTF8 (const char *s, size_t len) |
Converts C string encoded in UTF-8 to wxString. More... | |
static wxString | FromUTF8 (const std::string &s) |
Converts C string encoded in UTF-8 to wxString. More... | |
static wxString | FromUTF8 (std::string_view s) |
Converts C string encoded in UTF-8 to wxString. More... | |
static wxString | FromUTF8Unchecked (const char *s) |
Converts C string encoded in UTF-8 to wxString without checking its validity. More... | |
static wxString | FromUTF8Unchecked (const char *s, size_t len) |
Converts C string encoded in UTF-8 to wxString without checking its validity. More... | |
static wxString | FromUTF8Unchecked (const std::string &s) |
Converts C string encoded in UTF-8 to wxString without checking its validity. More... | |
static wxString | FromUTF8Unchecked (std::string_view s) |
Converts C string encoded in UTF-8 to wxString without checking its validity. More... | |
Static Public Attributes | |
static const size_t | npos |
An 'invalid' value for string index. More... | |
Friends | |
bool | operator== (const wxUniChar &c, const wxString &s) |
Comparison operators char types. More... | |
bool | operator== (const wxUniCharRef &c, const wxString &s) |
Comparison operators char types. More... | |
bool | operator== (char c, const wxString &s) |
Comparison operators char types. More... | |
bool | operator== (wchar_t c, const wxString &s) |
Comparison operators char types. More... | |
bool | operator== (int c, const wxString &s) |
Comparison operators char types. More... | |
bool | operator== (const wxString &s, const wxUniChar &c) |
Comparison operators char types. More... | |
bool | operator== (const wxString &s, const wxUniCharRef &c) |
Comparison operators char types. More... | |
bool | operator== (const wxString &s, char c) |
Comparison operators char types. More... | |
bool | operator== (const wxString &s, wchar_t c) |
Comparison operators char types. More... | |
bool | operator!= (const wxUniChar &c, const wxString &s) |
Comparison operators char types. More... | |
bool | operator!= (const wxUniCharRef &c, const wxString &s) |
Comparison operators char types. More... | |
bool | operator!= (char c, const wxString &s) |
Comparison operators char types. More... | |
bool | operator!= (wchar_t c, const wxString &s) |
Comparison operators char types. More... | |
bool | operator!= (int c, const wxString &s) |
Comparison operators char types. More... | |
bool | operator!= (const wxString &s, const wxUniChar &c) |
Comparison operators char types. More... | |
bool | operator!= (const wxString &s, const wxUniCharRef &c) |
Comparison operators char types. More... | |
bool | operator!= (const wxString &s, char c) |
Comparison operators char types. More... | |
bool | operator!= (const wxString &s, wchar_t c) |
Comparison operators char types. More... | |
typedef wxUniChar wxString::char_type |
typedef const wxChar* wxString::const_pointer |
typedef wxUniChar wxString::const_reference |
typedef wxChar* wxString::pointer |
typedef wxUniCharRef wxString::reference |
typedef size_t wxString::size_type |
typedef wxUniChar wxString::value_type |
wxString::wxString | ( | ) |
Default constructor.
wxString::wxString | ( | const wxString & | stringSrc | ) |
Creates a string from another string.
Just increases the ref count by 1.
wxString::wxString | ( | wxUniChar | ch, |
size_t | nRepeat = 1 |
||
) |
Construct a string consisting of nRepeat copies of ch.
wxString::wxString | ( | wxUniCharRef | ch, |
size_t | nRepeat = 1 |
||
) |
Construct a string consisting of nRepeat copies of ch.
wxString::wxString | ( | char | ch, |
size_t | nRepeat = 1 |
||
) |
Construct a string consisting of nRepeat copies of ch converted to Unicode using the current locale encoding.
wxString::wxString | ( | wchar_t | ch, |
size_t | nRepeat = 1 |
||
) |
Construct a string consisting of nRepeat copies of ch.
wxString::wxString | ( | const char * | psz | ) |
Constructs a string from the string literal psz using the current locale encoding to convert it to Unicode (wxConvLibc).
wxString::wxString | ( | const char * | psz, |
const wxMBConv & | conv | ||
) |
Constructs a string from the string literal psz using conv to convert it Unicode.
wxString::wxString | ( | const char * | psz, |
size_t | nLength | ||
) |
Constructs a string from the first nLength bytes of the string literal psz using the current locale encoding to convert it to Unicode (wxConvLibc).
wxString::wxString | ( | const char * | psz, |
const wxMBConv & | conv, | ||
size_t | nLength | ||
) |
Constructs a string from the first nLength bytes of the string literal psz using conv to convert it Unicode.
wxString::wxString | ( | const wchar_t * | pwz | ) |
Constructs a string from the string literal pwz.
wxString::wxString | ( | const wchar_t * | pwz, |
size_t | nLength | ||
) |
Constructs a string from the first nLength characters of the string literal pwz.
wxString::wxString | ( | const wxCharBuffer & | buf | ) |
Constructs a string from buf using the using the current locale encoding to convert it to Unicode.
wxString::wxString | ( | const wxWCharBuffer & | buf | ) |
Constructs a string from buf.
wxString::wxString | ( | const std::string & | str | ) |
Constructs a string from str using the using the current locale encoding to convert it to Unicode (wxConvLibc).
wxString::wxString | ( | std::string_view | str | ) |
Constructs a string from str using the using the current locale encoding to convert it to Unicode (wxConvLibc).
wxString::wxString | ( | const std::wstring & | str | ) |
Constructs a string from str.
wxString::wxString | ( | std::wstring_view | str | ) |
Constructs a string from str.
wxString::~wxString | ( | ) |
String destructor.
Note that this is not virtual, so wxString must not be inherited from.
Gets all the characters after the first occurrence of ch.
Returns the empty string if ch is not found.
Gets all the characters after the last occurrence of ch.
Returns the whole string if ch is not found.
bool wxString::Alloc | ( | size_t | nLen | ) |
Preallocate enough space for wxString to store nLen characters.
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
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 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 nLen.
wxString& wxString::Append | ( | const char * | psz | ) |
Appends the string literal psz.
wxString& wxString::Append | ( | const char * | psz, |
size_t | nLen | ||
) |
Appends the string literal psz with max length nLen.
wxString& wxString::append | ( | const char * | sz, |
size_t | n | ||
) |
wxString& wxString::Append | ( | const wchar_t * | pwz | ) |
Appends the wide string literal pwz.
wxString& wxString::Append | ( | const wchar_t * | pwz, |
size_t | nLen | ||
) |
Appends the wide string literal psz with max length nLen.
wxString& wxString::append | ( | const wchar_t * | sz, |
size_t | n | ||
) |
wxString& wxString::append | ( | const_iterator | first, |
const_iterator | last | ||
) |
Appends the character ch count times.
wxString& wxString::assign | ( | const char * | sz, |
size_t | n | ||
) |
wxString& wxString::assign | ( | const wchar_t * | sz, |
size_t | n | ||
) |
wxString& wxString::assign | ( | const_iterator | first, |
const_iterator | last | ||
) |
wxUniCharRef wxString::at | ( | size_t | n | ) |
wxUniChar wxString::at | ( | size_t | n | ) | const |
Gets all characters before the first occurrence of ch.
Returns the whole string if ch is not found.
ch | The character to look for. |
rest | Filled with the part of the string following the first occurrence of 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. |
Gets all characters before the last occurrence of ch.
Returns the empty string if ch is not found.
ch | The character to look for. |
rest | Filled with the part of the string following the last occurrence of 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. |
iterator wxString::begin | ( | ) |
const_iterator wxString::begin | ( | ) | const |
wxCStrData wxString::c_str | ( | ) | const |
Returns a lightweight intermediate class which is in turn implicitly convertible to both const
char*
and to const
wchar_t*
.
Given this ambiguity it is mostly better to use wc_str(), mb_str() or utf8_str() instead.
Please see the Unicode Support in wxWidgets for more information about it.
Note that the returned value is not convertible to char*
or wchar_t*
, use char_str() or wchar_str() if you need to pass string value to a function expecting non-const pointer.
size_type wxString::capacity | ( | ) | const |
wxString wxString::Capitalize | ( | ) | const |
Return the copy of the string with the first string character in the upper case and the subsequent ones in the lower case.
const_iterator wxString::cbegin | ( | ) | const |
const_iterator wxString::cend | ( | ) | const |
wxWritableCharBuffer wxString::char_str | ( | const wxMBConv & | conv = wxConvLibc | ) | const |
Returns an object with string data that is implicitly convertible to 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.
void wxString::Clear | ( | ) |
void wxString::clear | ( | ) |
wxString wxString::Clone | ( | ) | const |
Returns a copy of the string.
This method is obsolete as wxString doesn't use reference-counted implementation any longer and so all string copies are deep and assignment operator or copy constructor can be used instead of this function.
int wxString::Cmp | ( | const wxString & | s | ) | const |
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 strcmp()
function).
int wxString::CmpNoCase | ( | 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 strcmp()
function).
int wxString::compare | ( | const wxString & | str | ) | const |
int wxString::compare | ( | size_t | nStart, |
size_t | nLen, | ||
const char * | sz, | ||
size_t | nCount = npos |
||
) | const |
int wxString::compare | ( | size_t | nStart, |
size_t | nLen, | ||
const wchar_t * | sz, | ||
size_t | nCount = npos |
||
) | const |
int wxString::compare | ( | size_t | nStart, |
size_t | nLen, | ||
const wxString & | str | ||
) | const |
int wxString::compare | ( | size_t | nStart, |
size_t | nLen, | ||
const wxString & | str, | ||
size_t | nStart2, | ||
size_t | nLen2 | ||
) | const |
bool wxString::Contains | ( | const wxString & | str | ) | const |
Returns true if target appears anywhere in wxString; else false.
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
const_reverse_iterator wxString::crbegin | ( | ) | const |
const_reverse_iterator wxString::crend | ( | ) | const |
wxCStrData wxString::data | ( | ) | const |
void wxString::Empty | ( | ) |
bool wxString::empty | ( | ) | const |
iterator wxString::end | ( | ) |
const_iterator wxString::end | ( | ) | const |
bool wxString::ends_with | ( | const char * | sz | ) | const |
bool wxString::ends_with | ( | const wchar_t * | sz | ) | const |
bool wxString::ends_with | ( | const wxString & | str | ) | const |
This function can be used to test if the string ends with the specified suffix.
If it does, the function will return true and put the beginning of the string before the suffix into rest string if it is not nullptr. Otherwise, the function returns false and doesn't modify the rest.
iterator wxString::erase | ( | iterator | first | ) |
iterator wxString::erase | ( | iterator | first, |
iterator | last | ||
) |
size_t wxString::find | ( | const char * | sz, |
size_t | nStart = 0 , |
||
size_t | n = npos |
||
) | const |
size_t wxString::find | ( | const wchar_t * | sz, |
size_t | nStart = 0 , |
||
size_t | n = npos |
||
) | const |
size_t wxString::find | ( | const wxString & | str, |
size_t | nStart = 0 |
||
) | const |
int wxString::Find | ( | const wxString & | sub | ) | const |
Searches for the given string sub.
Returns the starting position or wxNOT_FOUND
if not found.
int wxString::Find | ( | wxUniChar | ch, |
bool | fromEnd = false |
||
) | const |
Searches for the given character ch.
Returns the position or wxNOT_FOUND
if not found.
size_t wxString::find | ( | wxUniChar | ch, |
size_t | nStart = 0 |
||
) | const |
size_t wxString::find_first_not_of | ( | const char * | sz, |
size_t | nStart, | ||
size_t | n | ||
) | const |
size_t wxString::find_first_not_of | ( | const char * | sz, |
size_t | nStart = 0 |
||
) | const |
size_t wxString::find_first_not_of | ( | const wchar_t * | sz, |
size_t | nStart, | ||
size_t | n | ||
) | const |
size_t wxString::find_first_not_of | ( | const wchar_t * | sz, |
size_t | nStart = 0 |
||
) | const |
size_t wxString::find_first_not_of | ( | const wxString & | str, |
size_t | nStart = 0 |
||
) | const |
size_t wxString::find_first_not_of | ( | wxUniChar | ch, |
size_t | nStart = 0 |
||
) | const |
size_t wxString::find_first_of | ( | const char * | sz, |
size_t | nStart, | ||
size_t | n | ||
) | const |
size_t wxString::find_first_of | ( | const char * | sz, |
size_t | nStart = 0 |
||
) | const |
size_t wxString::find_first_of | ( | const wchar_t * | sz, |
size_t | nStart, | ||
size_t | n | ||
) | const |
size_t wxString::find_first_of | ( | const wchar_t * | sz, |
size_t | nStart = 0 |
||
) | const |
size_t wxString::find_first_of | ( | wxUniChar | c, |
size_t | nStart = 0 |
||
) | const |
size_t wxString::find_last_not_of | ( | const char * | sz, |
size_t | nStart, | ||
size_t | n | ||
) | const |
size_t wxString::find_last_not_of | ( | const char * | sz, |
size_t | nStart = npos |
||
) | const |
size_t wxString::find_last_not_of | ( | const wchar_t * | sz, |
size_t | nStart, | ||
size_t | n | ||
) | const |
size_t wxString::find_last_not_of | ( | const wchar_t * | sz, |
size_t | nStart = npos |
||
) | const |
size_t wxString::find_last_of | ( | const char * | sz, |
size_t | nStart, | ||
size_t | n | ||
) | const |
size_t wxString::find_last_of | ( | const char * | sz, |
size_t | nStart = npos |
||
) | const |
size_t wxString::find_last_of | ( | const wchar_t * | sz, |
size_t | nStart, | ||
size_t | n | ||
) | const |
size_t wxString::find_last_of | ( | const wchar_t * | sz, |
size_t | nStart = npos |
||
) | const |
int wxString::First | ( | const wxString & | str | ) | const |
Same as Find().
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
int wxString::First | ( | wxUniChar | ch | ) | const |
Same as Find().
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
const TYPE wxString::fn_str | ( | ) | const |
Returns a string representation suitable for passing to OS' functions for file handling.
Depending on OS and configuration, TYPE is either wchar_t*
, char*
, or wxCharBuffer.
int wxString::Freq | ( | wxUniChar | ch | ) | const |
Returns the number of occurrences of ch in the string.
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
|
static |
Converts given buffer of binary data from 8-bit string to wxString.
std::vector<wxUint8>
is both simpler and more efficient than using wxString for storing binary data. See also more specialized classes provided by wxWidgets for working with binary data, such as wxMemoryBuffer and wxMemoryOutputStream and wxMemoryInputStream.In Unicode build, the string is interpreted as being in ISO-8859-1 encoding. The version without len parameter takes NUL-terminated data.
This is a convenience method useful when storing binary data in wxString. It should be used only for that purpose and only in conjunction with To8BitData(). Use mb_str() for conversion of character data to known encoding.
|
static |
Converts given buffer of binary data from 8-bit string to wxString.
std::vector<wxUint8>
is both simpler and more efficient than using wxString for storing binary data. See also more specialized classes provided by wxWidgets for working with binary data, such as wxMemoryBuffer and wxMemoryOutputStream and wxMemoryInputStream.In Unicode build, the string is interpreted as being in ISO-8859-1 encoding. The version without len parameter takes NUL-terminated data.
This is a convenience method useful when storing binary data in wxString. It should be used only for that purpose and only in conjunction with To8BitData(). Use mb_str() for conversion of character data to known encoding.
|
static |
Converts the string or character from an ASCII, 7-bit form to the native wxString representation.
Input must consist only of 7-bit (i.e. less than 128) ASCII characters, the behaviour in presence of non-ASCII characters is undefined but will result in assert failures.
|
static |
Converts the string or character from an ASCII, 7-bit form to the native wxString representation.
Input must consist only of 7-bit (i.e. less than 128) ASCII characters, the behaviour in presence of non-ASCII characters is undefined but will result in assert failures.
|
static |
Converts the string or character from an ASCII, 7-bit form to the native wxString representation.
Input must consist only of 7-bit (i.e. less than 128) ASCII characters, the behaviour in presence of non-ASCII characters is undefined but will result in assert failures.
|
static |
Converts the string or character from an ASCII, 7-bit form to the native wxString representation.
Input must consist only of 7-bit (i.e. less than 128) ASCII characters, the behaviour in presence of non-ASCII characters is undefined but will result in assert failures.
|
static |
Converts the string or character from an ASCII, 7-bit form to the native wxString representation.
Input must consist only of 7-bit (i.e. less than 128) ASCII characters, the behaviour in presence of non-ASCII characters is undefined but will result in assert failures.
|
static |
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 locale. Otherwise its behaviour is identical to the other function.
|
static |
Returns a string with the textual representation of the number.
For the default value of precision, this function behaves as a simple wrapper for
. If precision is positive (or zero), the %
.Nf format is used with the given precision value.
Notice that the string returned by this function uses the decimal separator appropriate for the current locale, e.g. ","
and not a period in French locale. Use FromCDouble() if this is unwanted.
val | The value to format. |
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. |
|
static |
Converts C string encoded in UTF-8 to wxString.
If s is not a valid UTF-8 string, an empty string is returned.
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.
The overload taking std::string
is only available starting with wxWidgets 3.1.1.
The overload taking std::string_view
is only available starting with wxWidgets 3.3.0 and requires the consumer application to use C++17.
|
static |
Converts C string encoded in UTF-8 to wxString.
If s is not a valid UTF-8 string, an empty string is returned.
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.
The overload taking std::string
is only available starting with wxWidgets 3.1.1.
The overload taking std::string_view
is only available starting with wxWidgets 3.3.0 and requires the consumer application to use C++17.
|
static |
Converts C string encoded in UTF-8 to wxString.
If s is not a valid UTF-8 string, an empty string is returned.
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.
The overload taking std::string
is only available starting with wxWidgets 3.1.1.
The overload taking std::string_view
is only available starting with wxWidgets 3.3.0 and requires the consumer application to use C++17.
|
static |
Converts C string encoded in UTF-8 to wxString.
If s is not a valid UTF-8 string, an empty string is returned.
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.
The overload taking std::string
is only available starting with wxWidgets 3.1.1.
The overload taking std::string_view
is only available starting with wxWidgets 3.3.0 and requires the consumer application to use C++17.
|
static |
Converts C string encoded in UTF-8 to wxString without checking its validity.
This method assumes that 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 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.
The overload taking std::string
is only available starting with wxWidgets 3.1.1.
The overload taking std::string_view
is only available starting with wxWidgets 3.3.0 and requires the consumer application to use C++17.
|
static |
Converts C string encoded in UTF-8 to wxString without checking its validity.
This method assumes that 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 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.
The overload taking std::string
is only available starting with wxWidgets 3.1.1.
The overload taking std::string_view
is only available starting with wxWidgets 3.3.0 and requires the consumer application to use C++17.
|
static |
Converts C string encoded in UTF-8 to wxString without checking its validity.
This method assumes that 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 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.
The overload taking std::string
is only available starting with wxWidgets 3.1.1.
The overload taking std::string_view
is only available starting with wxWidgets 3.3.0 and requires the consumer application to use C++17.
|
static |
Converts C string encoded in UTF-8 to wxString without checking its validity.
This method assumes that 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 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.
The overload taking std::string
is only available starting with wxWidgets 3.1.1.
The overload taking std::string_view
is only available starting with wxWidgets 3.3.0 and requires the consumer application to use C++17.
wxUniChar wxString::GetChar | ( | size_t | n | ) | const |
Returns the character at position n (read-only).
const wxCStrData wxString::GetData | ( | ) | const |
wxWidgets compatibility conversion.
Same as c_str().
wxUniCharRef wxString::GetWritableChar | ( | size_t | n | ) |
Returns a reference to the character at position n.
void wxString::insert | ( | iterator | it, |
const_iterator | first, | ||
const_iterator | last | ||
) |
iterator wxString::insert | ( | iterator | it, |
wxUniChar | ch | ||
) |
wxString& wxString::insert | ( | size_t | nPos, |
const char * | sz, | ||
size_t | n | ||
) |
wxString& wxString::insert | ( | size_t | nPos, |
const wchar_t * | sz, | ||
size_t | n | ||
) |
bool wxString::IsAscii | ( | ) | const |
Returns true if the string contains only ASCII characters.
See wxUniChar::IsAscii for more details.
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
bool wxString::IsEmpty | ( | ) | const |
Returns true if the string is empty.
bool wxString::IsNull | ( | ) | const |
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.
bool wxString::IsNumber | ( | ) | const |
Returns true if the string is an integer (with possible sign).
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
bool wxString::IsSameAs | ( | const wxString & | s, |
bool | caseSensitive = true |
||
) | const |
Test whether the string is equal to another string s.
The test is case-sensitive if caseSensitive is true (default) or not if it is false.
bool wxString::IsSameAs | ( | wxUniChar | ch, |
bool | caseSensitive = true |
||
) | const |
Test whether the string is equal to the single character ch.
The test is case-sensitive if caseSensitive is true (default) or not if it is false.
bool wxString::IsWord | ( | ) | const |
Returns true if the string is a word.
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
wxUniCharRef wxString::Last | ( | ) |
Returns a reference to the last character (writable).
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
wxUniChar wxString::Last | ( | ) | const |
Returns the last character.
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
wxString wxString::Left | ( | size_t | count | ) | const |
Returns the first count characters of the string.
size_t wxString::Len | ( | ) | const |
Returns the length of the string.
size_t wxString::Length | ( | ) | const |
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.
size_t wxString::length | ( | ) | const |
wxString wxString::Lower | ( | ) | const |
Returns this string converted to the lower case.
void wxString::LowerCase | ( | ) |
Same as MakeLower.
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
wxString& wxString::MakeCapitalized | ( | ) |
Converts the first characters of the string to the upper case and all the subsequent ones to the lower case and returns the result.
wxString& wxString::MakeLower | ( | ) |
Converts all characters to lower case and returns the reference to the modified string.
wxString& wxString::MakeUpper | ( | ) |
Converts all characters to upper case and returns the reference to the modified string.
bool wxString::Matches | ( | const wxString & | mask | ) | const |
Returns true if the string contents matches a mask containing '*' and '?'.
size_type wxString::max_size | ( | ) | const |
const wxCharBuffer wxString::mb_str | ( | const wxMBConv & | conv = wxConvLibc | ) | const |
Returns the multibyte (C string) representation of the string using conv's wxMBConv::cWC2MB method and returns wxCharBuffer.
wxString wxString::Mid | ( | size_t | first, |
size_t | nCount = wxString::npos |
||
) | const |
Returns a substring starting at first, with length count, or the rest of the string if count is the default value.
bool wxString::operator! | ( | ) | const |
Empty string is false, so !string will only return true if the string is empty.
wxString wxString::operator() | ( | size_t | start, |
size_t | len | ||
) | const |
Same as Mid() (substring extraction).
void wxString::operator+= | ( | const wxString & | str | ) |
Concatenation in place: the argument is appended to the string.
void wxString::operator+= | ( | wxUniChar | c | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
wxString& wxString::operator<< | ( | char | ch | ) |
Appends the string literal psz.
wxString& wxString::operator<< | ( | const char * | psz | ) |
Appends the string literal psz.
wxString& wxString::operator<< | ( | const wchar_t * | pwz | ) |
Appends the string literal psz.
wxString& wxString::operator<< | ( | const wxCharBuffer & | s | ) |
Appends the string literal psz.
wxString& wxString::operator<< | ( | const wxCStrData & | psz | ) |
Appends the string literal psz.
wxString& wxString::operator<< | ( | const wxWCharBuffer & | s | ) |
Appends the string literal psz.
wxString& wxString::operator<< | ( | double | d | ) |
Appends the string literal psz.
wxString& wxString::operator<< | ( | float | f | ) |
Appends the string literal psz.
wxString& wxString::operator<< | ( | long | l | ) |
Appends the string literal psz.
wxString& wxString::operator<< | ( | unsigned char | ch | ) |
Appends the string literal psz.
wxString& wxString::operator<< | ( | unsigned int | ui | ) |
Appends the string literal psz.
wxString& wxString::operator<< | ( | unsigned long | ul | ) |
Appends the string literal psz.
wxString& wxString::operator<< | ( | wchar_t | ch | ) |
Appends the string literal psz.
wxString& wxString::operator<< | ( | wxLongLong_t | ll | ) |
Appends the string literal psz.
wxString& wxString::operator<< | ( | wxULongLong_t | ul | ) |
Appends the string literal psz.
wxString& wxString::operator<< | ( | wxUniCharRef | ch | ) |
Appends the string literal psz.
Assignment: see the relative wxString constructor.
wxUniCharRef wxString::operator[] | ( | size_t | i | ) |
Returns a writable reference to the i-th character of the string.
wxUniChar wxString::operator[] | ( | size_t | i | ) | const |
Returns the i-th character of the string.
Adds count copies of chPad to the beginning, or to the end of the string (the default).
By default, appends the given number of spaces to the string. The character being added and whether it is appended or prepended can be changed by providing non-default parameter values.
Prepends str to this string, returning a reference to this string.
int wxString::Printf | ( | const wxString & | pszFormat, |
... | |||
) |
Similar to the standard function sprintf().
Returns the number of characters written, or an integer less than zero on error. Note that if wxUSE_PRINTF_POS_PARAMS
is set to 1, then this function supports Unix98-style positional parameters:
int wxString::PrintfV | ( | const wxString & | pszFormat, |
va_list | argPtr | ||
) |
Similar to vprintf.
Returns the number of characters written, or an integer less than zero on error.
reverse_iterator wxString::rbegin | ( | ) |
const_reverse_iterator wxString::rbegin | ( | ) | const |
wxString& wxString::Remove | ( | size_t | pos | ) |
Removes all characters from the string starting at pos.
Use Truncate() as a more readable alternative.
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
wxString& wxString::Remove | ( | size_t | pos, |
size_t | len | ||
) |
Removes len characters from the string, starting at pos.
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
wxString& wxString::RemoveLast | ( | size_t | n = 1 | ) |
Removes the last character.
reverse_iterator wxString::rend | ( | ) |
const_reverse_iterator wxString::rend | ( | ) | const |
size_t wxString::Replace | ( | const wxString & | strOld, |
const wxString & | strNew, | ||
bool | replaceAll = true |
||
) |
Replace first (or all) occurrences of substring with another one.
strOld | The string to search for replacing. |
strNew | The substitution string. |
replaceAll | If true a global replace will be done (default), otherwise only the first occurrence will be replaced. |
Returns the number of replacements made.
wxString& wxString::replace | ( | iterator | first, |
iterator | last, | ||
const char * | first1, | ||
const char * | last1 | ||
) |
wxString& wxString::replace | ( | iterator | first, |
iterator | last, | ||
const wchar_t * | first1, | ||
const wchar_t * | last1 | ||
) |
wxString& wxString::replace | ( | iterator | first, |
iterator | last, | ||
const_iterator | first1, | ||
const_iterator | last1 | ||
) |
wxString& wxString::replace | ( | size_t | nStart, |
size_t | nLen, | ||
const char * | sz, | ||
size_t | nCount | ||
) |
wxString& wxString::replace | ( | size_t | nStart, |
size_t | nLen, | ||
const wchar_t * | sz, | ||
size_t | nCount | ||
) |
wxString& wxString::replace | ( | size_t | nStart, |
size_t | nLen, | ||
const wxString & | str, | ||
size_t | nStart2, | ||
size_t | nLen2 | ||
) |
void wxString::reserve | ( | size_t | sz | ) |
void wxString::resize | ( | size_t | nSize, |
wxUniChar | ch = '\0' |
||
) |
wxString wxString::Right | ( | size_t | count | ) | const |
Returns the last count characters.
void wxString::SetChar | ( | size_t | n, |
wxUniChar | ch | ||
) |
Sets the character at position n.
bool wxString::Shrink | ( | ) |
Minimizes the string's memory.
Please note that this method does the same thing as the standard shrink_to_fit() one and shouldn't be used in new code.
This can be useful after a call to Alloc() if too much memory were preallocated.
size_type wxString::size | ( | ) | const |
bool wxString::starts_with | ( | const char * | sz | ) | const |
bool wxString::starts_with | ( | const wchar_t * | sz | ) | const |
bool wxString::starts_with | ( | const wxString & | str | ) | const |
This function can be used to test if the string starts with the specified prefix.
If it does, the function will return true and put the rest of the string (i.e. after the prefix) into rest string if it is not nullptr. Otherwise, the function returns false and doesn't modify the rest.
wxString wxString::Strip | ( | stripType | s = trailing | ) | const |
Strip characters at the front and/or end.
This is the same as Trim() except that it doesn't change this string.
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
wxString wxString::SubString | ( | size_t | from, |
size_t | to | ||
) | const |
Returns the part of the string between the indices from and to inclusive.
This is a wxWidgets 1.xx compatibility function, use Mid() instead (but note that parameters have different meaning).
void wxString::swap | ( | wxString & | str | ) |
wxCharTypeBuffer<T> wxString::tchar_str | ( | size_t * | len = nullptr | ) | const |
Returns buffer of the specified type containing the string data.
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 t should be either char
or wchar_t
.
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).
len | If non-null, filled with the length of the returned buffer. |
char
). const wxScopedCharBuffer wxString::To8BitData | ( | ) | const |
Converts the string to an 8-bit string in ISO-8859-1 encoding in the form of a wxCharBuffer.
This is a convenience method useful when storing binary data in wxString. It should be used only for this purpose. It is only valid to call this method on strings created using From8BitData().
const wxCharBuffer wxString::ToAscii | ( | char | replaceWith = '_' | ) | const |
Converts the string to an ASCII, 7-bit string.
Note that this conversion is only lossless if the string contains only ASCII characters as all the non-ASCII ones are replaced with the (same) provided replacement character.
Use mb_str() or utf8_str() to convert to other encodings.
replaceWith | The character used to replace any non-ASCII characters, default to underscore ("_" ). This parameter is new since wxWidgets 3.1.0. |
bool wxString::ToCDouble | ( | double * | val | ) | const |
Variant of ToDouble(), always working in "C" locale.
Works like ToDouble(), but 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).
bool wxString::ToCLong | ( | long * | val, |
int | base = 10 |
||
) | const |
Variant of ToLong() always working in "C" locale.
Works like ToLong() but unlike it this function expects the integer number to be formatted always with the rules dictated by the "C" locale, independently from the current application-wide locale (see wxLocale).
bool wxString::ToCULong | ( | unsigned long * | val, |
int | base = 10 |
||
) | const |
Variant of ToULong() always working in "C" locale.
Works like ToULong() but unlike it this function expects the integer number to be formatted always with the rules dictated by the "C" locale, independently from the current application-wide locale (see wxLocale).
bool wxString::ToDouble | ( | double * | val | ) | const |
Attempts to convert the string to a floating point number.
Returns true on success (the number is stored in the location pointed to by val) or false if the string does not represent such number (the value of val may still be modified in this case).
Note that unlike ToCDouble() this function uses a localized version of 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).
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 strtod()
for more details about the supported syntax.
bool wxString::ToInt | ( | int * | val, |
int | base = 10 |
||
) | const |
bool wxString::ToLong | ( | long * | val, |
int | base = 10 |
||
) | const |
Attempts to convert the string to a signed integer in base base.
Returns true on success in which case the number is stored in the location pointed to by val or false if the string does not represent a valid number in the given base (the value of val may still be modified in this case).
The value of base must be comprised between 2 and 36, inclusive, or be a special value 0 which means that the usual rules of C
numbers are applied: if the number starts with 0x
it is considered to be in base 16, if it starts with 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.
Note that unlike ToCLong() this function uses a localized version of wxStrtol()
. Thus you should use this function only when you are sure that this string contains an integer number formatted with the rules of the locale currently in use (see wxLocale).
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 strtol()
for more details about the supported syntax.
bool wxString::ToLongLong | ( | wxLongLong_t * | val, |
int | base = 10 |
||
) | const |
This is exactly the same as ToLong() but works with 64 bit integer numbers.
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.
std::string wxString::ToStdString | ( | const wxMBConv & | conv = wxConvLibc | ) | const |
Return the string as a std::string using conv's wxMBConv::cWC2MB method.
Note that if the conversion of (Unicode) string contents using conv fails, the return string will be empty. Be sure to check for this to avoid silent data loss. Alternatively, pass wxConvUTF8
as conv or use utf8_string() to always use UTF-8 encoding, rather than the current one.
Instead of using this function it's also possible to write
but using ToStdString() may make the code more clear.
conv | The converter to be used. This parameter is new in wxWidgets 3.1.1. |
std::wstring wxString::ToStdWstring | ( | ) | const |
Return the string as a std::wstring.
Unlike ToStdString(), there is no danger of data loss when using this function.
Note that the return type of this function is actually const std::wstring&
in wxWidgets builds using wxUSE_UNICODE_WCHAR==1
(which is the default), i.e. in this build there is no copying of string contents, however a temporary copy of the string is returned in wxUSE_UNICODE_UTF8==1
build.
bool wxString::ToUInt | ( | unsigned int * | val, |
int | base = 10 |
||
) | const |
bool wxString::ToULong | ( | unsigned long * | val, |
int | base = 10 |
||
) | const |
Attempts to convert the string to an unsigned integer in base base.
Returns true on success in which case the number is stored in the location pointed to by val or false if the string does not represent a valid number in the given base (the value of val may still be modified in this case).
Please notice that this function behaves in the same way as the standard strtoul()
and so it simply converts negative numbers to unsigned representation instead of rejecting them (e.g. -1 is returned as ULONG_MAX
).
See ToLong() for the more detailed description of the base parameter (and of the locale-specific behaviour of this function).
bool wxString::ToULongLong | ( | wxULongLong_t * | val, |
int | base = 10 |
||
) | const |
This is exactly the same as ToULong() but works with 64 bit integer numbers.
Please see ToLongLong() for additional remarks.
const wxScopedCharBuffer wxString::ToUTF8 | ( | ) | const |
Same as utf8_str().
wxString& wxString::Trim | ( | bool | fromRight = true | ) |
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).
wxString& wxString::Truncate | ( | size_t | len | ) |
Truncate the string to the given length.
wxString wxString::Upper | ( | ) | const |
Returns this string converted to upper case.
void wxString::UpperCase | ( | ) |
The same as MakeUpper().
This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
const wxScopedCharBuffer wxString::utf8_str | ( | ) | const |
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.
const std::string wxString::utf8_string | ( | ) | const |
Return the string as an std::string using UTF-8 encoding.
This is a shorter and more readable equivalent of calling ToStdString() with wxConvUTF8
argument.
const wxWX2WCbuf wxString::wc_str | ( | ) | const |
Returns the strings contents as a wide character string.
wxWX2WCbuf is macro which can be either wchar_t*
or wxWCharBuffer depending on whether wxUSE_UNICODE_UTF8 is 0 or 1.
std::wstring wxString::wc_string | ( | ) | const |
Returns the strings contents as a wide character string.
This is a somewhat more readable synonym for ToStdWstring().
The return type of this function is actually const std::wstring&
in wxWidgets builds using wxUSE_UNICODE_WCHAR==1
(which is the default), i.e. in this build there is no copying of string contents, however a temporary copy of the string is returned in wxUSE_UNICODE_UTF8==1
build.
wxWritableWCharBuffer wxString::wchar_str | ( | ) | const |
Returns an object with string data that is implicitly convertible to 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.
const wxStringCharType* wxString::wx_str | ( | ) | const |
Explicit conversion to C string in the internal representation (either wchar_t* or UTF-8-encoded char*, depending on the build).
|
friend |
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 strcmp()
function).
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 strcmp()
function).
|
friend |
Comparison operators char types.
|
friend |
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 strcmp()
function).
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 strcmp()
function).
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 strcmp()
function).
|
friend |
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 strcmp()
function).
|
friend |
Comparison operators char types.
|
friend |
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 strcmp()
function).
Concatenation: returns a new string equal to the concatenation of the operands.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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 strcmp()
function).
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 strcmp()
function).
|
friend |
Comparison operators char types.
|
friend |
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 strcmp()
function).
|
friend |
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 strcmp()
function).
|
friend |
Comparison operators char types.
|
friend |
Comparison operators char types.
|
friend |
Comparison operators char types.
|
friend |
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 strcmp()
function).
|
friend |
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 strcmp()
function).
Comparison operator for string types.
|
friend |
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 strcmp()
function).
|
friend |
Comparison operators char types.
|
friend |
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 strcmp()
function).
|
friend |
Comparison operators char types.
|
friend |
Comparison operators char types.
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 strcmp()
function).
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 strcmp()
function).
|
static |
An 'invalid' value for string index.