1 \section{\class{wxString
}}\label{wxstring
}
3 wxString is a class representing a character string. Please see the
4 \helpref{wxString overview
}{wxstringoverview
} for more information about it.
6 As explained there, wxString implements most of the methods of the std::string
8 These standard functions are not documented in this manual, please see the
9 \urlref{STL documentation
}{http://www.cppreference.com/cppstl.html
}).
10 The behaviour of all these functions is identical to the behaviour described
13 You may notice that wxString sometimes has many functions which do the same
14 thing like, for example,
\helpref{Length()
}{wxstringlength
},
15 \helpref{Len()
}{wxstringlen
} and
{\tt length()
} which all return the string
16 length. In all cases of such duplication the
{\tt std::string
}-compatible
17 method (
{\tt length()
} in this case, always the lowercase version) should be
18 used as it will ensure smoother transition to
{\tt std::string
} when wxWidgets
19 starts using it instead of wxString.
21 \wxheading{Derived from
}
25 \wxheading{Include files
}
29 \wxheading{Predefined objects
}
37 \helpref{wxString overview
}{wxstringoverview
},
\helpref{Unicode overview
}{unicode
}
39 \latexignore{\rtfignore{\wxheading{Function groups
}}}
42 \membersection{Constructors and assignment operators
}\label{constructorsinwxstring
}
44 A string may be constructed either from a C string, (some number of copies of)
45 a single character or a wide (UNICODE) string. For all constructors (except the
46 default which creates an empty string) there is also a corresponding assignment
49 \helpref{wxString
}{wxstringconstruct
}\\
50 \helpref{operator $=$
}{wxstringoperatorassign
}\\
51 \helpref{\destruct{wxString
}}{wxstringdestruct
}
54 \membersection{String length
}\label{lengthfunctionsinwxstring
}
56 These functions return the string length and check whether the string is empty
59 \helpref{Len
}{wxstringlen
}\\
60 \helpref{IsEmpty
}{wxstringisempty
}\\
61 \helpref{operator!
}{wxstringoperatornot
}\\
62 \helpref{Empty
}{wxstringempty
}\\
63 \helpref{Clear
}{wxstringclear
}
66 \membersection{Character access
}\label{characteraccessinwxstring
}
68 Many functions in this section take a character index in the string. As with C
69 strings and/or arrays, the indices start from $
0$, so the first character of a
70 string is string
[$
0$
]. Attempt to access a character beyond the end of the
71 string (which may be even $
0$ if the string is empty) will provoke an assert
72 failure in
\helpref{debug build
}{debuggingoverview
}, but no checks are done in
75 This section also contains both implicit and explicit conversions to C style
76 strings. Although implicit conversion is quite convenient, it is advised to use
77 explicit
\helpref{c
\_str()
}{wxstringcstr
} method for the sake of clarity. Also
78 see
\helpref{overview
}{wxstringadvices
} for the cases where it is necessary to
81 \helpref{GetChar
}{wxstringgetchar
}\\
82 \helpref{GetWritableChar
}{wxstringgetwritablechar
}\\
83 \helpref{SetChar
}{wxstringsetchar
}\\
84 \helpref{Last
}{wxstringlast
}\\
85 \helpref{operator
[]}{wxstringoperatorbracket
}\\
86 \helpref{c
\_str}{wxstringcstr
}\\
87 \helpref{mb
\_str}{wxstringmbstr
}\\
88 \helpref{wc
\_str}{wxstringwcstr
}\\
89 \helpref{fn
\_str}{wxstringfnstr
}\\
90 \helpref{operator const char*
}{wxstringoperatorconstcharpt
}
93 \membersection{Concatenation
}\label{concatenationinwxstring
}
95 Anything may be concatenated (appended to) with a string. However, you can't
96 append something to a C string (including literal constants), so to do this it
97 should be converted to a wxString first.
99 \helpref{operator
\cinsert}{wxstringoperatorout
}\\
100 \helpref{operator $+=$
}{wxstringplusequal
}\\
101 \helpref{operator $+$
}{wxstringoperatorplus
}\\
102 \helpref{Append
}{wxstringappend
}\\
103 \helpref{Prepend
}{wxstringprepend
}
106 \membersection{Comparison
}\label{comparisoninwxstring
}
108 The default comparison function
\helpref{Cmp
}{wxstringcmp
} is case-sensitive and
109 so is the default version of
\helpref{IsSameAs
}{wxstringissameas
}. For case
110 insensitive comparisons you should use
\helpref{CmpNoCase
}{wxstringcmpnocase
} or
111 give a second parameter to IsSameAs. This last function is may be more
112 convenient if only equality of the strings matters because it returns a boolean
113 \true value if the strings are the same and not
0 (which is usually false in C)
116 \helpref{Matches
}{wxstringmatches
} is a poor man's regular expression matcher:
117 it only understands '*' and '?' metacharacters in the sense of DOS command line
120 \helpref{StartsWith
}{wxstringstartswith
} is helpful when parsing a line of
121 text which should start with some predefined prefix and is more efficient than
122 doing direct string comparison as you would also have to precalculate the
123 length of the prefix then.
125 \helpref{Cmp
}{wxstringcmp
}\\
126 \helpref{CmpNoCase
}{wxstringcmpnocase
}\\
127 \helpref{IsSameAs
}{wxstringissameas
}\\
128 \helpref{Matches
}{wxstringmatches
}\\
129 \helpref{StartsWith
}{wxstringstartswith
}\\
130 \helpref{EndsWith
}{wxstringendswith
}
133 \membersection{Substring extraction
}\label{substringextractioninwxstring
}
135 These functions allow to extract substring from this string. All of them don't
136 modify the original string and return a new string containing the extracted
139 \helpref{Mid
}{wxstringmid
}\\
140 \helpref{operator()
}{wxstringoperatorparenth
}\\
141 \helpref{Left
}{wxstringleft
}\\
142 \helpref{Right
}{wxstringright
}\\
143 \helpref{BeforeFirst
}{wxstringbeforefirst
}\\
144 \helpref{BeforeLast
}{wxstringbeforelast
}\\
145 \helpref{AfterFirst
}{wxstringafterfirst
}\\
146 \helpref{AfterLast
}{wxstringafterlast
}\\
147 \helpref{StartsWith
}{wxstringstartswith
}\\
148 \helpref{EndsWith
}{wxstringendswith
}
152 \membersection{Case conversion
}\label{caseconversioninwxstring
}
154 The MakeXXX() variants modify the string in place, while the other functions
155 return a new string which contains the original text converted to the upper or
156 lower case and leave the original string unchanged.
158 \helpref{MakeUpper
}{wxstringmakeupper
}\\
159 \helpref{Upper
}{wxstringupper
}\\
160 \helpref{MakeLower
}{wxstringmakelower
}\\
161 \helpref{Lower
}{wxstringlower
}
164 \membersection{Searching and replacing
}\label{searchingandreplacinginwxstring
}
166 These functions replace the standard
{\it strchr()
} and
{\it strstr()
}
169 \helpref{Find
}{wxstringfind
}\\
170 \helpref{Replace
}{wxstringreplace
}
173 \membersection{Conversion to numbers
}\label{conversiontonumbersinwxstring
}
175 The string provides functions for conversion to signed and unsigned integer and
176 floating point numbers. All three functions take a pointer to the variable to
177 put the numeric value in and return
\true if the
{\bf entire
} string could be
178 converted to a number.
180 \helpref{ToLong
}{wxstringtolong
}\\
181 \helpref{ToLongLong
}{wxstringtolonglong
}\\
182 \helpref{ToULong
}{wxstringtoulong
}\\
183 \helpref{ToULongLong
}{wxstringtoulonglong
}\\
184 \helpref{ToDouble
}{wxstringtodouble
}
187 \membersection{Writing values into the string
}\label{writingintostringinwxstring
}
189 Both formatted versions (
\helpref{Printf
}{wxstringprintf
}) and stream-like
190 insertion operators exist (for basic types only). Additionally, the
191 \helpref{Format
}{wxstringformat
} function allows to use simply append
192 formatted value to a string:
195 // the following
2 snippets are equivalent
198 s += wxString::Format("
%d", n);
201 s.Printf("...
%d", n);
204 \helpref{Format
}{wxstringformat
}\\
205 \helpref{FormatV
}{wxstringformatv
}\\
206 \helpref{Printf
}{wxstringprintf
}\\
207 \helpref{PrintfV
}{wxstringprintfv
}\\
208 \helpref{operator
\cinsert}{wxstringoperatorout
}
211 \membersection{Memory management
}\label{memoryinwxstring
}
213 These are "advanced" functions and they will be needed quite rarely.
214 \helpref{Alloc
}{wxstringalloc
} and
\helpref{Shrink
}{wxstringshrink
} are only
215 interesting for optimization purposes.
216 \helpref{wxStringBuffer
}{wxstringbuffer
}
217 and
\helpref{wxStringBufferLength
}{wxstringbufferlength
} classes may be very
218 useful when working with some external API which requires the caller to provide
221 \helpref{Alloc
}{wxstringalloc
}\\
222 \helpref{Shrink
}{wxstringshrink
}\\
223 \helpref{wxStringBuffer
}{wxstringbuffer
}\\
224 \helpref{wxStringBufferLength
}{wxstringbufferlength
}
227 \membersection{Miscellaneous
}\label{miscellaneousinwxstring
}
229 Other string functions.
231 \helpref{Trim
}{wxstringtrim
}\\
232 \helpref{Truncate
}{wxstringtruncate
}\\
233 \helpref{Pad
}{wxstringpad
}
236 \membersection{wxWidgets
1.xx compatibility functions
}\label{backwardcompatibilityinwxstring
}
238 These functions are deprecated, please consider using new wxWidgets
2.0
239 functions instead of them (or, even better, std::string compatible variants).
241 % keep ordered alphabetically
242 \helpref{CompareTo
}{wxstringcompareto
}\\
243 \helpref{Contains
}{wxstringcontains
}\\
244 \helpref{First
}{wxstringfirst
}\\
245 \helpref{Freq
}{wxstringfreq
}\\
246 \helpref{Index
}{wxstringindex
}\\
247 \helpref{IsAscii
}{wxstringisascii
}\\
248 \helpref{IsNull
}{wxstringisnull
}\\
249 \helpref{IsNumber
}{wxstringisnumber
}\\
250 \helpref{IsWord
}{wxstringisword
}\\
251 \helpref{Last
}{wxstringlast
}\\
252 \helpref{Length
}{wxstringlength
}\\
253 \helpref{LowerCase
}{wxstringlowercase
}\\
254 \helpref{Remove
}{wxstringremove
}\\
255 \helpref{Strip
}{wxstringstrip
}\\
256 \helpref{SubString
}{wxstringsubstring
}\\
257 \helpref{UpperCase
}{wxstringuppercase
}
260 \membersection{std::string compatibility functions
}\label{wxstringat
}
262 The supported functions are only listed here, please see any STL reference for
266 // take nLen chars starting at nPos
267 wxString(const wxString& str, size_t nPos, size_t nLen);
268 // take all characters from pStart to pEnd (poor man's iterators)
269 wxString(const void *pStart, const void *pEnd);
271 // lib.string.capacity
272 // return the length of the string
274 // return the length of the string
275 size_t length() const;
276 // return the maximum size of the string
277 size_t max_size() const;
278 // resize the string, filling the space with c if c !=
0
279 void resize(size_t nSize, char ch = '
\0');
280 // delete the contents of the string
282 // returns true if the string is empty
286 // return the character at position n
287 char at(size_t n) const;
288 // returns the writable character at position n
291 // lib.string.modifiers
293 wxString& append(const wxString& str);
294 // append elements str
[pos
], ..., str
[pos+n
]
295 wxString& append(const wxString& str, size_t pos, size_t n);
296 // append first n (or all if n == npos) characters of sz
297 wxString& append(const char *sz, size_t n = npos);
299 // append n copies of ch
300 wxString& append(size_t n, char ch);
302 // same as `this_string = str'
303 wxString& assign(const wxString& str);
304 // same as ` = str
[pos..pos + n
]
305 wxString& assign(const wxString& str, size_t pos, size_t n);
306 // same as `= first n (or all if n == npos) characters of sz'
307 wxString& assign(const char *sz, size_t n = npos);
308 // same as `= n copies of ch'
309 wxString& assign(size_t n, char ch);
311 // insert another string
312 wxString& insert(size_t nPos, const wxString& str);
313 // insert n chars of str starting at nStart (in str)
314 wxString& insert(size_t nPos, const wxString& str, size_t nStart, size_t n);
316 // insert first n (or all if n == npos) characters of sz
317 wxString& insert(size_t nPos, const char *sz, size_t n = npos);
318 // insert n copies of ch
319 wxString& insert(size_t nPos, size_t n, char ch);
321 // delete characters from nStart to nStart + nLen
322 wxString& erase(size_t nStart =
0, size_t nLen = npos);
324 // replaces the substring of length nLen starting at nStart
325 wxString& replace(size_t nStart, size_t nLen, const char* sz);
326 // replaces the substring with nCount copies of ch
327 wxString& replace(size_t nStart, size_t nLen, size_t nCount, char ch);
328 // replaces a substring with another substring
329 wxString& replace(size_t nStart, size_t nLen,
330 const wxString& str, size_t nStart2, size_t nLen2);
331 // replaces the substring with first nCount chars of sz
332 wxString& replace(size_t nStart, size_t nLen,
333 const char* sz, size_t nCount);
336 void swap(wxString& str);
338 // All find() functions take the nStart argument which specifies the
339 // position to start the search on, the default value is
0. All functions
340 // return npos if there were no match.
343 size_t find(const wxString& str, size_t nStart =
0) const;
345 // find first n characters of sz
346 size_t find(const char* sz, size_t nStart =
0, size_t n = npos) const;
348 // find the first occurrence of character ch after nStart
349 size_t find(char ch, size_t nStart =
0) const;
351 // rfind() family is exactly like find() but works right to left
353 // as find, but from the end
354 size_t rfind(const wxString& str, size_t nStart = npos) const;
356 // as find, but from the end
357 size_t rfind(const char* sz, size_t nStart = npos,
358 size_t n = npos) const;
359 // as find, but from the end
360 size_t rfind(char ch, size_t nStart = npos) const;
362 // find first/last occurrence of any character in the set
365 size_t find_first_of(const wxString& str, size_t nStart =
0) const;
367 size_t find_first_of(const char* sz, size_t nStart =
0) const;
368 // same as find(char, size_t)
369 size_t find_first_of(char c, size_t nStart =
0) const;
371 size_t find_last_of (const wxString& str, size_t nStart = npos) const;
373 size_t find_last_of (const char* s, size_t nStart = npos) const;
374 // same as rfind(char, size_t)
375 size_t find_last_of (char c, size_t nStart = npos) const;
377 // find first/last occurrence of any character not in the set
380 size_t find_first_not_of(const wxString& str, size_t nStart =
0) const;
382 size_t find_first_not_of(const char* s, size_t nStart =
0) const;
384 size_t find_first_not_of(char ch, size_t nStart =
0) const;
386 size_t find_last_not_of(const wxString& str, size_t nStart=npos) const;
388 size_t find_last_not_of(const char* s, size_t nStart = npos) const;
390 size_t find_last_not_of(char ch, size_t nStart = npos) const;
392 // All compare functions return a negative, zero or positive value
393 // if the
[sub
]string is less, equal or greater than the compare() argument.
395 // just like strcmp()
396 int compare(const wxString& str) const;
397 // comparison with a substring
398 int compare(size_t nStart, size_t nLen, const wxString& str) const;
399 // comparison of
2 substrings
400 int compare(size_t nStart, size_t nLen,
401 const wxString& str, size_t nStart2, size_t nLen2) const;
402 // just like strcmp()
403 int compare(const char* sz) const;
404 // substring comparison with first nCount characters of sz
405 int compare(size_t nStart, size_t nLen,
406 const char* sz, size_t nCount = npos) const;
408 // substring extraction
409 wxString substr(size_t nStart =
0, size_t nLen = npos) const;
412 %%%%% MEMBERS HERE %%%%%
413 \helponly{\insertatlevel{2}{
420 \membersection{wxString::wxString
}\label{wxstringconstruct
}
422 \func{}{wxString
}{\void}
424 Default constructor. Initializes the string to
{\tt ""
} (empty string).
426 \func{}{wxString
}{\param{const wxString\&
}{ x
}}
430 \func{}{wxString
}{\param{wxChar
}{ ch
},
\param{size
\_t}{ n =
1}}
432 Constructs a string of
{\it n
} copies of character
{\it ch
}.
434 \func{}{wxString
}{\param{const wxChar*
}{ psz
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
436 Takes first
{\it nLength
} characters from the C string
{\it psz
}.
437 The default value of
{\tt wxSTRING
\_MAXLEN} means to take all the string.
439 Note that this constructor may be used even if
{\it psz
} points to a buffer
440 with binary data (i.e. containing
{\tt NUL
} characters) as long as you provide
441 the correct value for
{\it nLength
}. However, the default form of it works
442 only with strings without intermediate
{\tt NUL
}s because it uses
443 {\tt strlen()
} to calculate the effective length and it would not give correct
446 \func{}{wxString
}{\param{const unsigned char*
}{ psz
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
448 For compilers using unsigned char: takes first
{\it nLength
} characters from the C string
{\it psz
}.
449 The default value of
{\tt wxSTRING
\_MAXLEN} means take all the string.
450 For ANSI builds only (note the use of
{\tt char
} instead of
{\tt wxChar
}).
452 \wxheading{Constructors with conversion
}
454 The following constructors allow you to construct wxString from a wide string
455 in ANSI build or from a C string in Unicode build.
457 \func{}{wxString
}{\param{const wchar
\_t*
}{ psz
},
\param{wxMBConv\&
}{ conv
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
459 Initializes the string from first
\arg{nLength
} characters of wide string.
460 The default value of
{\tt wxSTRING
\_MAXLEN} means take all the string.
461 In ANSI build,
\arg{conv
}'s
462 \helpref{WC2MB
}{wxmbconvwc2mb
} method is called to
463 convert
\arg{psz
} to wide string. It is ignored in Unicode build.
465 \func{}{wxString
}{\param{const char*
}{ psz
},
\param{wxMBConv\&
}{ conv = wxConvLibc
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
467 Initializes the string from first
\arg{nLength
} characters of C string.
468 The default value of
{\tt wxSTRING
\_MAXLEN} means take all the string.
469 In Unicode build,
\arg{conv
}'s
470 \helpref{MB2WC
}{wxmbconvmb2wc
} method is called to
471 convert
\arg{psz
} to wide string (the default converter uses current locale's
472 charset). It is ignored in ANSI build.
476 \helpref{wxMBConv classes
}{mbconvclasses
},
\helpref{mb
\_str}{wxstringmbstr
},
477 \helpref{wc
\_str}{wxstringwcstr
}
480 \membersection{wxString::
\destruct{wxString
}}\label{wxstringdestruct
}
482 \func{}{\destruct{wxString
}}{\void}
484 String destructor. Note that this is not virtual, so wxString must not be inherited from.
487 \membersection{wxString::Alloc
}\label{wxstringalloc
}
489 \func{void
}{Alloc
}{\param{size
\_t}{ nLen
}}
491 Preallocate enough space for wxString to store
{\it nLen
} characters. This function
492 may be used to increase speed when the string is constructed by repeated
497 // delete all vowels from the string
498 wxString DeleteAllVowels(const wxString& original)
502 size_t len = original.length();
506 for ( size_t n =
0; n < len; n++ )
508 if ( strchr("aeuio", tolower(original
[n
])) == NULL )
509 result += original
[n
];
517 because it will avoid the need to reallocate string memory many times (in case
518 of long strings). Note that it does not set the maximal length of a string - it
519 will still expand if more than
{\it nLen
} characters are stored in it. Also, it
520 does not truncate the existing string (use
521 \helpref{Truncate()
}{wxstringtruncate
} for this) even if its current length is
522 greater than
{\it nLen
}
525 \membersection{wxString::Append
}\label{wxstringappend
}
527 \func{wxString\&
}{Append
}{\param{const wxChar*
}{ psz
}}
529 Concatenates
{\it psz
} to this string, returning a reference to it.
531 \func{wxString\&
}{Append
}{\param{wxChar
}{ ch
},
\param{int
}{ count =
1}}
533 Concatenates character
{\it ch
} to this string,
{\it count
} times, returning a reference
537 \membersection{wxString::AfterFirst
}\label{wxstringafterfirst
}
539 \constfunc{wxString
}{AfterFirst
}{\param{wxChar
}{ ch
}}
541 Gets all the characters after the first occurrence of
{\it ch
}.
542 Returns the empty string if
{\it ch
} is not found.
545 \membersection{wxString::AfterLast
}\label{wxstringafterlast
}
547 \constfunc{wxString
}{AfterLast
}{\param{wxChar
}{ ch
}}
549 Gets all the characters after the last occurrence of
{\it ch
}.
550 Returns the whole string if
{\it ch
} is not found.
553 \membersection{wxString::BeforeFirst
}\label{wxstringbeforefirst
}
555 \constfunc{wxString
}{BeforeFirst
}{\param{wxChar
}{ ch
}}
557 Gets all characters before the first occurrence of
{\it ch
}.
558 Returns the whole string if
{\it ch
} is not found.
561 \membersection{wxString::BeforeLast
}\label{wxstringbeforelast
}
563 \constfunc{wxString
}{BeforeLast
}{\param{wxChar
}{ ch
}}
565 Gets all characters before the last occurrence of
{\it ch
}.
566 Returns the empty string if
{\it ch
} is not found.
569 \membersection{wxString::c
\_str}\label{wxstringcstr
}
571 \constfunc{const wxChar *
}{c
\_str}{\void}
573 Returns a pointer to the string data (
{\tt const char*
} in ANSI build,
574 {\tt const wchar
\_t*
} in Unicode build).
578 \helpref{mb
\_str}{wxstringmbstr
},
\helpref{wc
\_str}{wxstringwcstr
},
579 \helpref{fn
\_str}{wxstringfnstr
}
582 \membersection{wxString::Clear
}\label{wxstringclear
}
584 \func{void
}{Clear
}{\void}
586 Empties the string and frees memory occupied by it.
588 See also:
\helpref{Empty
}{wxstringempty
}
591 \membersection{wxString::Cmp
}\label{wxstringcmp
}
593 \constfunc{int
}{Cmp
}{\param{const wxString\&
}{ s
}}
595 \constfunc{int
}{Cmp
}{\param{const wxChar*
}{ psz
}}
597 Case-sensitive comparison.
599 Returns a positive value if the string is greater than the argument, zero if
600 it is equal to it or a negative value if it is less than the argument (same semantics
601 as the standard
{\it strcmp()
} function).
603 See also
\helpref{CmpNoCase
}{wxstringcmpnocase
},
\helpref{IsSameAs
}{wxstringissameas
}.
606 \membersection{wxString::CmpNoCase
}\label{wxstringcmpnocase
}
608 \constfunc{int
}{CmpNoCase
}{\param{const wxString\&
}{ s
}}
610 \constfunc{int
}{CmpNoCase
}{\param{const wxChar*
}{ psz
}}
612 Case-insensitive comparison.
614 Returns a positive value if the string is greater than the argument, zero if
615 it is equal to it or a negative value if it is less than the argument (same semantics
616 as the standard
{\it strcmp()
} function).
618 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{IsSameAs
}{wxstringissameas
}.
621 \membersection{wxString::CompareTo
}\label{wxstringcompareto
}
624 enum wxString::caseCompare
{exact, ignoreCase
};
627 \constfunc{int
}{CompareTo
}{\param{const wxChar*
}{ psz
},
\param{caseCompare
}{ cmp = exact
}}
629 Case-sensitive comparison. Returns
0 if equal,
1 if greater or -
1 if less.
631 This is a wxWidgets
1.xx compatibility function; use
\helpref{Cmp
}{wxstringcmp
} instead.
634 \membersection{wxString::Contains
}\label{wxstringcontains
}
636 \constfunc{bool
}{Contains
}{\param{const wxString\&
}{ str
}}
638 Returns
\true if target appears anywhere in wxString; else
\false.
640 This is a wxWidgets
1.xx compatibility function; you should not use it in new code.
643 \membersection{wxString::Empty
}\label{wxstringempty
}
645 \func{void
}{Empty
}{\void}
647 Makes the string empty, but doesn't free memory occupied by the string.
649 See also:
\helpref{Clear()
}{wxstringclear
}.
652 \membersection{wxString::Find
}\label{wxstringfind
}
654 \constfunc{int
}{Find
}{\param{wxChar
}{ ch
},
\param{bool
}{ fromEnd = false
}}
656 Searches for the given character. Returns the starting index, or
{\tt wxNOT
\_FOUND} if not found.
658 \constfunc{int
}{Find
}{\param{const wxChar*
}{ sz
}}
660 Searches for the given string. Returns the starting index, or
{\tt wxNOT
\_FOUND} if not found.
663 \membersection{wxString::First
}\label{wxstringfirst
}
665 \func{int
}{First
}{\param{wxChar
}{ c
}}
667 \constfunc{int
}{First
}{\param{const wxChar*
}{ psz
}}
669 \constfunc{int
}{First
}{\param{const wxString\&
}{ str
}}
671 Same as
\helpref{Find
}{wxstringfind
}.
673 This is a wxWidgets
1.xx compatibility function; you should not use it in new code.
676 \membersection{wxString::fn
\_str}\label{wxstringfnstr
}
678 \constfunc{const wchar
\_t*
}{fn
\_str}{\void}
680 \constfunc{const char*
}{fn
\_str}{\void}
682 \constfunc{const wxCharBuffer
}{fn
\_str}{\void}
684 Returns string representation suitable for passing to OS' functions for
685 file handling. In ANSI build, this is same as
\helpref{c
\_str}{wxstringcstr
}.
686 In Unicode build, returned value can be either wide character string
687 or C string in charset matching the
{\tt wxConvFileName
} object, depending on
692 \helpref{wxMBConv
}{wxmbconv
},
693 \helpref{wc
\_str}{wxstringwcstr
},
\helpref{mb
\_str}{wxstringwcstr
}
696 \membersection{wxString::Format
}\label{wxstringformat
}
698 \func{static wxString
}{Format
}{\param{const wxChar
}{*format
},
\param{}{...
}}
700 This static function returns the string containing the result of calling
701 \helpref{Printf
}{wxstringprintf
} with the passed parameters on it.
705 \helpref{FormatV
}{wxstringformatv
},
\helpref{Printf
}{wxstringprintf
}
708 \membersection{wxString::FormatV
}\label{wxstringformatv
}
710 \func{static wxString
}{FormatV
}{\param{const wxChar
}{*format
},
\param{va
\_list }{argptr
}}
712 This static function returns the string containing the result of calling
713 \helpref{PrintfV
}{wxstringprintfv
} with the passed parameters on it.
717 \helpref{Format
}{wxstringformat
},
\helpref{PrintfV
}{wxstringprintfv
}
720 \membersection{wxString::Freq
}\label{wxstringfreq
}
722 \constfunc{int
}{Freq
}{\param{wxChar
}{ch
}}
724 Returns the number of occurrences of
{\it ch
} in the string.
726 This is a wxWidgets
1.xx compatibility function; you should not use it in new code.
729 \membersection{wxString::FromAscii
}\label{wxstringfromascii
}
731 \func{static wxString
}{FromAscii
}{\param{const char*
}{ s
}}
733 \func{static wxString
}{FromAscii
}{\param{const char
}{ c
}}
735 Converts the string or character from an ASCII,
7-bit form
736 to the native wxString representation. Most useful when using
737 a Unicode build of wxWidgets (note the use of
{\tt char
} instead of
{\tt wxChar
}).
738 Use
\helpref{wxString constructors
}{wxstringconstruct
} if you
739 need to convert from another charset.
742 \membersection{wxString::GetChar
}\label{wxstringgetchar
}
744 \constfunc{wxChar
}{GetChar
}{\param{size
\_t}{ n
}}
746 Returns the character at position
{\it n
} (read-only).
749 \membersection{wxString::GetData
}\label{wxstringgetdata
}
751 \constfunc{const wxChar*
}{GetData
}{\void}
753 wxWidgets compatibility conversion. Returns a constant pointer to the data in the string.
756 \membersection{wxString::GetWritableChar
}\label{wxstringgetwritablechar
}
758 \func{wxChar\&
}{GetWritableChar
}{\param{size
\_t}{ n
}}
760 Returns a reference to the character at position
{\it n
}.
763 \membersection{wxString::GetWriteBuf
}\label{wxstringgetwritebuf
}
765 \func{wxChar*
}{GetWriteBuf
}{\param{size
\_t}{ len
}}
767 Returns a writable buffer of at least
{\it len
} bytes.
768 It returns a pointer to a new memory block, and the
769 existing data will not be copied.
771 Call
\helpref{wxString::UngetWriteBuf
}{wxstringungetwritebuf
} as soon as
772 possible to put the string back into a reasonable state.
774 This method is deprecated, please use
775 \helpref{wxStringBuffer
}{wxstringbuffer
} or
776 \helpref{wxStringBufferLength
}{wxstringbufferlength
} instead.
779 \membersection{wxString::Index
}\label{wxstringindex
}
781 \constfunc{size
\_t}{Index
}{\param{wxChar
}{ ch
}}
783 \constfunc{size
\_t}{Index
}{\param{const wxChar*
}{ sz
}}
785 Same as
\helpref{wxString::Find
}{wxstringfind
}.
787 This is a wxWidgets
1.xx compatibility function; you should not use it in new code.
790 \membersection{wxString::IsAscii
}\label{wxstringisascii
}
792 \constfunc{bool
}{IsAscii
}{\void}
794 Returns
\true if the string contains only ASCII characters.
796 This is a wxWidgets
1.xx compatibility function; you should not use it in new code.
799 \membersection{wxString::IsEmpty
}\label{wxstringisempty
}
801 \constfunc{bool
}{IsEmpty
}{\void}
803 Returns
\true if the string is empty.
806 \membersection{wxString::IsNull
}\label{wxstringisnull
}
808 \constfunc{bool
}{IsNull
}{\void}
810 Returns
\true if the string is empty (same as
\helpref{IsEmpty
}{wxstringisempty
}).
812 This is a wxWidgets
1.xx compatibility function; you should not use it in new code.
815 \membersection{wxString::IsNumber
}\label{wxstringisnumber
}
817 \constfunc{bool
}{IsNumber
}{\void}
819 Returns
\true if the string is an integer (with possible sign).
821 This is a wxWidgets
1.xx compatibility function; you should not use it in new code.
824 \membersection{wxString::IsSameAs
}\label{wxstringissameas
}
826 \constfunc{bool
}{IsSameAs
}{\param{const wxChar*
}{ psz
},
\param{bool
}{ caseSensitive = true
}}
828 Test for string equality, case-sensitive (default) or not.
830 caseSensitive is
\true by default (case matters).
832 Returns
\true if strings are equal,
\false otherwise.
834 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{CmpNoCase
}{wxstringcmpnocase
}
836 \constfunc{bool
}{IsSameAs
}{\param{wxChar
}{ c
},
\param{bool
}{ caseSensitive = true
}}
838 Test whether the string is equal to the single character
{\it c
}. The test is
839 case-sensitive if
{\it caseSensitive
} is
\true (default) or not if it is
\false.
841 Returns
\true if the string is equal to the character,
\false otherwise.
843 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{CmpNoCase
}{wxstringcmpnocase
}
846 \membersection{wxString::IsWord
}\label{wxstringisword
}
848 \constfunc{bool
}{IsWord
}{\void}
850 Returns
\true if the string is a word.
852 This is a wxWidgets
1.xx compatibility function; you should not use it in new code.
855 \membersection{wxString::Last
}\label{wxstringlast
}
857 \constfunc{wxChar
}{Last
}{\void}
859 Returns the last character.
861 \func{wxChar\&
}{Last
}{\void}
863 Returns a reference to the last character (writable).
865 This is a wxWidgets
1.xx compatibility function; you should not use it in new code.
868 \membersection{wxString::Left
}\label{wxstringleft
}
870 \constfunc{wxString
}{Left
}{\param{size
\_t}{ count
}}
872 Returns the first
{\it count
} characters of the string.
875 \membersection{wxString::Len
}\label{wxstringlen
}
877 \constfunc{size
\_t}{Len
}{\void}
879 Returns the length of the string.
882 \membersection{wxString::Length
}\label{wxstringlength
}
884 \constfunc{size
\_t}{Length
}{\void}
886 Returns the length of the string (same as Len).
888 This is a wxWidgets
1.xx compatibility function; you should not use it in new code.
891 \membersection{wxString::Lower
}\label{wxstringlower
}
893 \constfunc{wxString
}{Lower
}{\void}
895 Returns this string converted to the lower case.
898 \membersection{wxString::LowerCase
}\label{wxstringlowercase
}
900 \func{void
}{LowerCase
}{\void}
904 This is a wxWidgets
1.xx compatibility function; you should not use it in new code.
907 \membersection{wxString::MakeLower
}\label{wxstringmakelower
}
909 \func{wxString\&
}{MakeLower
}{\void}
911 Converts all characters to lower case and returns the result.
914 \membersection{wxString::MakeUpper
}\label{wxstringmakeupper
}
916 \func{wxString\&
}{MakeUpper
}{\void}
918 Converts all characters to upper case and returns the result.
921 \membersection{wxString::Matches
}\label{wxstringmatches
}
923 \constfunc{bool
}{Matches
}{\param{const wxChar*
}{ szMask
}}
925 Returns
\true if the string contents matches a mask containing '*' and '?'.
928 \membersection{wxString::mb
\_str}\label{wxstringmbstr
}
930 \constfunc{const char*
}{mb
\_str}{\param{wxMBConv\&
}{ conv = wxConvLibc
}}
932 \constfunc{const wxCharBuffer
}{mb
\_str}{\param{wxMBConv\&
}{ conv = wxConvLibc
}}
934 Returns multibyte (C string) representation of the string.
935 In Unicode build, converts using
\arg{conv
}'s
\helpref{cWC2MB
}{wxmbconvcwc2mb
}
936 method and returns wxCharBuffer. In ANSI build, this function is same
937 as
\helpref{c
\_str}{wxstringcstr
}.
938 The macro wxWX2MBbuf is defined as the correct return type (without const).
942 \helpref{wxMBConv
}{wxmbconv
},
943 \helpref{c
\_str}{wxstringcstr
},
\helpref{wc
\_str}{wxstringwcstr
},
944 \helpref{fn
\_str}{wxstringfnstr
}
947 \membersection{wxString::Mid
}\label{wxstringmid
}
949 \constfunc{wxString
}{Mid
}{\param{size
\_t}{ first
},
\param{size
\_t}{ count = wxSTRING
\_MAXLEN}}
951 Returns a substring starting at
{\it first
}, with length
{\it count
}, or the rest of
952 the string if
{\it count
} is the default value.
955 \membersection{wxString::Pad
}\label{wxstringpad
}
957 \func{wxString\&
}{Pad
}{\param{size
\_t}{ count
},
\param{wxChar
}{ pad = ' '
},
\param{bool
}{ fromRight = true
}}
959 Adds
{\it count
} copies of
{\it pad
} to the beginning, or to the end of the string (the default).
961 Removes spaces from the left or from the right (default).
964 \membersection{wxString::Prepend
}\label{wxstringprepend
}
966 \func{wxString\&
}{Prepend
}{\param{const wxString\&
}{ str
}}
968 Prepends
{\it str
} to this string, returning a reference to this string.
971 \membersection{wxString::Printf
}\label{wxstringprintf
}
973 \func{int
}{Printf
}{\param{const wxChar*
}{pszFormat
},
\param{}{...
}}
975 Similar to the standard function
{\it sprintf()
}. Returns the number of
976 characters written, or an integer less than zero on error.
978 Note that if
{\tt wxUSE
\_PRINTF\_POS\_PARAMS} is set to
1, then this function supports
979 Unix98-style positional parameters:
984 str.Printf(wxT("
%d %d %d"), 1, 2, 3);
985 // str now contains "
1 2 3"
987 str.Printf(wxT("
%2$d %3$d %1$d"), 1, 2, 3);
988 // str now contains "
2 3 1"
991 {\bf NB:
} This function will use a safe version of
{\it vsprintf()
} (usually called
992 {\it vsnprintf()
}) whenever available to always allocate the buffer of correct
993 size. Unfortunately, this function is not available on all platforms and the
994 dangerous
{\it vsprintf()
} will be used then which may lead to buffer overflows.
997 \membersection{wxString::PrintfV
}\label{wxstringprintfv
}
999 \func{int
}{PrintfV
}{\param{const wxChar*
}{pszFormat
},
\param{va
\_list}{ argPtr
}}
1001 Similar to vprintf. Returns the number of characters written, or an integer less than zero
1005 \membersection{wxString::Remove
}\label{wxstringremove
}
1007 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
}}
1009 Same as Truncate. Removes the portion from
{\it pos
} to the end of the string.
1011 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
},
\param{size
\_t}{ len
}}
1013 Removes
{\it len
} characters from the string, starting at
{\it pos
}.
1015 This is a wxWidgets
1.xx compatibility function; you should not use it in new code.
1018 \membersection{wxString::RemoveLast
}\label{wxstringremovelast
}
1020 \func{wxString\&
}{RemoveLast
}{\void}
1022 Removes the last character.
1025 \membersection{wxString::Replace
}\label{wxstringreplace
}
1027 \func{size
\_t}{Replace
}{\param{const wxChar*
}{ szOld
},
\param{const wxChar*
}{ szNew
},
\param{bool
}{ replaceAll = true
}}
1029 Replace first (or all) occurrences of substring with another one.
1031 {\it replaceAll
}: global replace (default), or only the first occurrence.
1033 Returns the number of replacements made.
1036 \membersection{wxString::Right
}\label{wxstringright
}
1038 \constfunc{wxString
}{Right
}{\param{size
\_t}{ count
}}
1040 Returns the last
{\it count
} characters.
1043 \membersection{wxString::SetChar
}\label{wxstringsetchar
}
1045 \func{void
}{SetChar
}{\param{size
\_t}{ n
},
\param{wxChar
}{ch
}}
1047 Sets the character at position
{\it n
}.
1050 \membersection{wxString::Shrink
}\label{wxstringshrink
}
1052 \func{void
}{Shrink
}{\void}
1054 Minimizes the string's memory. This can be useful after a call to
1055 \helpref{Alloc()
}{wxstringalloc
} if too much memory were preallocated.
1058 \membersection{wxString::StartsWith
}\label{wxstringstartswith
}
1060 \constfunc{bool
}{StartsWith
}{\param{const wxChar
}{*prefix
},
\param{wxString
}{*rest = NULL
}}
1062 This function can be used to test if the string starts with the specified
1063 {\it prefix
}. If it does, the function will return
\true and put the rest
1064 of the string (i.e. after the prefix) into
{\it rest
} string if it is not
1065 {\tt NULL
}. Otherwise, the function returns
\false and doesn't modify the
1069 \membersection{wxString::EndsWith
}\label{wxstringendswith
}
1071 \constfunc{bool
}{EndsWith
}{\param{const wxChar
}{*suffix
},
\param{wxString
}{*rest = NULL
}}
1073 This function can be used to test if the string ends with the specified
1074 {\it suffix
}. If it does, the function will return
\true and put the
1075 beginning of the string before the suffix into
{\it rest
} string if it is not
1076 {\tt NULL
}. Otherwise, the function returns
\false and doesn't
1077 modify the
{\it rest
}.
1080 \membersection{wxString::Strip
}\label{wxstringstrip
}
1083 enum wxString::stripType
{leading =
0x1, trailing =
0x2, both =
0x3};
1086 \constfunc{wxString
}{Strip
}{\param{stripType
}{ s = trailing
}}
1088 Strip characters at the front and/or end. The same as Trim except that it
1089 doesn't change this string.
1091 This is a wxWidgets
1.xx compatibility function; you should not use it in new code.
1094 \membersection{wxString::SubString
}\label{wxstringsubstring
}
1096 \constfunc{wxString
}{SubString
}{\param{size
\_t}{ from
},
\param{size
\_t}{ to
}}
1098 Returns the part of the string between the indices
{\it from
} and
{\it to
}
1101 This is a wxWidgets
1.xx compatibility function, use
\helpref{Mid
}{wxstringmid
}
1102 instead (but note that parameters have different meaning).
1105 \membersection{wxString::ToAscii
}\label{wxstringtoascii
}
1107 \constfunc{const char*
}{ToAscii
}{\void}
1109 Converts the string to an ASCII,
7-bit string (ANSI builds only).
1111 \constfunc{const wxCharBuffer
}{ToAscii
}{\void}
1113 Converts the string to an ASCII,
7-bit string in the form of
1114 a wxCharBuffer (Unicode builds only).
1116 Note that this conversion only works if the string contains only ASCII
1117 characters. The
\helpref{mb
\_str}{wxstringmbstr
} method provides more
1118 powerful means of converting wxString to C string.
1121 \membersection{wxString::ToDouble
}\label{wxstringtodouble
}
1123 \constfunc{bool
}{ToDouble
}{\param{double
}{ *val
}}
1125 Attempts to convert the string to a floating point number. Returns
\true on
1126 success (the number is stored in the location pointed to by
{\it val
}) or
\false
1127 if the string does not represent such number.
1129 \wxheading{See also
}
1131 \helpref{wxString::ToLong
}{wxstringtolong
},\\
1132 \helpref{wxString::ToULong
}{wxstringtoulong
}
1135 \membersection{wxString::ToLong
}\label{wxstringtolong
}
1137 \constfunc{bool
}{ToLong
}{\param{long
}{ *val
},
\param{int
}{base = $
10$
}}
1139 Attempts to convert the string to a signed integer in base
{\it base
}. Returns
1140 \true on success in which case the number is stored in the location
1141 pointed to by
{\it val
} or
\false if the string does not represent a
1142 valid number in the given base.
1144 The value of
{\it base
} must be comprised between $
2$ and $
36$, inclusive, or
1145 be a special value $
0$ which means that the usual rules of
{\tt C
} numbers are
1146 applied: if the number starts with
{\tt 0x
} it is considered to be in base
1147 $
16$, if it starts with
{\tt 0} - in base $
8$ and in base $
10$ otherwise. Note
1148 that you may not want to specify the base $
0$ if you are parsing the numbers
1149 which may have leading zeroes as they can yield unexpected (to the user not
1150 familiar with C) results.
1152 \wxheading{See also
}
1154 \helpref{wxString::ToDouble
}{wxstringtodouble
},\\
1155 \helpref{wxString::ToULong
}{wxstringtoulong
}
1158 \membersection{wxString::ToLongLong
}\label{wxstringtolonglong
}
1160 \constfunc{bool
}{ToLongLong
}{\param{wxLongLong
\_t}{ *val
},
\param{int
}{base = $
10$
}}
1162 This is exactly the same as
\helpref{ToLong
}{wxstringtolong
} but works with
64
1163 bit integer numbers.
1165 Notice that currently it doesn't work (always returns
\false) if parsing of
64
1166 bit numbers is not supported by the underlying C run-time library. Compilers
1167 with C99 support and Microsoft Visual C++ version
7 and higher do support this.
1169 \wxheading{See also
}
1171 \helpref{wxString::ToLong
}{wxstringtolong
},\\
1172 \helpref{wxString::ToULongLong
}{wxstringtoulonglong
}
1175 \membersection{wxString::ToULong
}\label{wxstringtoulong
}
1177 \constfunc{bool
}{ToULong
}{\param{unsigned long
}{ *val
},
\param{int
}{base = $
10$
}}
1179 Attempts to convert the string to an unsigned integer in base
{\it base
}.
1180 Returns
\true on success in which case the number is stored in the
1181 location pointed to by
{\it val
} or
\false if the string does not
1182 represent a valid number in the given base. Please notice that this function
1183 behaves in the same way as the standard
\texttt{strtoul()
} and so it simply
1184 converts negative numbers to unsigned representation instead of rejecting them
1185 (e.g. $-
1$ is returned as
\texttt{ULONG
\_MAX}).
1187 See
\helpref{wxString::ToLong
}{wxstringtolong
} for the more detailed
1188 description of the
{\it base
} parameter.
1190 \wxheading{See also
}
1192 \helpref{wxString::ToDouble
}{wxstringtodouble
},\\
1193 \helpref{wxString::ToLong
}{wxstringtolong
}
1196 \membersection{wxString::ToULongLong
}\label{wxstringtoulonglong
}
1198 \constfunc{bool
}{ToULongLong
}{\param{wxULongLong
\_t}{ *val
},
\param{int
}{base = $
10$
}}
1200 This is exactly the same as
\helpref{ToULong
}{wxstringtoulong
} but works with
64
1201 bit integer numbers.
1203 Please see
\helpref{ToLongLong
}{wxstringtolonglong
} for additional remarks.
1206 \membersection{wxString::Trim
}\label{wxstringtrim
}
1208 \func{wxString\&
}{Trim
}{\param{bool
}{ fromRight = true
}}
1210 Removes white-space (space, tabs, form feed, newline and carriage return) from
1211 the left or from the right end of the string (right is default).
1214 \membersection{wxString::Truncate
}\label{wxstringtruncate
}
1216 \func{wxString\&
}{Truncate
}{\param{size
\_t}{ len
}}
1218 Truncate the string to the given length.
1221 \membersection{wxString::UngetWriteBuf
}\label{wxstringungetwritebuf
}
1223 \func{void
}{UngetWriteBuf
}{\void}
1225 \func{void
}{UngetWriteBuf
}{\param{size
\_t }{len
}}
1227 Puts the string back into a reasonable state (in which it can be used
1229 \rtfsp\helpref{wxString::GetWriteBuf
}{wxstringgetwritebuf
} was called.
1231 The version of the function without the
{\it len
} parameter will calculate the
1232 new string length itself assuming that the string is terminated by the first
1233 {\tt NUL
} character in it while the second one will use the specified length
1234 and thus is the only version which should be used with the strings with
1235 embedded
{\tt NUL
}s (it is also slightly more efficient as
{\tt strlen()
}
1236 doesn't have to be called).
1238 This method is deprecated, please use
1239 \helpref{wxStringBuffer
}{wxstringbuffer
} or
1240 \helpref{wxStringBufferLength
}{wxstringbufferlength
} instead.
1243 \membersection{wxString::Upper
}\label{wxstringupper
}
1245 \constfunc{wxString
}{Upper
}{\void}
1247 Returns this string converted to upper case.
1250 \membersection{wxString::UpperCase
}\label{wxstringuppercase
}
1252 \func{void
}{UpperCase
}{\void}
1254 The same as MakeUpper.
1256 This is a wxWidgets
1.xx compatibility function; you should not use it in new code.
1259 \membersection{wxString::wc
\_str}\label{wxstringwcstr
}
1261 \constfunc{const wchar
\_t*
}{wc
\_str}{\param{wxMBConv\&
}{ conv
}}
1263 \constfunc{const wxWCharBuffer
}{wc
\_str}{\param{wxMBConv\&
}{ conv
}}
1265 Returns wide character representation of the string.
1266 In ANSI build, converts using
\arg{conv
}'s
\helpref{cMB2WC
}{wxmbconvcmb2wc
}
1267 method and returns wxWCharBuffer. In Unicode build, this function is same
1268 as
\helpref{c
\_str}{wxstringcstr
}.
1269 The macro wxWX2WCbuf is defined as the correct return type (without const).
1271 \wxheading{See also
}
1273 \helpref{wxMBConv
}{wxmbconv
},
1274 \helpref{c
\_str}{wxstringcstr
},
\helpref{mb
\_str}{wxstringwcstr
},
1275 \helpref{fn
\_str}{wxstringfnstr
}
1278 \membersection{wxString::operator!
}\label{wxstringoperatornot
}
1280 \constfunc{bool
}{operator!
}{\void}
1282 Empty string is
\false, so !string will only return
\true if the string is empty.
1283 This allows the tests for NULLness of a
{\it const wxChar *
} pointer and emptiness
1284 of the string to look the same in the code and makes it easier to port old code
1287 See also
\helpref{IsEmpty()
}{wxstringisempty
}.
1290 \membersection{wxString::operator $=$
}\label{wxstringoperatorassign
}
1292 \func{wxString\&
}{operator $=$
}{\param{const wxString\&
}{ str
}}
1294 \func{wxString\&
}{operator $=$
}{\param{const wxChar*
}{ psz
}}
1296 \func{wxString\&
}{operator $=$
}{\param{wxChar
}{ c
}}
1298 Assignment: the effect of each operation is the same as for the corresponding
1299 constructor (see
\helpref{wxString constructors
}{wxstringconstruct
}).
1302 \membersection{wxString::operator $+$
}\label{wxstringoperatorplus
}
1304 Concatenation: all these operators return a new string equal to the
1305 concatenation of the operands.
1307 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1309 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const wxChar*
}{ y
}}
1311 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{wxChar
}{ y
}}
1313 \func{wxString
}{operator $+$
}{\param{const wxChar*
}{ x
},
\param{const wxString\&
}{ y
}}
1316 \membersection{wxString::operator $+=$
}\label{wxstringplusequal
}
1318 \func{void
}{operator $+=$
}{\param{const wxString\&
}{ str
}}
1320 \func{void
}{operator $+=$
}{\param{const wxChar*
}{ psz
}}
1322 \func{void
}{operator $+=$
}{\param{wxChar
}{ c
}}
1324 Concatenation in place: the argument is appended to the string.
1327 \membersection{wxString::operator
[]}\label{wxstringoperatorbracket
}
1329 \func{wxChar\&
}{operator
[]}{\param{size
\_t}{ i
}}
1331 \constfunc{wxChar
}{operator
[]}{\param{size
\_t}{ i
}}
1333 \func{wxChar\&
}{operator
[]}{\param{int
}{ i
}}
1335 \constfunc{wxChar
}{operator
[]}{\param{int
}{ i
}}
1340 \membersection{wxString::operator ()
}\label{wxstringoperatorparenth
}
1342 \func{wxString
}{operator ()
}{\param{size
\_t}{ start
},
\param{size
\_t}{ len
}}
1344 Same as Mid (substring extraction).
1347 \membersection{wxString::operator
\cinsert}\label{wxstringoperatorout
}
1349 \func{wxString\&
}{operator
\cinsert}{\param{const wxString\&
}{ str
}}
1351 \func{wxString\&
}{operator
\cinsert}{\param{const wxChar*
}{ psz
}}
1353 \func{wxString\&
}{operator
\cinsert}{\param{wxChar
}{ch
}}
1357 \func{wxString\&
}{operator
\cinsert}{\param{int
}{ i
}}
1359 \func{wxString\&
}{operator
\cinsert}{\param{float
}{ f
}}
1361 \func{wxString\&
}{operator
\cinsert}{\param{double
}{ d
}}
1363 These functions work as C++ stream insertion operators: they insert the given
1364 value into the string. Precision or format cannot be set using them, you can use
1365 \helpref{Printf
}{wxstringprintf
} for this.
1368 \membersection{wxString::operator
\cextract}\label{wxstringoperatorin
}
1370 \func{friend istream\&
}{operator
\cextract}{\param{istream\&
}{ is
},
\param{wxString\&
}{ str
}}
1372 Extraction from a stream.
1375 \membersection{wxString::operator const wxChar*
}\label{wxstringoperatorconstcharpt
}
1377 \constfunc{}{operator const wxChar*
}{\void}
1379 Implicit conversion to a C string.
1382 \membersection{Comparison operators
}\label{wxstringcomparison
}
1384 \func{bool
}{operator $==$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1386 \func{bool
}{operator $==$
}{\param{const wxString\&
}{ x
},
\param{const wxChar*
}{ t
}}
1388 \func{bool
}{operator $!=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1390 \func{bool
}{operator $!=$
}{\param{const wxString\&
}{ x
},
\param{const wxChar*
}{ t
}}
1392 \func{bool
}{operator $>$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1394 \func{bool
}{operator $>$
}{\param{const wxString\&
}{ x
},
\param{const wxChar*
}{ t
}}
1396 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1398 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const wxChar*
}{ t
}}
1400 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1402 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const wxChar*
}{ t
}}
1404 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1406 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const wxChar*
}{ t
}}
1410 These comparisons are case-sensitive.
1413 \section{\class{wxStringBuffer
}}\label{wxstringbuffer
}
1415 This tiny class allows to conveniently access the
\helpref{wxString
}{wxstring
}
1416 internal buffer as a writable pointer without any risk of forgetting to restore
1417 the string to the usable state later.
1419 For example, assuming you have a low-level OS function called
1420 {\tt GetMeaningOfLifeAsString(char *)
} returning the value in the provided
1421 buffer (which must be writable, of course) you might call it like this:
1425 GetMeaningOfLifeAsString(wxStringBuffer(theAnswer,
1024));
1426 if ( theAnswer != "
42" )
1428 wxLogError("Something is very wrong!");
1432 Note that the exact usage of this depends on whether on not wxUSE
\_STL is enabled. If
1433 wxUSE
\_STL is enabled, wxStringBuffer creates a separate empty character buffer, and
1434 if wxUSE
\_STL is disabled, it uses GetWriteBuf() from wxString, keeping the same buffer
1435 wxString uses intact. In other words, relying on wxStringBuffer containing the old
1436 wxString data is probably not a good idea if you want to build your program in both
1437 with and without wxUSE
\_STL.
1439 \wxheading{Derived from
}
1443 \wxheading{Include files
}
1447 \latexignore{\rtfignore{\wxheading{Members
}}}
1450 \membersection{wxStringBuffer::wxStringBuffer
}\label{wxstringbufferctor
}
1452 \func{}{wxStringBuffer
}{\param{const wxString\&
}{str
},
\param{size
\_t }{len
}}
1454 Constructs a writable string buffer object associated with the given string
1455 and containing enough space for at least
{\it len
} characters. Basically, this
1456 is equivalent to calling
\helpref{GetWriteBuf
}{wxstringgetwritebuf
} and
1460 \membersection{wxStringBuffer::
\destruct{wxStringBuffer
}}\label{wxstringbufferdtor
}
1462 \func{}{\destruct{wxStringBuffer
}}{\void}
1464 Restores the string passed to the constructor to the usable state by calling
1465 \helpref{UngetWriteBuf
}{wxstringungetwritebuf
} on it.
1468 \membersection{wxStringBuffer::operator wxChar *
}\label{wxstringbufferwxchar
}
1470 \func{wxChar *
}{operator wxChar *
}{\void}
1472 Returns the writable pointer to a buffer of the size at least equal to the
1473 length specified in the constructor.
1477 \section{\class{wxStringBufferLength
}}\label{wxstringbufferlength
}
1479 This tiny class allows to conveniently access the
\helpref{wxString
}{wxstring
}
1480 internal buffer as a writable pointer without any risk of forgetting to restore
1481 the string to the usable state later, and allows the user to set the internal
1482 length of the string.
1484 For example, assuming you have a low-level OS function called
1485 {\tt int GetMeaningOfLifeAsString(char *)
} copying the value in the provided
1486 buffer (which must be writable, of course), and returning the actual length
1487 of the string, you might call it like this:
1491 wxStringBuffer theAnswerBuffer(theAnswer,
1024);
1492 int nLength = GetMeaningOfLifeAsString(theAnswerBuffer);
1493 theAnswerBuffer.SetLength(nLength);
1494 if ( theAnswer != "
42" )
1496 wxLogError("Something is very wrong!");
1500 Note that the exact usage of this depends on whether on not wxUSE
\_STL is enabled. If
1501 wxUSE
\_STL is enabled, wxStringBuffer creates a separate empty character buffer, and
1502 if wxUSE
\_STL is disabled, it uses GetWriteBuf() from wxString, keeping the same buffer
1503 wxString uses intact. In other words, relying on wxStringBuffer containing the old
1504 wxString data is probably not a good idea if you want to build your program in both
1505 with and without wxUSE
\_STL.
1507 Note that SetLength
{\tt must
} be called before wxStringBufferLength destructs.
1509 \wxheading{Derived from
}
1513 \wxheading{Include files
}
1517 \latexignore{\rtfignore{\wxheading{Members
}}}
1520 \membersection{wxStringBufferLength::wxStringBufferLength
}\label{wxstringbufferlengthctor
}
1522 \func{}{wxStringBufferLength
}{\param{const wxString\&
}{str
},
\param{size
\_t }{len
}}
1524 Constructs a writable string buffer object associated with the given string
1525 and containing enough space for at least
{\it len
} characters. Basically, this
1526 is equivalent to calling
\helpref{GetWriteBuf
}{wxstringgetwritebuf
} and
1530 \membersection{wxStringBufferLength::
\destruct{wxStringBufferLength
}}\label{wxstringbufferlengthdtor
}
1532 \func{}{\destruct{wxStringBufferLength
}}{\void}
1534 Restores the string passed to the constructor to the usable state by calling
1535 \helpref{UngetWriteBuf
}{wxstringungetwritebuf
} on it.
1538 \membersection{wxStringBufferLength::SetLength
}\label{wxstringbufferlengthsetlength
}
1540 \func{void
}{SetLength
}{\param{size
\_t }{nLength
}}
1542 Sets the internal length of the string referred to by wxStringBufferLength to
1543 {\it nLength
} characters.
1545 Must be called before wxStringBufferLength destructs.
1548 \membersection{wxStringBufferLength::operator wxChar *
}\label{wxstringbufferlengthwxchar
}
1550 \func{wxChar *
}{operator wxChar *
}{\void}
1552 Returns the writable pointer to a buffer of the size at least equal to the
1553 length specified in the constructor.