1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxStringBuffer, wxString
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
13 The wxString class has been completely rewritten for wxWidgets 3.0
14 and this change was actually the main reason for the calling that
15 version wxWidgets 3.0.
17 wxString is a class representing a Unicode character string.
18 wxString uses @c std::basic_string internally (even if @c wxUSE_STL is not defined)
19 to store its content (unless this is not supported by the compiler or disabled
20 specifically when building wxWidgets) and it therefore inherits
21 many features from @c std::basic_string. (Note that most implementations of
22 @c std::basic_string are thread-safe and don't use reference counting.)
24 These @c std::basic_string standard functions are only listed here, but
25 they are not fully documented in this manual; see the STL documentation
26 (http://www.cppreference.com/wiki/string/start) for more info.
27 The behaviour of all these functions is identical to the behaviour
30 You may notice that wxString sometimes has several functions which do
31 the same thing like Length(), Len() and length() which all return the
32 string length. In all cases of such duplication the @c std::string
33 compatible methods should be used.
35 For informations about the internal encoding used by wxString and
36 for important warnings and advices for using it, please read
37 the @ref overview_string.
39 Since wxWidgets 3.0 wxString always stores Unicode strings, so you should
40 be sure to read also @ref overview_unicode.
43 @section string_index Index of the member groups
45 Links for quick access to the various categories of wxString functions:
46 - @ref_member_group{ctor, Constructors and assignment operators}
47 - @ref_member_group{length, Length functions}
48 - @ref_member_group{ch_access, Character access functions}
49 - @ref_member_group{conv, Conversions functions}
50 - @ref_member_group{concat, Concatenation functions}
51 - @ref_member_group{cmp, Comparison functions}
52 - @ref_member_group{substring, Substring extraction functions}
53 - @ref_member_group{caseconv, Case conversion functions}
54 - @ref_member_group{search, Searching and replacing functions}
55 - @ref_member_group{numconv, Conversion to numbers functions}
56 - @ref_member_group{fmt, Formatting and printing functions}
57 - @ref_member_group{mem, Memory management functions}
58 - @ref_member_group{misc, Miscellaneous functions}
59 - @ref_member_group{iter, Iterator interface functions}
60 - @ref_member_group{stl, STL interface functions}
69 @see @ref overview_string, @ref overview_unicode,
70 @ref group_funcmacro_string "String-related functions", wxUString,
71 wxCharBuffer, wxUniChar, wxStringTokenizer, wxStringBuffer, wxStringBufferLength
79 Types used with wxString.
82 typedef wxUniChar value_type
;
83 typedef wxUniChar char_type
;
84 typedef wxUniCharRef reference
;
85 typedef wxChar
* pointer
;
86 typedef const wxChar
* const_pointer
;
87 typedef size_t size_type
;
88 typedef wxUniChar const_reference
;
93 @member_group_name{ctor, Constructors and assignment operators}
95 A string may be constructed either from a C string, (some number of copies of)
96 a single character or a wide (Unicode) string. For all constructors (except the
97 default which creates an empty string) there is also a corresponding assignment
100 See also the assign() STL-like function.
110 Creates a string from another string.
111 Just increases the ref count by 1.
113 wxString(const wxString
& stringSrc
);
116 Construct a string consisting of @a nRepeat copies of ch.
118 wxString(wxUniChar ch
, size_t nRepeat
= 1);
121 Construct a string consisting of @a nRepeat copies of ch.
123 wxString(wxUniCharRef ch
, size_t nRepeat
= 1);
126 Construct a string consisting of @a nRepeat copies of ch
127 converted to Unicode using the current locale encoding.
129 wxString(char ch
, size_t nRepeat
= 1);
132 Construct a string consisting of @a nRepeat copies of ch.
134 wxString(wchar_t ch
, size_t nRepeat
= 1);
137 Constructs a string from the string literal @a psz using
138 the current locale encoding to convert it to Unicode (wxConvLibc).
140 wxString(const char *psz
);
143 Constructs a string from the string literal @a psz using
144 @a conv to convert it Unicode.
146 wxString(const char *psz
, const wxMBConv
& conv
);
149 Constructs a string from the first @a nLength character of the string literal @a psz using
150 the current locale encoding to convert it to Unicode (wxConvLibc).
152 wxString(const char *psz
, size_t nLength
);
155 Constructs a string from the first @a nLength character of the string literal @a psz using
156 @a conv to convert it Unicode.
158 wxString(const char *psz
, const wxMBConv
& conv
, size_t nLength
);
161 Constructs a string from the string literal @a pwz.
163 wxString(const wchar_t *pwz
);
166 Constructs a string from the first @a nLength characters of the string literal @a pwz.
168 wxString(const wchar_t *pwz
, size_t nLength
);
171 Constructs a string from @a buf using the using the current locale
172 encoding to convert it to Unicode.
174 wxString(const wxCharBuffer
& buf
);
177 Constructs a string from @a buf.
179 wxString(const wxWCharBuffer
& buf
);
182 Constructs a string from @a str using the using the current locale encoding
183 to convert it to Unicode (wxConvLibc).
187 wxString(const std::string
& str
);
190 Constructs a string from @a str.
194 wxString(const std::wstring
& str
);
199 Note that this is not virtual, so wxString must not be inherited from.
204 Assignment: see the relative wxString constructor.
206 wxString
operator =(const wxString
& str
);
209 Assignment: see the relative wxString constructor.
211 wxString
operator =(wxUniChar c
);
218 @member_group_name{length, String length}
220 These functions return the string length and/or check whether the string
223 See also the length(), size() or empty() STL-like functions.
229 Returns the length of the string.
234 Returns the length of the string (same as Len).
235 This is a wxWidgets 1.xx compatibility function; you should not use it in new
238 size_t Length() const;
241 Returns @true if the string is empty.
243 bool IsEmpty() const;
246 Returns @true if the string is empty (same as wxString::IsEmpty).
247 This is a wxWidgets 1.xx compatibility function; you should not use it in new
253 Empty string is @false, so !string will only return @true if the
258 bool operator!() const;
265 @member_group_name{ch_access, Character access}
267 Many functions below take a character index in the string.
268 As with C strings and arrays, the indices start from 0, so the first character
269 of a string is string[0]. An attempt to access a character beyond the end of the
270 string (which may even be 0 if the string is empty) will provoke an assert
271 failure in @ref overview_debugging "debug builds", but no checks are
272 done in release builds.
277 Returns the character at position @a n (read-only).
279 wxUniChar
GetChar(size_t n
) const;
282 wxWidgets compatibility conversion. Same as c_str().
284 const wxCStrData
GetData() const;
287 Returns a reference to the character at position @a n.
289 wxUniCharRef
GetWritableChar(size_t n
);
292 Returns a writable buffer of at least @a len bytes.
294 It returns a pointer to a new memory block, and the existing data will not be copied.
295 Call UngetWriteBuf() as soon as possible to put the string back into a reasonable state.
297 This method is deprecated, please use wxStringBuffer or wxStringBufferLength instead.
299 wxStringCharType
* GetWriteBuf(size_t len
);
302 Puts the string back into a reasonable state (in which it can be used
303 normally), after GetWriteBuf() was called.
305 The version of the function without the @a len parameter will calculate the
306 new string length itself assuming that the string is terminated by the first
307 @c NUL character in it while the second one will use the specified length
308 and thus is the only version which should be used with the strings with
309 embedded @c NULs (it is also slightly more efficient as @c strlen()
310 doesn't have to be called).
312 This method is deprecated, please use wxStringBuffer or wxStringBufferLength instead.
314 void UngetWriteBuf();
319 void UngetWriteBuf(size_t len
);
322 Sets the character at position @e n.
324 void SetChar(size_t n
, wxUniChar ch
);
327 Returns a the last character.
329 This is a wxWidgets 1.xx compatibility function;
330 you should not use it in new code.
332 wxUniChar
Last() const;
335 Returns a reference to the last character (writable).
337 This is a wxWidgets 1.xx compatibility function;
338 you should not use it in new code.
343 Returns the @a i-th character of the string.
345 wxUniChar
operator [](size_t i
) const;
348 Returns a writable reference to the @a i-th character of the string.
350 wxUniCharRef
operator [](size_t i
);
356 @member_group_name{conv, Conversions}
358 This section contains both implicit and explicit conversions to C style
359 strings. Although implicit conversion is quite convenient, you are advised
360 to use wc_str() for the sake of clarity.
365 Returns a lightweight intermediate class which is in turn implicitly
366 convertible to both @c const @c char* and to @c const @c wchar_t*.
367 Given this ambiguity it is mostly better to use wc_str(), mb_str() or
370 Please see the @ref overview_unicode for more information about it.
372 Note that the returned value is not convertible to @c char* or
373 @c wchar_t*, use char_str() or wchar_str() if you need to pass
374 string value to a function expecting non-const pointer.
376 @see wc_str(), utf8_str(), c_str(), mb_str(), fn_str()
378 wxCStrData
c_str() const;
381 Returns an object with string data that is implicitly convertible to
382 @c char* pointer. Note that any change to the returned buffer is lost and so
383 this function is only usable for passing strings to legacy libraries that
384 don't have const-correct API. Use wxStringBuffer if you want to modify
389 wxWritableCharBuffer
char_str(const wxMBConv
& conv
= wxConvLibc
) const;
392 Returns buffer of the specified type containing the string data.
394 This method is only useful in template code, otherwise you should
395 directly call mb_str() or wc_str() if you need to retrieve a narrow or
396 wide string from this wxString. The template parameter @a t should be
397 either @c char or @c wchar_t.
399 Notice that retrieving a char buffer in UTF-8 build will return the
400 internal string representation in UTF-8 while in wchar_t build the char
401 buffer will contain the conversion of the string to the encoding of the
402 current locale (and so can fail).
405 If non-@NULL, filled with the length of the returned buffer.
408 buffer containing the string contents in the specified type,
409 notice that it may be @NULL if the conversion failed (e.g. Unicode
410 string couldn't be converted to the current encoding when @a T is
413 template <typename T
>
414 wxCharTypeBuffer
<T
> tchar_str(size_t *len
= NULL
) const;
417 Returns a string representation suitable for passing to OS' functions
420 const wchar_t* fn_str() const;
425 const char* fn_str() const;
430 const wxCharBuffer
fn_str() const;
433 Returns the multibyte (C string) representation of the string
434 using @e conv's wxMBConv::cWC2MB method and returns wxCharBuffer.
436 @see wc_str(), utf8_str(), c_str(), wxMBConv
438 const wxCharBuffer
mb_str(const wxMBConv
& conv
= wxConvLibc
) const;
441 Converts the strings contents to UTF-8 and returns it either as a
442 temporary wxCharBuffer object or as a pointer to the internal
443 string contents in UTF-8 build.
445 @see wc_str(), c_str(), mb_str()
447 const wxScopedCharBuffer
utf8_str() const;
450 Converts the strings contents to the wide character represention
451 and returns it as a temporary wxWCharBuffer object (Unix and OS X)
452 or returns a pointer to the internal string contents in wide character
455 The macro wxWX2WCbuf is defined as the correct return type (without const).
457 @see utf8_str(), c_str(), mb_str(), fn_str(), wchar_str()
459 const wchar_t* wc_str() const;
464 const wxWCharBuffer
wc_str() const;
467 Returns an object with string data that is implicitly convertible to
468 @c char* pointer. Note that changes to the returned buffer may or may
469 not be lost (depending on the build) and so this function is only usable for
470 passing strings to legacy libraries that don't have const-correct API. Use
471 wxStringBuffer if you want to modify the string.
473 @see mb_str(), wc_str(), fn_str(), c_str(), char_str()
475 wxWritableWCharBuffer
wchar_str() const;
478 Explicit conversion to C string in the internal representation (either
479 wchar_t* or UTF-8-encoded char*, depending on the build).
481 const wxStringCharType
*wx_str() const;
484 Converts the string to an 8-bit string in ISO-8859-1 encoding in the
485 form of a wxCharBuffer (Unicode builds only).
487 This is a convenience method useful when storing binary data in
488 wxString. It should be used @em only for this purpose. It is only valid
489 to call this method on strings created using From8BitData().
493 @see wxString::From8BitData()
495 const wxScopedCharBuffer
To8BitData() const;
498 Converts the string to an ASCII, 7-bit string in the form of
499 a wxCharBuffer (Unicode builds only) or a C string (ANSI builds).
500 Note that this conversion only works if the string contains only ASCII
501 characters. The @ref mb_str() "mb_str" method provides more
502 powerful means of converting wxString to C string.
504 const char* ToAscii() const;
509 const wxCharBuffer
ToAscii() const;
512 Return the string as an std::string in current locale encoding.
514 Note that if the conversion of (Unicode) string contents to the current
515 locale fails, the return string will be empty. Be sure to check for
516 this to avoid silent data loss.
518 Instead of using this function it's also possible to write
523 s = std::string(wxs);
525 but using ToStdString() may make the code more clear.
529 std::string
ToStdString() const;
532 Return the string as an std::wstring.
534 Unlike ToStdString(), there is no danger of data loss when using this
539 std::wstring
ToStdWstring() const;
544 const wxScopedCharBuffer
ToUTF8() const;
550 @member_group_name{concat, Concatenation}
552 Almost anything may be concatenated (appended to) with a string!
554 Note that the various operator<<() overloads work as C++ stream insertion
555 operators. They insert the given value into the string.
556 Precision and format cannot be set using them. Use Printf() instead.
558 See also the insert() and append() STL-like functions.
563 Appends the string literal @a psz.
565 wxString
& Append(const char* psz
);
568 Appends the wide string literal @a pwz.
570 wxString
& Append(const wchar_t* pwz
);
573 Appends the string literal @a psz with max length @a nLen.
575 wxString
& Append(const char* psz
, size_t nLen
);
578 Appends the wide string literal @a psz with max length @a nLen.
580 wxString
& Append(const wchar_t* pwz
, size_t nLen
);
583 Appends the string @a s.
585 wxString
& Append(const wxString
& s
);
588 Appends the character @a ch @a count times.
590 wxString
&Append(wxUniChar ch
, size_t count
= 1u);
593 Prepends @a str to this string, returning a reference to this string.
595 wxString
& Prepend(const wxString
& str
);
598 Concatenation: returns a new string equal to the concatenation of the operands.
600 wxString
operator +(const wxString
& x
, const wxString
& y
);
605 wxString
operator +(const wxString
& x
, wxUniChar y
);
607 wxString
& operator<<(const wxString
& s
);
608 wxString
& operator<<(const char* psz
);
609 wxString
& operator<<(const wchar_t* pwz
);
610 wxString
& operator<<(const wxCStrData
& psz
);
611 wxString
& operator<<(char ch
);
612 wxString
& operator<<(unsigned char ch
);
613 wxString
& operator<<(wchar_t ch
);
614 wxString
& operator<<(const wxCharBuffer
& s
);
615 wxString
& operator<<(const wxWCharBuffer
& s
);
616 wxString
& operator<<(wxUniChar ch
);
617 wxString
& operator<<(wxUniCharRef ch
);
618 wxString
& operator<<(unsigned int ui
);
619 wxString
& operator<<(long l
);
620 wxString
& operator<<(unsigned long ul
);
621 wxString
& operator<<(wxLongLong_t ll
);
622 wxString
& operator<<(wxULongLong_t ul
);
623 wxString
& operator<<(float f
);
624 wxString
& operator<<(double d
);
627 Concatenation in place: the argument is appended to the string.
629 void operator +=(const wxString
& str
);
634 void operator +=(wxUniChar c
);
640 @member_group_name{cmp, Comparison}
642 The default comparison function Cmp() is case-sensitive and so is the default
643 version of IsSameAs(). For case insensitive comparisons you should use CmpNoCase()
644 or give a second parameter to IsSameAs(). This last function is maybe more
645 convenient if only equality of the strings matters because it returns a boolean
646 @true value if the strings are the same and not 0 (which is usually @false
649 Matches() is a poor man's regular expression matcher: it only understands
650 '*' and '?' metacharacters in the sense of DOS command line interpreter.
652 StartsWith() is helpful when parsing a line of text which should start
653 with some predefined prefix and is more efficient than doing direct string
654 comparison as you would also have to precalculate the length of the prefix.
656 See also the compare() STL-like function.
661 Case-sensitive comparison.
662 Returns a positive value if the string is greater than the argument,
663 zero if it is equal to it or a negative value if it is less than the
664 argument (same semantics as the standard @c strcmp() function).
666 @see CmpNoCase(), IsSameAs().
668 int Cmp(const wxString
& s
) const;
671 Case-insensitive comparison.
672 Returns a positive value if the string is greater than the argument,
673 zero if it is equal to it or a negative value if it is less than the
674 argument (same semantics as the standard @c strcmp() function).
676 @see Cmp(), IsSameAs().
678 int CmpNoCase(const wxString
& s
) const;
681 Test whether the string is equal to another string @a s.
683 The test is case-sensitive if @a caseSensitive is @true (default) or not if it is
686 @return @true if the string is equal to the other one, @false otherwise.
688 @see Cmp(), CmpNoCase()
690 bool IsSameAs(const wxString
& s
, bool caseSensitive
= true) const;
693 Test whether the string is equal to the single character @a ch.
695 The test is case-sensitive if @a caseSensitive is @true (default) or not if it is
698 @return @true if the string is equal to this character, @false otherwise.
700 @see Cmp(), CmpNoCase()
702 bool IsSameAs(wxUniChar ch
, bool caseSensitive
= true) const;
705 Returns @true if the string contents matches a mask containing '*' and '?'.
707 bool Matches(const wxString
& mask
) const;
710 This function can be used to test if the string starts with the specified
713 If it does, the function will return @true and put the rest of the string
714 (i.e. after the prefix) into @a rest string if it is not @NULL.
715 Otherwise, the function returns @false and doesn't modify the @a rest.
717 bool StartsWith(const wxString
& prefix
, wxString
*rest
= NULL
) const;
720 This function can be used to test if the string ends with the specified
721 @e suffix. If it does, the function will return @true and put the
722 beginning of the string before the suffix into @e rest string if it is not
723 @NULL. Otherwise, the function returns @false and doesn't
726 bool EndsWith(const wxString
& suffix
, wxString
*rest
= NULL
) const;
732 @member_group_name{substring, Substring extraction}
734 These functions allow you to extract a substring from the string. The
735 original string is not modified and the function returns the extracted
738 See also the at() and the substr() STL-like functions.
742 Returns a substring starting at @e first, with length @e count, or the rest of
743 the string if @a count is the default value.
745 wxString
Mid(size_t first
, size_t nCount
= wxString::npos
) const;
748 Returns the part of the string between the indices @a from and @a to
751 This is a wxWidgets 1.xx compatibility function, use Mid()
752 instead (but note that parameters have different meaning).
754 wxString
SubString(size_t from
, size_t to
) const;
757 Same as Mid() (substring extraction).
759 wxString
operator()(size_t start
, size_t len
) const;
762 Returns the first @a count characters of the string.
764 wxString
Left(size_t count
) const;
767 Returns the last @a count characters.
769 wxString
Right(size_t count
) const;
772 Gets all the characters after the first occurrence of @e ch.
773 Returns the empty string if @e ch is not found.
775 wxString
AfterFirst(wxUniChar ch
) const;
778 Gets all the characters after the last occurrence of @e ch.
779 Returns the whole string if @e ch is not found.
781 wxString
AfterLast(wxUniChar ch
) const;
784 Gets all characters before the first occurrence of @e ch.
785 Returns the whole string if @a ch is not found.
787 @param ch The character to look for.
788 @param rest Filled with the part of the string following the first
789 occurrence of @a ch or cleared if it was not found. The same string
790 is returned by AfterFirst() but it is more efficient to use this
791 output parameter if both the "before" and "after" parts are needed
792 than calling both functions one after the other. This parameter is
793 available in wxWidgets version 2.9.2 and later only.
794 @return Part of the string before the first occurrence of @a ch.
796 wxString
BeforeFirst(wxUniChar ch
, wxString
*rest
= NULL
) const;
799 Gets all characters before the last occurrence of @e ch.
800 Returns the empty string if @a ch is not found.
802 @param ch The character to look for.
803 @param rest Filled with the part of the string following the last
804 occurrence of @a ch or the copy of this string if it was not found.
805 The same string is returned by AfterLast() but it is more efficient
806 to use this output parameter if both the "before" and "after" parts
807 are needed than calling both functions one after the other. This
808 parameter is available in wxWidgets version 2.9.2 and later only.
809 @return Part of the string before the last occurrence of @a ch.
811 wxString
BeforeLast(wxUniChar ch
, wxString
*rest
= NULL
) const;
817 @member_group_name{caseconv, Case conversion}
819 The MakeXXX() variants modify the string in place, while the other functions
820 return a new string which contains the original text converted to the upper or
821 lower case and leave the original string unchanged.
826 Return the copy of the string with the first string character in the
827 upper case and the subsequent ones in the lower case.
831 @see MakeCapitalized()
833 wxString
Capitalize() const;
836 Returns this string converted to the lower case.
840 wxString
Lower() const;
844 This is a wxWidgets 1.xx compatibility function; you should not use it in new
850 Converts the first characters of the string to the upper case and all
851 the subsequent ones to the lower case and returns the result.
857 wxString
& MakeCapitalized();
860 Converts all characters to lower case and returns the reference to the
865 wxString
& MakeLower();
868 Converts all characters to upper case and returns the reference to the
873 wxString
& MakeUpper();
876 Returns this string converted to upper case.
880 wxString
Upper() const;
883 The same as MakeUpper().
885 This is a wxWidgets 1.xx compatibility function; you should not use it in new
894 @member_group_name{search, Searching and replacing}
896 These functions replace the standard @c strchr() and @c strstr()
899 See also the find(), rfind(), replace() STL-like functions.
904 Searches for the given character @a ch.
905 Returns the position or @c wxNOT_FOUND if not found.
907 int Find(wxUniChar ch
, bool fromEnd
= false) const;
910 Searches for the given string @a sub.
911 Returns the starting position or @c wxNOT_FOUND if not found.
913 int Find(const wxString
& sub
) const;
918 This is a wxWidgets 1.xx compatibility function;
919 you should not use it in new code.
921 int First(wxUniChar ch
) const;
926 This is a wxWidgets 1.xx compatibility function;
927 you should not use it in new code.
929 int First(const wxString
& str
) const;
932 Replace first (or all) occurrences of substring with another one.
935 The string to search for replacing.
937 The substitution string.
939 If @true a global replace will be done (default), otherwise only the
940 first occurrence will be replaced.
942 Returns the number of replacements made.
944 size_t Replace(const wxString
& strOld
, const wxString
& strNew
,
945 bool replaceAll
= true);
952 @member_group_name{numconv, Conversion to numbers}
954 The string provides functions for conversion to signed and unsigned integer and
955 floating point numbers.
957 All functions take a pointer to the variable to put the numeric value
958 in and return @true if the @b entire string could be converted to a
959 number. Notice if there is a valid number in the beginning of the
960 string, it is returned in the output parameter even if the function
961 returns @false because there is more text following it.
966 Attempts to convert the string to a floating point number.
968 Returns @true on success (the number is stored in the location pointed to by
969 @a val) or @false if the string does not represent such number (the value of
970 @a val may still be modified in this case).
972 Note that unlike ToCDouble() this function uses a localized version of
973 @c wxStrtod() and thus needs as decimal point (and thousands separator) the
974 locale-specific decimal point. Thus you should use this function only when
975 you are sure that this string contains a floating point number formatted with
976 the rules of the locale currently in use (see wxLocale).
978 Refer to the docs of the standard function @c strtod() for more details about
979 the supported syntax.
981 @see ToCDouble(), ToLong(), ToULong()
983 bool ToDouble(double* val
) const;
986 Variant of ToDouble() always working in "C" locale.
988 Works like ToDouble() but unlike it this function expects the floating point
989 number to be formatted always with the rules dictated by the "C" locale
990 (in particular, the decimal point must be a dot), independently from the
991 current application-wide locale (see wxLocale).
993 @see ToDouble(), ToLong(), ToULong()
995 bool ToCDouble(double* val
) const;
998 Attempts to convert the string to a signed integer in base @a base.
1000 Returns @true on success in which case the number is stored in the location
1001 pointed to by @a val or @false if the string does not represent a
1002 valid number in the given base (the value of @a val may still be
1003 modified in this case).
1005 The value of @a base must be comprised between 2 and 36, inclusive, or
1006 be a special value 0 which means that the usual rules of @c C numbers are
1007 applied: if the number starts with @c 0x it is considered to be in base
1008 16, if it starts with @c 0 - in base 8 and in base 10 otherwise. Note
1009 that you may not want to specify the base 0 if you are parsing the numbers
1010 which may have leading zeroes as they can yield unexpected (to the user not
1011 familiar with C) results.
1013 Note that unlike ToCLong() this function uses a localized version of
1014 @c wxStrtol(). Thus you should use this function only when you are sure
1015 that this string contains an integer number formatted with
1016 the rules of the locale currently in use (see wxLocale).
1018 Refer to the docs of the standard function @c strtol() for more details about
1019 the supported syntax.
1021 @see ToCDouble(), ToDouble(), ToULong()
1023 bool ToLong(long* val
, int base
= 10) const;
1026 Variant of ToLong() always working in "C" locale.
1028 Works like ToLong() but unlike it this function expects the integer
1029 number to be formatted always with the rules dictated by the "C" locale,
1030 independently from the current application-wide locale (see wxLocale).
1032 @see ToDouble(), ToLong(), ToULong()
1034 bool ToCLong(long* val
, int base
= 10) const;
1037 This is exactly the same as ToLong() but works with 64 bit integer numbers.
1039 Notice that currently it doesn't work (always returns @false) if parsing of 64
1040 bit numbers is not supported by the underlying C run-time library. Compilers
1041 with C99 support and Microsoft Visual C++ version 7 and higher do support this.
1043 @see ToLong(), ToULongLong()
1045 bool ToLongLong(wxLongLong_t
* val
, int base
= 10) const;
1048 Attempts to convert the string to an unsigned integer in base @a base.
1050 Returns @true on success in which case the number is stored in the
1051 location pointed to by @a val or @false if the string does not
1052 represent a valid number in the given base (the value of @a val may
1053 still be modified in this case).
1055 Please notice that this function behaves in the same way as the standard
1056 @c strtoul() and so it simply converts negative numbers to unsigned
1057 representation instead of rejecting them (e.g. -1 is returned as @c ULONG_MAX).
1059 See ToLong() for the more detailed description of the @a base parameter
1060 (and of the locale-specific behaviour of this function).
1062 @see ToCULong(), ToDouble(), ToLong()
1064 bool ToULong(unsigned long* val
, int base
= 10) const;
1067 Variant of ToULong() always working in "C" locale.
1069 Works like ToULong() but unlike it this function expects the integer
1070 number to be formatted always with the rules dictated by the "C" locale,
1071 independently from the current application-wide locale (see wxLocale).
1073 @see ToDouble(), ToLong(), ToULong()
1075 bool ToCULong(unsigned long* val
, int base
= 10) const;
1078 This is exactly the same as ToULong() but works with 64 bit integer
1081 Please see ToLongLong() for additional remarks.
1083 bool ToULongLong(wxULongLong_t
* val
, int base
= 10) const;
1089 @member_group_name{fmt, Formatting and printing}
1091 Both formatted versions (Printf/() and stream-like insertion operators
1092 exist (for basic types only).
1094 See also the static Format() and FormatV() functions.
1099 Similar to the standard function @e sprintf(). Returns the number of
1100 characters written, or an integer less than zero on error.
1101 Note that if @c wxUSE_PRINTF_POS_PARAMS is set to 1, then this function supports
1102 Unix98-style positional parameters:
1107 str.Printf(wxT("%d %d %d"), 1, 2, 3);
1108 // str now contains "1 2 3"
1110 str.Printf(wxT("%2$d %3$d %1$d"), 1, 2, 3);
1111 // str now contains "2 3 1"
1114 @note This function will use a safe version of @e vsprintf() (usually called
1115 @e vsnprintf()) whenever available to always allocate the buffer of correct
1116 size. Unfortunately, this function is not available on all platforms and the
1117 dangerous @e vsprintf() will be used then which may lead to buffer overflows.
1119 int Printf(const wxString
& pszFormat
, ...);
1122 Similar to vprintf. Returns the number of characters written, or an integer
1126 int PrintfV(const wxString
& pszFormat
, va_list argPtr
);
1132 @member_group_name{mem, Memory management}
1134 The following are "advanced" functions and they will be needed rarely.
1135 Alloc() and Shrink() are only interesting for optimization purposes.
1136 wxStringBuffer and wxStringBufferLength classes may be very useful when working
1137 with some external API which requires the caller to provide a writable buffer.
1139 See also the reserve() and resize() STL-like functions.
1144 Preallocate enough space for wxString to store @a nLen characters.
1146 Please note that this method does the same thing as the standard
1147 reserve() one and shouldn't be used in new code.
1149 This function may be used to increase speed when the string is
1150 constructed by repeated concatenation as in
1153 // delete all vowels from the string
1154 wxString DeleteAllVowels(const wxString& original)
1158 size_t len = original.length();
1162 for ( size_t n = 0; n < len; n++ )
1164 if ( strchr("aeuio", tolower(original[n])) == NULL )
1165 result += original[n];
1172 because it will avoid the need to reallocate string memory many times
1173 (in case of long strings). Note that it does not set the maximal length
1174 of a string -- it will still expand if more than @a nLen characters are
1175 stored in it. Also, it does not truncate the existing string (use
1176 Truncate() for this) even if its current length is greater than @a nLen.
1178 @return @true if memory was successfully allocated, @false otherwise.
1180 bool Alloc(size_t nLen
);
1183 Minimizes the string's memory. This can be useful after a call to
1184 Alloc() if too much memory were preallocated.
1189 Returns a deep copy of the string.
1191 That is, the returned string is guaranteed to not share data with this
1192 string when using reference-counted wxString implementation.
1194 This method is primarily useful for passing strings between threads
1195 (because wxString is not thread-safe). Unlike creating a copy using
1196 @c wxString(c_str()), Clone() handles embedded NULs correctly.
1200 wxString
Clone() const;
1203 Empties the string and frees memory occupied by it.
1214 @member_group_name{misc, Miscellaneous}
1216 Miscellaneous other string functions.
1221 Returns @true if target appears anywhere in wxString; else @false.
1223 This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
1225 bool Contains(const wxString
& str
) const;
1228 Makes the string empty, but doesn't free memory occupied by the string.
1235 Returns the number of occurrences of @e ch in the string.
1237 This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
1239 int Freq(wxUniChar ch
) const;
1242 Returns @true if the string contains only ASCII characters.
1243 See wxUniChar::IsAscii for more details.
1245 This is a wxWidgets 1.xx compatibility function; you should not use it in new
1248 bool IsAscii() const;
1251 Returns @true if the string is an integer (with possible sign).
1253 This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
1255 bool IsNumber() const;
1258 Returns @true if the string is a word.
1260 This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
1262 bool IsWord() const;
1265 Adds @a count copies of @a chPad to the beginning, or to the end of the
1266 string (the default).
1268 Removes spaces from the left or from the right (default).
1270 wxString
& Pad(size_t count
, wxUniChar chPad
= ' ', bool fromRight
= true);
1273 Removes all characters from the string starting at @a pos.
1274 Use Truncate() as a more readable alternative.
1276 This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
1278 wxString
& Remove(size_t pos
);
1281 Removes @a len characters from the string, starting at @a pos.
1283 This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
1285 wxString
& Remove(size_t pos
, size_t len
);
1288 Removes the last character.
1290 wxString
& RemoveLast(size_t n
= 1);
1293 Strip characters at the front and/or end.
1295 This is the same as Trim() except that it doesn't change this string.
1297 This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
1299 wxString
Strip(stripType s
= trailing
) const;
1302 Removes white-space (space, tabs, form feed, newline and carriage return) from
1303 the left or from the right end of the string (right is default).
1305 wxString
& Trim(bool fromRight
= true);
1308 Truncate the string to the given length.
1310 wxString
& Truncate(size_t len
);
1318 @member_group_name{iter, Iterator interface}
1320 These methods return iterators to the beginnnig or end of the string.
1322 Please see any STL reference (e.g. http://www.cppreference.com/wiki/string/start)
1323 for their documentation.
1327 const_iterator
begin() const;
1329 const_iterator
end() const;
1332 const_reverse_iterator
rbegin() const;
1333 reverse_iterator
rbegin();
1334 const_reverse_iterator
rend() const;
1335 reverse_iterator
rend();
1342 @member_group_name{stl, STL interface}
1344 The supported STL functions are listed here.
1346 Please see any STL reference (e.g. http://www.cppreference.com/wiki/string/start)
1347 for their documentation.
1351 wxString
& append(const wxString
& str
, size_t pos
, size_t n
);
1352 wxString
& append(const wxString
& str
);
1353 wxString
& append(const char *sz
, size_t n
);
1354 wxString
& append(const wchar_t *sz
, size_t n
);
1355 wxString
& append(size_t n
, wxUniChar ch
);
1356 wxString
& append(const_iterator first
, const_iterator last
);
1358 wxString
& assign(const wxString
& str
, size_t pos
, size_t n
);
1359 wxString
& assign(const wxString
& str
);
1360 wxString
& assign(const char *sz
, size_t n
);
1361 wxString
& assign(const wchar_t *sz
, size_t n
);
1362 wxString
& assign(size_t n
, wxUniChar ch
);
1363 wxString
& assign(const_iterator first
, const_iterator last
);
1365 wxUniChar
at(size_t n
) const;
1366 wxUniCharRef
at(size_t n
);
1370 size_type
capacity() const;
1372 int compare(const wxString
& str
) const;
1373 int compare(size_t nStart
, size_t nLen
, const wxString
& str
) const;
1374 int compare(size_t nStart
, size_t nLen
,
1375 const wxString
& str
, size_t nStart2
, size_t nLen2
) const;
1376 int compare(size_t nStart
, size_t nLen
,
1377 const char* sz
, size_t nCount
= npos
) const;
1378 int compare(size_t nStart
, size_t nLen
,
1379 const wchar_t* sz
, size_t nCount
= npos
) const;
1381 wxCStrData
data() const;
1385 wxString
& erase(size_type pos
= 0, size_type n
= npos
);
1386 iterator
erase(iterator first
, iterator last
);
1387 iterator
erase(iterator first
);
1389 size_t find(const wxString
& str
, size_t nStart
= 0) const;
1390 size_t find(const char* sz
, size_t nStart
= 0, size_t n
= npos
) const;
1391 size_t find(const wchar_t* sz
, size_t nStart
= 0, size_t n
= npos
) const;
1392 size_t find(wxUniChar ch
, size_t nStart
= 0) const;
1393 size_t find_first_of(const char* sz
, size_t nStart
= 0) const;
1394 size_t find_first_of(const wchar_t* sz
, size_t nStart
= 0) const;
1395 size_t find_first_of(const char* sz
, size_t nStart
, size_t n
) const;
1396 size_t find_first_of(const wchar_t* sz
, size_t nStart
, size_t n
) const;
1397 size_t find_first_of(wxUniChar c
, size_t nStart
= 0) const;
1398 size_t find_last_of (const wxString
& str
, size_t nStart
= npos
) const;
1399 size_t find_last_of (const char* sz
, size_t nStart
= npos
) const;
1400 size_t find_last_of (const wchar_t* sz
, size_t nStart
= npos
) const;
1401 size_t find_last_of(const char* sz
, size_t nStart
, size_t n
) const;
1402 size_t find_last_of(const wchar_t* sz
, size_t nStart
, size_t n
) const;
1403 size_t find_last_of(wxUniChar c
, size_t nStart
= npos
) const;
1404 size_t find_first_not_of(const wxString
& str
, size_t nStart
= 0) const;
1405 size_t find_first_not_of(const char* sz
, size_t nStart
= 0) const;
1406 size_t find_first_not_of(const wchar_t* sz
, size_t nStart
= 0) const;
1407 size_t find_first_not_of(const char* sz
, size_t nStart
, size_t n
) const;
1408 size_t find_first_not_of(const wchar_t* sz
, size_t nStart
, size_t n
) const;
1409 size_t find_first_not_of(wxUniChar ch
, size_t nStart
= 0) const;
1410 size_t find_last_not_of(const wxString
& str
, size_t nStart
= npos
) const;
1411 size_t find_last_not_of(const char* sz
, size_t nStart
= npos
) const;
1412 size_t find_last_not_of(const wchar_t* sz
, size_t nStart
= npos
) const;
1413 size_t find_last_not_of(const char* sz
, size_t nStart
, size_t n
) const;
1414 size_t find_last_not_of(const wchar_t* sz
, size_t nStart
, size_t n
) const;
1416 wxString
& insert(size_t nPos
, const wxString
& str
);
1417 wxString
& insert(size_t nPos
, const wxString
& str
, size_t nStart
, size_t n
);
1418 wxString
& insert(size_t nPos
, const char *sz
, size_t n
);
1419 wxString
& insert(size_t nPos
, const wchar_t *sz
, size_t n
);
1420 wxString
& insert(size_t nPos
, size_t n
, wxUniChar ch
);
1421 iterator
insert(iterator it
, wxUniChar ch
);
1422 void insert(iterator it
, const_iterator first
, const_iterator last
);
1423 void insert(iterator it
, size_type n
, wxUniChar ch
);
1425 size_t length() const;
1427 size_type
max_size() const;
1429 void reserve(size_t sz
);
1430 void resize(size_t nSize
, wxUniChar ch
= '\0');
1432 wxString
& replace(size_t nStart
, size_t nLen
, const wxString
& str
);
1433 wxString
& replace(size_t nStart
, size_t nLen
, size_t nCount
, wxUniChar ch
);
1434 wxString
& replace(size_t nStart
, size_t nLen
,
1435 const wxString
& str
, size_t nStart2
, size_t nLen2
);
1436 wxString
& replace(size_t nStart
, size_t nLen
,
1437 const char* sz
, size_t nCount
);
1438 wxString
& replace(size_t nStart
, size_t nLen
,
1439 const wchar_t* sz
, size_t nCount
);
1440 wxString
& replace(size_t nStart
, size_t nLen
,
1441 const wxString
& s
, size_t nCount
);
1442 wxString
& replace(iterator first
, iterator last
, const wxString
& s
);
1443 wxString
& replace(iterator first
, iterator last
, const char* s
, size_type n
);
1444 wxString
& replace(iterator first
, iterator last
, const wchar_t* s
, size_type n
);
1445 wxString
& replace(iterator first
, iterator last
, size_type n
, wxUniChar ch
);
1446 wxString
& replace(iterator first
, iterator last
,
1447 const_iterator first1
, const_iterator last1
);
1448 wxString
& replace(iterator first
, iterator last
,
1449 const char *first1
, const char *last1
);
1450 wxString
& replace(iterator first
, iterator last
,
1451 const wchar_t *first1
, const wchar_t *last1
);
1453 size_t rfind(const wxString
& str
, size_t nStart
= npos
) const;
1454 size_t rfind(const char* sz
, size_t nStart
= npos
, size_t n
= npos
) const;
1455 size_t rfind(const wchar_t* sz
, size_t nStart
= npos
, size_t n
= npos
) const;
1456 size_t rfind(wxUniChar ch
, size_t nStart
= npos
) const;
1458 size_type
size() const;
1459 wxString
substr(size_t nStart
= 0, size_t nLen
= npos
) const;
1460 void swap(wxString
& str
);
1467 // Keep these functions separed from the other groups or Doxygen gets confused
1468 // -----------------------------------------------------------------------------
1471 An 'invalid' value for string index
1473 static const size_t npos
;
1476 This static function returns the string containing the result of calling
1477 Printf() with the passed parameters on it.
1479 @see FormatV(), Printf()
1481 static wxString
Format(const wxString
& format
, ...);
1484 This static function returns the string containing the result of calling
1485 PrintfV() with the passed parameters on it.
1487 @see Format(), PrintfV()
1489 static wxString
FormatV(const wxString
& format
, va_list argptr
);
1493 Converts given buffer of binary data from 8-bit string to wxString. In
1494 Unicode build, the string is interpreted as being in ISO-8859-1
1495 encoding. The version without @e len parameter takes NUL-terminated
1498 This is a convenience method useful when storing binary data in
1499 wxString. It should be used @em only for that purpose and only in
1500 conjunction with To8BitData(). Use mb_str() for conversion of character
1501 data to known encoding.
1505 @see wxString::To8BitData()
1507 static wxString
From8BitData(const char* buf
, size_t len
);
1508 static wxString
From8BitData(const char* buf
);
1513 Converts the string or character from an ASCII, 7-bit form
1514 to the native wxString representation.
1516 static wxString
FromAscii(const char* s
);
1517 static wxString
FromAscii(const unsigned char* s
);
1518 static wxString
FromAscii(const char* s
, size_t len
);
1519 static wxString
FromAscii(const unsigned char* s
, size_t len
);
1520 static wxString
FromAscii(char c
);
1524 Returns a string with the textual representation of the number in C
1527 Unlike FromDouble() the string returned by this function always uses
1528 the period character as decimal separator, independently of the current
1535 static wxString
FromCDouble(double val
);
1538 Returns a string with the textual representation of the number.
1540 This is a simple wrapper for @code wxString::Format("%g", val)
1543 Notice that the string returned by this function uses the decimal
1544 separator appropriate for the current locale, e.g. @c "," and not a
1545 period in French locale. Use FromCDouble() if this is unwanted.
1551 static wxString
FromDouble(double val
);
1555 Converts C string encoded in UTF-8 to wxString.
1557 If @a s is not a valid UTF-8 string, an empty string is returned.
1559 Notice that when using UTF-8 wxWidgets build there is a more efficient
1560 alternative to this function called FromUTF8Unchecked() which, unlike
1561 this one, doesn't check that the input string is valid.
1565 static wxString
FromUTF8(const char* s
);
1566 static wxString
FromUTF8(const char* s
, size_t len
);
1571 Converts C string encoded in UTF-8 to wxString without checking its
1574 This method assumes that @a s is a valid UTF-8 sequence and doesn't do
1575 any validation (although an assert failure is triggered in debug builds
1576 if the string is invalid). Only use it if you are absolutely sure that
1577 @a s is a correct UTF-8 string (e.g. because it comes from another
1578 library using UTF-8) and if the performance matters, otherwise use
1579 slower (in UTF-8 build) but safer FromUTF8(). Passing a bad UTF-8
1580 string to this function will result in creating a corrupted wxString
1581 and all the subsequent operations on it will be undefined.
1585 static wxString
FromUTF8Unchecked(const char* s
);
1586 static wxString
FromUTF8Unchecked(const char* s
, size_t len
);
1594 Comparison operator for string types.
1596 inline bool operator==(const wxString
& s1
, const wxString
& s2
);
1597 inline bool operator!=(const wxString
& s1
, const wxString
& s2
);
1598 inline bool operator< (const wxString
& s1
, const wxString
& s2
);
1599 inline bool operator> (const wxString
& s1
, const wxString
& s2
);
1600 inline bool operator<=(const wxString
& s1
, const wxString
& s2
);
1601 inline bool operator>=(const wxString
& s1
, const wxString
& s2
);
1602 inline bool operator==(const wxString
& s1
, const wxCStrData
& s2
);
1603 inline bool operator==(const wxCStrData
& s1
, const wxString
& s2
);
1604 inline bool operator!=(const wxString
& s1
, const wxCStrData
& s2
);
1605 inline bool operator!=(const wxCStrData
& s1
, const wxString
& s2
);
1606 inline bool operator==(const wxString
& s1
, const wxWCharBuffer
& s2
);
1607 inline bool operator==(const wxWCharBuffer
& s1
, const wxString
& s2
);
1608 inline bool operator!=(const wxString
& s1
, const wxWCharBuffer
& s2
);
1609 inline bool operator!=(const wxWCharBuffer
& s1
, const wxString
& s2
);
1610 inline bool operator==(const wxString
& s1
, const wxCharBuffer
& s2
);
1611 inline bool operator==(const wxCharBuffer
& s1
, const wxString
& s2
);
1612 inline bool operator!=(const wxString
& s1
, const wxCharBuffer
& s2
);
1613 inline bool operator!=(const wxCharBuffer
& s1
, const wxString
& s2
);
1618 Comparison operators char types.
1620 inline bool operator==(const wxUniChar
& c
, const wxString
& s
);
1621 inline bool operator==(const wxUniCharRef
& c
, const wxString
& s
);
1622 inline bool operator==(char c
, const wxString
& s
);
1623 inline bool operator==(wchar_t c
, const wxString
& s
);
1624 inline bool operator==(int c
, const wxString
& s
);
1625 inline bool operator==(const wxString
& s
, const wxUniChar
& c
);
1626 inline bool operator==(const wxString
& s
, const wxUniCharRef
& c
);
1627 inline bool operator==(const wxString
& s
, char c
);
1628 inline bool operator==(const wxString
& s
, wchar_t c
);
1629 inline bool operator!=(const wxUniChar
& c
, const wxString
& s
);
1630 inline bool operator!=(const wxUniCharRef
& c
, const wxString
& s
);
1631 inline bool operator!=(char c
, const wxString
& s
);
1632 inline bool operator!=(wchar_t c
, const wxString
& s
);
1633 inline bool operator!=(int c
, const wxString
& s
);
1634 inline bool operator!=(const wxString
& s
, const wxUniChar
& c
);
1635 inline bool operator!=(const wxString
& s
, const wxUniCharRef
& c
);
1636 inline bool operator!=(const wxString
& s
, char c
);
1637 inline bool operator!=(const wxString
& s
, wchar_t c
);
1641 The global wxString instance of an empty string.
1642 Used extensively in the entire wxWidgets API.
1644 wxString wxEmptyString
;
1649 @class wxStringBufferLength
1651 This tiny class allows you to conveniently access the wxString internal buffer
1652 as a writable pointer without any risk of forgetting to restore the string to
1653 the usable state later, and allows the user to set the internal length of the string.
1655 For example, assuming you have a low-level OS function called
1656 @c "int GetMeaningOfLifeAsString(char *)" copying the value in the provided
1657 buffer (which must be writable, of course), and returning the actual length
1658 of the string, you might call it like this:
1662 wxStringBufferLength theAnswerBuffer(theAnswer, 1024);
1663 int nLength = GetMeaningOfLifeAsString(theAnswerBuffer);
1664 theAnswerBuffer.SetLength(nLength);
1665 if ( theAnswer != "42" )
1666 wxLogError("Something is very wrong!");
1669 Note that the exact usage of this depends on whether or not wxUSE_STL is
1670 enabled. If wxUSE_STL is enabled, wxStringBuffer creates a separate empty
1671 character buffer, and if wxUSE_STL is disabled, it uses GetWriteBuf() from
1672 wxString, keeping the same buffer wxString uses intact. In other words,
1673 relying on wxStringBuffer containing the old wxString data is not a good
1674 idea if you want to build your program both with and without wxUSE_STL.
1676 Note that wxStringBuffer::SetLength @b must be called before
1677 wxStringBufferLength destructs.
1682 class wxStringBufferLength
1686 Constructs a writable string buffer object associated with the given string
1687 and containing enough space for at least @a len characters.
1689 Basically, this is equivalent to calling wxString::GetWriteBuf and
1692 wxStringBufferLength(const wxString
& str
, size_t len
);
1695 Restores the string passed to the constructor to the usable state by calling
1696 wxString::UngetWriteBuf on it.
1698 ~wxStringBufferLength();
1701 Sets the internal length of the string referred to by wxStringBufferLength to
1702 @a nLength characters.
1704 Must be called before wxStringBufferLength destructs.
1706 void SetLength(size_t nLength
);
1709 Returns the writable pointer to a buffer of the size at least equal to the
1710 length specified in the constructor.
1712 wxChar
* operator wxChar
*();
1717 @class wxStringBuffer
1719 This tiny class allows you to conveniently access the wxString internal buffer
1720 as a writable pointer without any risk of forgetting to restore the string
1721 to the usable state later.
1723 For example, assuming you have a low-level OS function called
1724 @c "GetMeaningOfLifeAsString(char *)" returning the value in the provided
1725 buffer (which must be writable, of course) you might call it like this:
1729 GetMeaningOfLifeAsString(wxStringBuffer(theAnswer, 1024));
1730 if ( theAnswer != "42" )
1731 wxLogError("Something is very wrong!");
1734 Note that the exact usage of this depends on whether or not @c wxUSE_STL is
1735 enabled. If @c wxUSE_STL is enabled, wxStringBuffer creates a separate empty
1736 character buffer, and if @c wxUSE_STL is disabled, it uses GetWriteBuf() from
1737 wxString, keeping the same buffer wxString uses intact. In other words,
1738 relying on wxStringBuffer containing the old wxString data is not a good
1739 idea if you want to build your program both with and without @c wxUSE_STL.
1744 class wxStringBuffer
1748 Constructs a writable string buffer object associated with the given string
1749 and containing enough space for at least @a len characters.
1750 Basically, this is equivalent to calling wxString::GetWriteBuf() and
1753 wxStringBuffer(const wxString
& str
, size_t len
);
1756 Restores the string passed to the constructor to the usable state by calling
1757 wxString::UngetWriteBuf() on it.
1762 Returns the writable pointer to a buffer of the size at least equal to the
1763 length specified in the constructor.
1765 wxStringCharType
* operator wxStringCharType
*();
1769 /** @addtogroup group_funcmacro_string */
1773 Allows to extend a function with the signature:
1774 @code bool SomeFunc(const wxUniChar& c) @endcode
1775 which operates on a single character, to an entire wxString.
1777 E.g. if you want to check if an entire string contains only digits,
1780 if (wxStringCheck<wxIsdigit>(myString))
1781 ... // the entire string contains oly digits!
1783 ... // at least one character of myString is not a digit
1786 @return @true if the given function returns a non-zero value for all
1787 characters of the @a val string.
1789 template<bool (T
)(const wxUniChar
& c
)>
1790 inline bool wxStringCheck(const wxString
& val
);