wxstringwxstring is a class representing a character string. please see the wxstring overview for more information about it. 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. you may notice that wxstring sometimes has many functions which do the same thing like, for example, length(), len() and length() which all return the string length. in all cases of such duplication the std::string-compatible method (length() in this case, always the lowercase version) should be used as it will ensure smoother transition to std::string when wxwidgets starts using it instead of wxstring. derived from none include files <wx/string.h> predefined objects objects: wxemptystring see also wxstring overview, unicode overview function groups
constructors and assignment operators
constructors and assignment operatorsa 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.
string lengththese functions return the string length and check whether the string is empty or empty it.
len
character accessmany functions in this section take a character index in the string. as with c strings and/or arrays, the indices start from 0, so the first character of a string is string[0]. attempt to access a character beyond the end of the string (which may be even 0 if the string is empty) will provoke an assert failure in debug build, but no checks are done in release builds. 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 c_str() method for the sake of clarity. also see overview for the cases where it is necessary to use it.
getchar
concatenationanything 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.
operator <<
comparisonthe 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 may be 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 then.
cmp
substring extractionthese 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.
mid
case conversionthe 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.
makeupper
searching and replacingthese functions replace the standard strchr() and strstr() functions.
conversion to numbersthe 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 entire string could be converted to a number.
tolong
writing values into the stringboth formatted versions (printf) and stream-like insertion operators exist (for basic types only). additionally, the format function allows to use simply append formatted value to a string:
// the following 2 snippets are equivalent wxstring s = "..."; s += wxstring::format("%d", n); wxstring s; s.printf("...%d", n);format formatv printf printfv operator <<
memory managementthese are "advanced" functions and they will be needed quite rarely. alloc and shrink are only interesting for optimization purposes. getwritebuf may be very useful when working with some external api which requires the caller to provide a writable buffer, but extreme care should be taken when using it: before performing any other operation on the string ungetwritebuf must be called!
alloc
miscellaneousother string functions.
wxwidgets 1.xx compatibility functionsthese functions are deprecated, please consider using new wxwidgets 2.0 functions instead of them (or, even better, std::string compatible variants).
compareto
std::string compatibility functionsthe supported functions are only listed here, please see any stl reference for their documentation.
// take nlen chars starting at npos wxstring(const wxstring& str, size_t npos, size_t nlen); // take all characters from pstart to pend (poor man's iterators) wxstring(const void *pstart, const void *pend); // lib.string.capacity // return the length of the string size_t size() const; // return the length of the string size_t length() const; // return the maximum size of the string size_t max_size() const; // resize the string, filling the space with c if c != 0 void resize(size_t nsize, char ch = '\0'); // delete the contents of the string void clear(); // returns true if the string is empty bool empty() const; // lib.string.access // return the character at position n char at(size_t n) const; // returns the writable character at position n char& at(size_t n); // lib.string.modifiers // append a string wxstring& append(const wxstring& str); // append elements str[pos], ..., str[pos+n] wxstring& append(const wxstring& str, size_t pos, size_t n); // append first n (or all if n == npos) characters of sz wxstring& append(const char *sz, size_t n = npos); // append n copies of ch wxstring& append(size_t n, char ch); // same as `this_string = str' wxstring& assign(const wxstring& str); // same as ` = str[pos..pos + n] wxstring& assign(const wxstring& str, size_t pos, size_t n); // same as `= first n (or all if n == npos) characters of sz' wxstring& assign(const char *sz, size_t n = npos); // same as `= n copies of ch' wxstring& assign(size_t n, char ch); // insert another string wxstring& insert(size_t npos, const wxstring& str); // insert n chars of str starting at nstart (in str) wxstring& insert(size_t npos, const wxstring& str, size_t nstart, size_t n); // insert first n (or all if n == npos) characters of sz wxstring& insert(size_t npos, const char *sz, size_t n = npos); // insert n copies of ch wxstring& insert(size_t npos, size_t n, char ch); // delete characters from nstart to nstart + nlen wxstring& erase(size_t nstart = 0, size_t nlen = npos); // replaces the substring of length nlen starting at nstart wxstring& replace(size_t nstart, size_t nlen, const char* sz); // replaces the substring with ncount copies of ch wxstring& replace(size_t nstart, size_t nlen, size_t ncount, char ch); // replaces a substring with another substring wxstring& replace(size_t nstart, size_t nlen, const wxstring& str, size_t nstart2, size_t nlen2); // replaces the substring with first ncount chars of sz wxstring& replace(size_t nstart, size_t nlen, const char* sz, size_t ncount); // swap two strings void swap(wxstring& str); // all find() functions take the nstart argument which specifies the // position to start the search on, the default value is 0. all functions // return npos if there were no match. // find a substring size_t find(const wxstring& str, size_t nstart = 0) const; // find first n characters of sz size_t find(const char* sz, size_t nstart = 0, size_t n = npos) const; // find the first occurrence of character ch after nstart size_t find(char ch, size_t nstart = 0) const; // rfind() family is exactly like find() but works right to left // as find, but from the end size_t rfind(const wxstring& str, size_t nstart = npos) const; // as find, but from the end size_t rfind(const char* sz, size_t nstart = npos, size_t n = npos) const; // as find, but from the end size_t rfind(char ch, size_t nstart = npos) const; // find first/last occurrence of any character in the set // size_t find_first_of(const wxstring& str, size_t nstart = 0) const; // size_t find_first_of(const char* sz, size_t nstart = 0) const; // same as find(char, size_t) size_t find_first_of(char 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* s, size_t nstart = npos) const; // same as rfind(char, size_t) size_t find_last_of (char c, size_t nstart = npos) const; // find first/last occurrence of any character not in the set // size_t find_first_not_of(const wxstring& str, size_t nstart = 0) const; // size_t find_first_not_of(const char* s, size_t nstart = 0) const; // size_t find_first_not_of(char 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* s, size_t nstart = npos) const; // size_t find_last_not_of(char ch, size_t nstart = npos) const; // all compare functions return a negative, zero or positive value // if the [sub]string is less, equal or greater than the compare() argument. // just like strcmp() int compare(const wxstring& str) const; // comparison with a substring int compare(size_t nstart, size_t nlen, const wxstring& str) const; // comparison of 2 substrings int compare(size_t nstart, size_t nlen, const wxstring& str, size_t nstart2, size_t nlen2) const; // just like strcmp() int compare(const char* sz) const; // substring comparison with first ncount characters of sz int compare(size_t nstart, size_t nlen, const char* sz, size_t ncount = npos) const; // substring extraction wxstring substr(size_t nstart = 0, size_t nlen = npos) const;
wxstring::wxstringwxstring() default constructor. initializes the string to "" (empty string). wxstring(const wxstring& x) copy constructor. wxstring(wxchar ch, size_t n = 1) constructs a string of n copies of character ch. wxstring(const wxchar* psz, size_t nlength = wxstring_maxlen) takes first nlength characters from the c string psz. the default value of wxstring_maxlen means to take all the string. note that this constructor may be used even if psz points to a buffer with binary data (i.e. containing nul characters) as long as you provide the correct value for nlength. however, the default form of it works only with strings without intermediate nuls because it uses strlen() to calculate the effective length and it would not give correct results otherwise. wxstring(const unsigned char* psz, size_t nlength = wxstring_maxlen) for compilers using unsigned char: takes first nlength characters from the c string psz. the default value of wxstring_maxlen means take all the string. for ansi builds only (note the use of char instead of wxchar). constructors with conversion the following constructors allow you to construct wxstring from a wide string in ansi build or from a c string in unicode build. wxstring(const wchar_t* psz, wxmbconv& conv, size_t nlength = wxstring_maxlen) initializes the string from first nlength characters of wide string. the default value of wxstring_maxlen means take all the string. in ansi build, conv's wc2mb method is called to convert psz to wide string. it is ignored in unicode build. wxstring(const char* psz, wxmbconv& conv, size_t nlength = wxstring_maxlen) initializes the string from first nlength characters of c string. the default value of wxstring_maxlen means take all the string. in unicode build, conv's mb2wc method is called to convert psz to wide string. it is ignored in ansi build. see also wxmbconv classes, mb_str, wc_str
wxstring::~wxstring~wxstring() string destructor. note that this is not virtual, so wxstring must not be inherited from.
wxstring::allocvoid alloc(size_t nlen) preallocate enough space for wxstring to store nlen characters. this function may be used to increase speed when the string is constructed by repeated concatenation as in
// delete all vowels from the string wxstring deleteallvowels(const wxstring& original) { wxstring result; size_t len = original.length(); result.alloc(len); for ( size_t n = 0; n < len; n++ ) { if ( strchr("aeuio", tolower(original[n])) == null ) result += original[n]; } return result; }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::appendwxstring& append(const wxchar* psz) concatenates psz to this string, returning a reference to it. wxstring& append(wxchar ch, int count = 1) concatenates character ch to this string, count times, returning a reference to it.
wxstring::afterfirstwxstring afterfirst(wxchar ch) const gets all the characters after the first occurrence of ch. returns the empty string if ch is not found.
wxstring::afterlastwxstring afterlast(wxchar ch) const gets all the characters after the last occurrence of ch. returns the whole string if ch is not found.
wxstring::beforefirstwxstring beforefirst(wxchar ch) const gets all characters before the first occurrence of ch. returns the whole string if ch is not found.
wxstring::beforelastwxstring beforelast(wxchar ch) const gets all characters before the last occurrence of ch. returns the empty string if ch is not found.
wxstring::c_strconst wxchar * c_str() const returns a pointer to the string data (const char* in ansi build, const wchar_t* in unicode build). note that the returned value will not be convertible to char* or wchar_t* in wxwidgets 3, consider using char_str or wchar_string if you need to pass string value to a function expecting non-const pointer. see also mb_str, wc_str, fn_str, char_str, wchar_string
wxstring::char_strwxwritablecharbuffer char_str(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. this function is new since wxwidgets version 2.8.4 see also mb_str, wc_str, fn_str, c_str, wchar_str
wxstring::clearvoid clear() empties the string and frees memory occupied by it. see also: empty
wxstring::cmpint cmp(const wxstring& s) const int cmp(const wxchar* psz) 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).
wxstring::cmpnocaseint cmpnocase(const wxstring& s) const int cmpnocase(const wxchar* psz) 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).
wxstring::compareto
enum wxstring::casecompare {exact, ignorecase};int compareto(const wxchar* psz, casecompare cmp = exact) const case-sensitive comparison. returns 0 if equal, 1 if greater or -1 if less. this is a wxwidgets 1.xx compatibility function; use cmp instead.
wxstring::containsbool 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.
wxstring::emptyvoid empty() makes the string empty, but doesn't free memory occupied by the string. see also: clear().
wxstring::findint find(wxchar ch, bool fromend = false) const searches for the given character. returns the starting index, or wxnot_found if not found. int find(const wxchar* sz) const searches for the given string. returns the starting index, or wxnot_found if not found.
wxstring::firstint first(wxchar c) int first(const wxchar* psz) const int first(const wxstring& str) const same as find. this is a wxwidgets 1.xx compatibility function; you should not use it in new code.
wxstring::fn_strconst wchar_t* fn_str() const const char* fn_str() const const wxcharbuffer fn_str() const returns string representation suitable for passing to os' functions for file handling. in ansi build, this is same as c_str. in unicode build, returned value can be either wide character string or c string in charset matching the wxconvfilename object, depending on the os. see also
wxstring::formatstatic wxstring format(const wxchar *format, ...) this static function returns the string containing the result of calling printf with the passed parameters on it. see also
wxstring::formatvstatic wxstring formatv(const wxchar *format, va_list argptr) this static function returns the string containing the result of calling printfv with the passed parameters on it. see also
wxstring::freqint freq(wxchar 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.
wxstring::from8bitdatastatic wxstring from8bitdata(const char* buf, size_tlen) static wxstring from8bitdata(const char* buf) converts given buffer of binary data from 8-bit string to wxstring. in unicode build, the string is interpreted as being in iso-8859-1 encoding. the version without len parameter takes nul-terminated data. this is a convenience method useful when storing binary data in wxstring. this function is new since wxwidgets version 2.8.4 see also
wxstring::fromasciistatic wxstring fromascii(const char* s) static wxstring fromascii(const char c) converts the string or character from an ascii, 7-bit form to the native wxstring representation. most useful when using a unicode build of wxwidgets (note the use of char instead of wxchar). use wxstring constructors if you need to convert from another charset.
wxstring::fromutf8static wxstring fromutf8(const char* s) static wxstring fromutf8(const char* s, size_t len) converts c string encoded in utf-8 to wxstring. note that this method assumes that s is a valid utf-8 sequence and doesn't do any validation in release builds, it's validity is only checked in debug builds.
wxstring::getcharwxchar getchar(size_t n) const returns the character at position n (read-only).
wxstring::getdataconst wxchar* getdata() const wxwidgets compatibility conversion. returns a constant pointer to the data in the string.
wxstring::getwritablecharwxchar& getwritablechar(size_t n) returns a reference to the character at position n.
wxstring::getwritebufwxchar* getwritebuf(size_t len) returns a writable buffer of at least len bytes. it returns a pointer to a new memory block, and the existing data will not be copied. call wxstring::ungetwritebuf as soon as possible to put the string back into a reasonable state.
wxstring::indexsize_t index(wxchar ch) const size_t index(const wxchar* sz) const same as wxstring::find. this is a wxwidgets 1.xx compatibility function; you should not use it in new code.
wxstring::isasciibool isascii() const returns true if the string contains only ascii characters. this is a wxwidgets 1.xx compatibility function; you should not use it in new code.
wxstring::isemptybool isempty() const returns true if the string is empty.
wxstring::isnullbool isnull() const returns true if the string is empty (same as isempty). this is a wxwidgets 1.xx compatibility function; you should not use it in new code.
wxstring::isnumberbool 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.
wxstring::issameasbool issameas(const wxchar* psz, bool casesensitive = true) const test for string equality, case-sensitive (default) or not. casesensitive is true by default (case matters). returns true if strings are equal, false otherwise. bool issameas(wxchar c, bool casesensitive = true) const test whether the string is equal to the single character c. the test is case-sensitive if casesensitive is true (default) or not if it is false. returns true if the string is equal to the character, false otherwise.
wxstring::iswordbool 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.
wxstring::lastwxchar last() const returns the last character. wxchar& 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.
wxstring::leftwxstring left(size_t count) const returns the first count characters of the string.
wxstring::lensize_t len() const returns the length of the string.
wxstring::lengthsize_t 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.
wxstring::lowerwxstring lower() const returns this string converted to the lower case.
wxstring::lowercasevoid lowercase() same as makelower. this is a wxwidgets 1.xx compatibility function; you should not use it in new code.
wxstring::makelowerwxstring& makelower() converts all characters to lower case and returns the result.
wxstring::makeupperwxstring& makeupper() converts all characters to upper case and returns the result.
wxstring::matchesbool matches(const wxchar* szmask) const returns true if the string contents matches a mask containing '*' and '?'.
wxstring::mb_strconst char* mb_str(wxmbconv& conv) const const wxcharbuffer mb_str(wxmbconv& conv) const returns multibyte (c string) representation of the string. in unicode build, converts using conv's cwc2mb method and returns wxcharbuffer. in ansi build, this function is same as c_str. the macro wxwx2mbbuf is defined as the correct return type (without const). see also wxmbconv, c_str, wc_str, fn_str, char_str
wxstring::midwxstring mid(size_t first, size_t count = wxstring_maxlen) const returns a substring starting at first, with length count, or the rest of the string if count is the default value.
wxstring::padwxstring& pad(size_t count, wxchar pad = ' ', bool fromright = true) adds count copies of pad to the beginning, or to the end of the string (the default). removes spaces from the left or from the right (default).
wxstring::prependwxstring& prepend(const wxstring& str) prepends str to this string, returning a reference to this string.
wxstring::printfint printf(const wxchar* 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:
wxstring str; str.printf(wxt("%d %d %d"), 1, 2, 3); // str now contains "1 2 3" str.printf(wxt("%2$d %3$d %1$d"), 1, 2, 3); // str now contains "2 3 1"nb: this function will use a safe version of vsprintf() (usually called vsnprintf()) whenever available to always allocate the buffer of correct size. unfortunately, this function is not available on all platforms and the dangerous vsprintf() will be used then which may lead to buffer overflows.
wxstring::printfvint printfv(const wxchar* pszformat, va_list argptr) similar to vprintf. returns the number of characters written, or an integer less than zero on error.
wxstring::removewxstring& remove(size_t pos) same as truncate. removes the portion from pos to the end of the string. 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::removelastwxstring& removelast() removes the last character.
wxstring::replacesize_t replace(const wxchar* szold, const wxchar* sznew, bool replaceall = true) replace first (or all) occurrences of substring with another one. replaceall: global replace (default), or only the first occurrence. returns the number of replacements made.
wxstring::rightwxstring right(size_t count) const returns the last count characters.
wxstring::setcharvoid setchar(size_t n, wxcharch) sets the character at position n.
wxstring::shrinkvoid shrink() minimizes the string's memory. this can be useful after a call to alloc() if too much memory were preallocated.
wxstring::startswithbool startswith(const wxchar *prefix, wxstring *rest = null) 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 null. otherwise, the function returns false and doesn't modify the rest.
wxstring::endswithbool endswith(const wxchar *suffix, wxstring *rest = null) 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 null. otherwise, the function returns false and doesn't modify the rest.
wxstring::strip
enum wxstring::striptype {leading = 0x1, trailing = 0x2, both = 0x3};wxstring strip(striptype s = trailing) const 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; you should not use it in new code.
wxstring::substringwxstring 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).
wxstring::to8bitdataconst char* to8bitdata() const converts the string to an 8-bit string (ansi builds only). const wxcharbuffer to8bitdata() const converts the string to an 8-bit string in iso-8859-1 encoding in the form of a wxcharbuffer (unicode builds only). this is a convenience method useful when storing binary data in wxstring. this function is new since wxwidgets version 2.8.4 see also
wxstring::toasciiconst char* toascii() const const wxcharbuffer toascii() const 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 mb_str method provides more powerful means of converting wxstring to c string.
wxstring::todoublebool 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. see also
wxstring::tolong,
wxstring::tolongbool 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 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. see also
wxstring::todouble,
wxstring::tolonglongbool 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. see also
wxstring::tolong,
wxstring::toulongbool 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. 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 wxstring::tolong for the more detailed description of the base parameter. see also
wxstring::todouble,
wxstring::toulonglongbool 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.
wxstring::toutf8const wxcharbuffer touf8() const same as utf8_str. this function is new since wxwidgets version 2.8.4
wxstring::trimwxstring& 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::truncatewxstring& truncate(size_t len) truncate the string to the given length.
wxstring::ungetwritebufvoid ungetwritebuf() void ungetwritebuf(size_t len) puts the string back into a reasonable state (in which it can be used normally), after wxstring::getwritebuf was called. the version of the function without the len parameter will calculate the new string length itself assuming that the string is terminated by the first nul character in it while the second one will use the specified length and thus is the only version which should be used with the strings with embedded nuls (it is also slightly more efficient as strlen() doesn't have to be called).
wxstring::upperwxstring upper() const returns this string converted to upper case.
wxstring::uppercasevoid uppercase() the same as makeupper. this is a wxwidgets 1.xx compatibility function; you should not use it in new code.
wxstring::utf8_strconst wxcharbuffer utf8_str() const converts the strings contents to utf-8 and returns it as a temporary wxcharbuffer object. this function is new since wxwidgets version 2.8.4
wxstring::wc_strconst wchar_t* wc_str(wxmbconv& conv) const const wxwcharbuffer wc_str(wxmbconv& conv) const returns wide character representation of the string. in ansi build, converts using conv's cmb2wc method and returns wxwcharbuffer. in unicode build, this function is same as c_str. the macro wxwx2wcbuf is defined as the correct return type (without const). see also wxmbconv, c_str, mb_str, fn_str, wchar_str
wxstring::wchar_strwxwritablewcharbuffer wchar_str() 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. this function is new since wxwidgets version 2.8.4 see also mb_str, wc_str, fn_str, c_str, char_str
wxstring::operator!bool operator!() const empty string is false, so !string will only return true if the string is empty. this allows the tests for nullness of a 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. see also isempty().
wxstring::operator =wxstring& operator =(const wxstring& str) wxstring& operator =(const wxchar* psz) wxstring& operator =(wxchar c) assignment: the effect of each operation is the same as for the corresponding constructor (see wxstring constructors).
wxstring::operator +concatenation: all these operators return a new string equal to the 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 +=void operator +=(const wxstring& str) void operator +=(const wxchar* psz) void operator +=(wxchar c) concatenation in place: the argument is appended to the string.
wxstring::operator []wxchar& operator [](size_t i) wxchar operator [](size_t i) const wxchar& operator [](int i) wxchar operator [](int i) const element extraction.
wxstring::operator ()wxstring operator ()(size_t start, size_t len) same as mid (substring extraction).
wxstring::operator <<wxstring& operator <<(const wxstring& str) wxstring& operator <<(const wxchar* psz) wxstring& operator <<(wxchar ch) same as +=. wxstring& operator <<(int i) wxstring& operator <<(float f) wxstring& operator <<(double d) 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 use printf for this.
wxstring::operator >>friend istream& operator >>(istream& is, wxstring& str) extraction from a stream.
wxstring::operator const wxchar*operator const wxchar*() const implicit conversion to a c string.
comparison operatorsbool 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 wxstring& y) bool operator <=(const wxstring& x, const wxchar* t) remarks these comparisons are case-sensitive.
|