]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/wxstring.tex
fixed indentation in case there's only one cell on line
[wxWidgets.git] / docs / latex / wx / wxstring.tex
CommitLineData
a660d684
KB
1\section{\class{wxString}}\label{wxstring}
2
40b480c3
JS
3wxString is a class representing a character string. Please see the
4\helpref{wxString overview}{wxstringoverview} for more information about it. As explained
5there, wxString implements about 90\% of methods of the std::string class (iterators
6are not supported, nor all methods which use them).
7These standard functions are not documented in this manual so please see the STL documentation.
99f09bc1 8The behaviour of all these functions is identical to the behaviour described
e2101186 9there (except that wxString is sensitive to null character).
99f09bc1 10
0aa35d19
VZ
11You may notice that wxString sometimes has many functions which do the same
12thing like, for example, \helpref{Length()}{wxstringlength},
13\helpref{Len()}{wxstringlen} and {\tt length()} which all return the string
14length. In all cases of such duplication the {\tt std::string}-compatible
15method ({\tt length()} in this case, always the lowercase version) should be
fc2171bd 16used as it will ensure smoother transition to {\tt std::string} when wxWidgets
0aa35d19
VZ
17starts using it instead of wxString.
18
b3324be2
JS
19\wxheading{Derived from}
20
21None
a660d684 22
954b8ae6
JS
23\wxheading{Include files}
24
25<wx/string.h>
26
20e85460
JS
27\wxheading{Predefined objects}
28
29Objects:
30
31{\bf wxEmptyString}
32
b3324be2
JS
33\wxheading{See also}
34
35\overview{Overview}{wxstringoverview}
a660d684 36
99f09bc1
VZ
37\latexignore{\rtfignore{\wxheading{Function groups}}}
38
39\membersection{Constructors and assignment operators}
40
2edb0bde 41A string may be constructed either from a C string, (some number of copies of)
99f09bc1
VZ
42a single character or a wide (UNICODE) string. For all constructors (except the
43default which creates an empty string) there is also a corresponding assignment
44operator.
45
46\helpref{wxString}{wxstringconstruct}\\
47\helpref{operator $=$}{wxstringoperatorassign}\\
48\helpref{\destruct{wxString}}{wxstringdestruct}
49
50\membersection{String length}
51
52These functions return the string length and check whether the string is empty
53or empty it.
54
55\helpref{Len}{wxstringlen}\\
56\helpref{IsEmpty}{wxstringisempty}\\
57\helpref{operator!}{wxstringoperatornot}\\
58\helpref{Empty}{wxstringempty}\\
59\helpref{Clear}{wxstringclear}
60
61\membersection{Character access}
62
63Many functions in this section take a character index in the string. As with C
64strings and/or arrays, the indices start from $0$, so the first character of a
65string is string[$0$]. Attempt to access a character beyond the end of the
2edb0bde 66string (which may be even $0$ if the string is empty) will provoke an assert
99f09bc1
VZ
67failure in \helpref{debug build}{debuggingoverview}, but no checks are done in
68release builds.
69
70This section also contains both implicit and explicit conversions to C style
71strings. Although implicit conversion is quite convenient, it is advised to use
72explicit \helpref{c\_str()}{wxstringcstr} method for the sake of clarity. Also
fd34e3a5 73see \helpref{overview}{wxstringadvices} for the cases where it is necessary to
99f09bc1
VZ
74use it.
75
76\helpref{GetChar}{wxstringgetchar}\\
77\helpref{GetWritableChar}{wxstringgetwritablechar}\\
78\helpref{SetChar}{wxstringsetchar}\\
79\helpref{Last}{wxstringlast}\\
80\helpref{operator []}{wxstringoperatorbracket}\\
81\helpref{c\_str}{wxstringcstr}\\
82\helpref{operator const char*}{wxstringoperatorconstcharpt}
83
84\membersection{Concatenation}
85
86Anything may be concatenated (appended to) with a string. However, you can't
87append something to a C string (including literal constants), so to do this it
88should be converted to a wxString first.
89
90\helpref{operator \cinsert}{wxstringoperatorout}\\
91\helpref{operator $+=$}{wxstringplusequal}\\
92\helpref{operator $+$}{wxstringoperatorplus}\\
93\helpref{Append}{wxstringappend}\\
94\helpref{Prepend}{wxstringprepend}
95
96\membersection{Comparison}
97
98The default comparison function \helpref{Cmp}{wxstringcmp} is case-sensitive and
99so is the default version of \helpref{IsSameAs}{wxstringissameas}. For case
100insensitive comparisons you should use \helpref{CmpNoCase}{wxstringcmpnocase} or
101give a second parameter to IsSameAs. This last function is may be more
102convenient if only equality of the strings matters because it returns a boolean
cc81d32f 103true value if the strings are the same and not 0 (which is usually false in C)
f6bcfd97 104as {\tt Cmp()} does.
99f09bc1
VZ
105
106\helpref{Matches}{wxstringmatches} is a poor man's regular expression matcher:
107it only understands '*' and '?' metacharacters in the sense of DOS command line
108interpreter.
109
f6bcfd97
BP
110\helpref{StartsWith}{wxstringstartswith} is helpful when parsing a line of
111text which should start with some predefined prefix and is more efficient than
2edb0bde 112doing direct string comparison as you would also have to precalculate the
f6bcfd97
BP
113length of the prefix then.
114
99f09bc1
VZ
115\helpref{Cmp}{wxstringcmp}\\
116\helpref{CmpNoCase}{wxstringcmpnocase}\\
117\helpref{IsSameAs}{wxstringissameas}\\
f6bcfd97
BP
118\helpref{Matches}{wxstringmatches}\\
119\helpref{StartsWith}{wxstringstartswith}
99f09bc1
VZ
120
121\membersection{Substring extraction}
122
123These functions allow to extract substring from this string. All of them don't
124modify the original string and return a new string containing the extracted
125substring.
126
127\helpref{Mid}{wxstringmid}\\
128\helpref{operator()}{wxstringoperatorparenth}\\
129\helpref{Left}{wxstringleft}\\
130\helpref{Right}{wxstringright}\\
131\helpref{BeforeFirst}{wxstringbeforefirst}\\
132\helpref{BeforeLast}{wxstringbeforelast}\\
133\helpref{AfterFirst}{wxstringafterfirst}\\
f6bcfd97
BP
134\helpref{AfterLast}{wxstringafterlast}\\
135\helpref{StartsWith}{wxstringstartswith}
99f09bc1
VZ
136
137\membersection{Case conversion}
138
139The MakeXXX() variants modify the string in place, while the other functions
2edb0bde 140return a new string which contains the original text converted to the upper or
99f09bc1
VZ
141lower case and leave the original string unchanged.
142
143\helpref{MakeUpper}{wxstringmakeupper}\\
144\helpref{Upper}{wxstringupper}\\
145\helpref{MakeLower}{wxstringmakelower}\\
146\helpref{Lower}{wxstringlower}
147
148\membersection{Searching and replacing}
149
40b480c3 150These functions replace the standard {\it strchr()} and {\it strstr()}
99f09bc1
VZ
151functions.
152
153\helpref{Find}{wxstringfind}\\
154\helpref{Replace}{wxstringreplace}
155
cd0b1709
VZ
156\membersection{Conversion to numbers}
157
158The string provides functions for conversion to signed and unsigned integer and
159floating point numbers. All three functions take a pointer to the variable to
cc81d32f 160put the numeric value in and return true if the {\bf entire} string could be
cd0b1709
VZ
161converted to a number.
162
163\helpref{ToLong}{wxstringtolong}\\
164\helpref{ToULong}{wxstringtoulong}\\
165\helpref{ToDouble}{wxstringtodouble}
166
99f09bc1
VZ
167\membersection{Writing values into the string}
168
169Both formatted versions (\helpref{Printf}{wxstringprintf}) and stream-like
341e7d28
VZ
170insertion operators exist (for basic types only). Additionally, the
171\helpref{Format}{wxstringformat} function allows to use simply append
172formatted value to a string:
99f09bc1 173
341e7d28
VZ
174\begin{verbatim}
175 // the following 2 snippets are equivalent
176
177 wxString s = "...";
178 s += wxString::Format("%d", n);
179
180 wxString s;
181 s.Printf("...%d", n);
182\end{verbatim}
183
184\helpref{Format}{wxstringformat}\\
185\helpref{FormatV}{wxstringformatv}\\
99f09bc1
VZ
186\helpref{Printf}{wxstringprintf}\\
187\helpref{PrintfV}{wxstringprintfv}\\
40b480c3 188\helpref{operator \cinsert}{wxstringoperatorout}
99f09bc1
VZ
189
190\membersection{Memory management}
191
2edb0bde 192These are "advanced" functions and they will be needed quite rarely.
99f09bc1
VZ
193\helpref{Alloc}{wxstringalloc} and \helpref{Shrink}{wxstringshrink} are only
194interesting for optimization purposes.
195\helpref{GetWriteBuf}{wxstringgetwritebuf} may be very useful when working with
196some external API which requires the caller to provide a writable buffer, but
197extreme care should be taken when using it: before performing any other
198operation on the string \helpref{UngetWriteBuf}{wxstringungetwritebuf} {\bf
199must} be called!
200
201\helpref{Alloc}{wxstringalloc}\\
202\helpref{Shrink}{wxstringshrink}\\
203\helpref{GetWriteBuf}{wxstringgetwritebuf}\\
204\helpref{UngetWriteBuf}{wxstringungetwritebuf}
205
206\membersection{Miscellaneous}
207
208Other string functions.
209
210\helpref{Trim}{wxstringtrim}\\
211\helpref{Pad}{wxstringpad}\\
212\helpref{Truncate}{wxstringtruncate}
213
fc2171bd 214\membersection{wxWidgets 1.xx compatibility functions}
99f09bc1 215
fc2171bd 216These functions are deprecated, please consider using new wxWidgets 2.0
99f09bc1
VZ
217functions instead of them (or, even better, std::string compatible variants).
218
219\helpref{SubString}{wxstringsubstring}\\
220\helpref{sprintf}{wxstringsprintf}\\
221\helpref{CompareTo}{wxstringcompareto}\\
222\helpref{Length}{wxstringlength}\\
223\helpref{Freq}{wxstringfreq}\\
224\helpref{LowerCase}{wxstringlowercase}\\
225\helpref{UpperCase}{wxstringuppercase}\\
226\helpref{Strip}{wxstringstrip}\\
227\helpref{Index}{wxstringindex}\\
228\helpref{Remove}{wxstringremove}\\
229\helpref{First}{wxstringfirst}\\
230\helpref{Last}{wxstringlast}\\
231\helpref{Contains}{wxstringcontains}\\
232\helpref{IsNull}{wxstringisnull}\\
233\helpref{IsAscii}{wxstringisascii}\\
234\helpref{IsNumber}{wxstringisnumber}\\
235\helpref{IsWord}{wxstringisword}
236
ed93168b 237\membersection{std::string compatibility functions}\label{wxstringat}
99f09bc1
VZ
238
239The supported functions are only listed here, please see any STL reference for
240their documentation.
241
242\begin{verbatim}
243 // take nLen chars starting at nPos
244 wxString(const wxString& str, size_t nPos, size_t nLen);
245 // take all characters from pStart to pEnd (poor man's iterators)
246 wxString(const void *pStart, const void *pEnd);
247
248 // lib.string.capacity
249 // return the length of the string
250 size_t size() const;
251 // return the length of the string
252 size_t length() const;
253 // return the maximum size of the string
254 size_t max_size() const;
255 // resize the string, filling the space with c if c != 0
256 void resize(size_t nSize, char ch = '\0');
257 // delete the contents of the string
258 void clear();
259 // returns true if the string is empty
260 bool empty() const;
261
262 // lib.string.access
263 // return the character at position n
264 char at(size_t n) const;
265 // returns the writable character at position n
266 char& at(size_t n);
267
268 // lib.string.modifiers
269 // append a string
270 wxString& append(const wxString& str);
271 // append elements str[pos], ..., str[pos+n]
272 wxString& append(const wxString& str, size_t pos, size_t n);
273 // append first n (or all if n == npos) characters of sz
274 wxString& append(const char *sz, size_t n = npos);
275
276 // append n copies of ch
277 wxString& append(size_t n, char ch);
278
279 // same as `this_string = str'
280 wxString& assign(const wxString& str);
281 // same as ` = str[pos..pos + n]
282 wxString& assign(const wxString& str, size_t pos, size_t n);
283 // same as `= first n (or all if n == npos) characters of sz'
284 wxString& assign(const char *sz, size_t n = npos);
285 // same as `= n copies of ch'
286 wxString& assign(size_t n, char ch);
287
288 // insert another string
289 wxString& insert(size_t nPos, const wxString& str);
290 // insert n chars of str starting at nStart (in str)
291 wxString& insert(size_t nPos, const wxString& str, size_t nStart, size_t n);
292
293 // insert first n (or all if n == npos) characters of sz
294 wxString& insert(size_t nPos, const char *sz, size_t n = npos);
295 // insert n copies of ch
296 wxString& insert(size_t nPos, size_t n, char ch);
297
298 // delete characters from nStart to nStart + nLen
299 wxString& erase(size_t nStart = 0, size_t nLen = npos);
300
301 // replaces the substring of length nLen starting at nStart
302 wxString& replace(size_t nStart, size_t nLen, const char* sz);
303 // replaces the substring with nCount copies of ch
304 wxString& replace(size_t nStart, size_t nLen, size_t nCount, char ch);
305 // replaces a substring with another substring
306 wxString& replace(size_t nStart, size_t nLen,
307 const wxString& str, size_t nStart2, size_t nLen2);
308 // replaces the substring with first nCount chars of sz
309 wxString& replace(size_t nStart, size_t nLen,
310 const char* sz, size_t nCount);
311
312 // swap two strings
313 void swap(wxString& str);
314
315 // All find() functions take the nStart argument which specifies the
316 // position to start the search on, the default value is 0. All functions
317 // return npos if there were no match.
318
319 // find a substring
320 size_t find(const wxString& str, size_t nStart = 0) const;
321
322 // find first n characters of sz
323 size_t find(const char* sz, size_t nStart = 0, size_t n = npos) const;
324
7335902d 325 // find the first occurrence of character ch after nStart
99f09bc1
VZ
326 size_t find(char ch, size_t nStart = 0) const;
327
328 // rfind() family is exactly like find() but works right to left
329
330 // as find, but from the end
331 size_t rfind(const wxString& str, size_t nStart = npos) const;
332
333 // as find, but from the end
334 size_t rfind(const char* sz, size_t nStart = npos,
335 size_t n = npos) const;
336 // as find, but from the end
337 size_t rfind(char ch, size_t nStart = npos) const;
338
7335902d 339 // find first/last occurrence of any character in the set
99f09bc1
VZ
340
341 //
342 size_t find_first_of(const wxString& str, size_t nStart = 0) const;
343 //
344 size_t find_first_of(const char* sz, size_t nStart = 0) const;
345 // same as find(char, size_t)
346 size_t find_first_of(char c, size_t nStart = 0) const;
347 //
348 size_t find_last_of (const wxString& str, size_t nStart = npos) const;
349 //
350 size_t find_last_of (const char* s, size_t nStart = npos) const;
351 // same as rfind(char, size_t)
352 size_t find_last_of (char c, size_t nStart = npos) const;
353
7335902d 354 // find first/last occurrence of any character not in the set
99f09bc1
VZ
355
356 //
357 size_t find_first_not_of(const wxString& str, size_t nStart = 0) const;
358 //
359 size_t find_first_not_of(const char* s, size_t nStart = 0) const;
360 //
361 size_t find_first_not_of(char ch, size_t nStart = 0) const;
362 //
363 size_t find_last_not_of(const wxString& str, size_t nStart=npos) const;
364 //
365 size_t find_last_not_of(const char* s, size_t nStart = npos) const;
366 //
367 size_t find_last_not_of(char ch, size_t nStart = npos) const;
368
369 // All compare functions return a negative, zero or positive value
370 // if the [sub]string is less, equal or greater than the compare() argument.
371
372 // just like strcmp()
373 int compare(const wxString& str) const;
374 // comparison with a substring
375 int compare(size_t nStart, size_t nLen, const wxString& str) const;
376 // comparison of 2 substrings
377 int compare(size_t nStart, size_t nLen,
378 const wxString& str, size_t nStart2, size_t nLen2) const;
379 // just like strcmp()
380 int compare(const char* sz) const;
381 // substring comparison with first nCount characters of sz
382 int compare(size_t nStart, size_t nLen,
383 const char* sz, size_t nCount = npos) const;
384
385 // substring extraction
386 wxString substr(size_t nStart = 0, size_t nLen = npos) const;
387\end{verbatim}
388
389%%%%% MEMBERS HERE %%%%%
390\helponly{\insertatlevel{2}{
391
392\wxheading{Members}
393
394}}
a660d684
KB
395
396\membersection{wxString::wxString}\label{wxstringconstruct}
397
b3324be2 398\func{}{wxString}{\void}
a660d684 399
b3324be2 400Default constructor.
a660d684 401
b3324be2 402\func{}{wxString}{\param{const wxString\&}{ x}}
a660d684 403
b3324be2 404Copy constructor.
a660d684 405
b3324be2 406\func{}{wxString}{\param{char}{ ch}, \param{size\_t}{ n = 1}}
a660d684 407
b3324be2 408Constructs a string of {\it n} copies of character {\it ch}.
a660d684 409
99f09bc1 410\func{}{wxString}{\param{const char*}{ psz}, \param{size\_t}{ nLength = wxSTRING\_MAXLEN}}
a660d684 411
b3324be2 412Takes first {\it nLength} characters from the C string {\it psz}.
f6bcfd97
BP
413The default value of wxSTRING\_MAXLEN means to take all the string.
414
415Note that this constructor may be used even if {\it psz} points to a buffer
416with binary data (i.e. containing {\tt NUL} characters) as long as you provide
417the correct value for {\it nLength}. However, the default form of it works
418only with strings without intermediate {\tt NUL}s because it uses
419{\tt strlen()} to calculate the effective length and it would not give correct
420results otherwise.
a660d684 421
99f09bc1 422\func{}{wxString}{\param{const unsigned char*}{ psz}, \param{size\_t}{ nLength = wxSTRING\_MAXLEN}}
a660d684 423
b3324be2 424For compilers using unsigned char: takes first {\it nLength} characters from the C string {\it psz}.
99f09bc1 425The default value of wxSTRING\_MAXLEN means take all the string.
a660d684 426
b3324be2 427\func{}{wxString}{\param{const wchar\_t*}{ psz}}
a660d684 428
b3324be2 429Constructs a string from the wide (UNICODE) string.
a660d684 430
b3324be2 431\membersection{wxString::\destruct{wxString}}\label{wxstringdestruct}
a660d684 432
b3324be2 433\func{}{\destruct{wxString}}{\void}
a660d684 434
b3324be2 435String destructor. Note that this is not virtual, so wxString must not be inherited from.
a660d684 436
99f09bc1
VZ
437\membersection{wxString::Alloc}\label{wxstringalloc}
438
439\func{void}{Alloc}{\param{size\_t}{ nLen}}
440
441Preallocate enough space for wxString to store {\it nLen} characters. This function
442may be used to increase speed when the string is constructed by repeated
443concatenation as in
444
445\begin{verbatim}
a660d684 446
99f09bc1
VZ
447// delete all vowels from the string
448wxString DeleteAllVowels(const wxString& original)
449{
450 wxString result;
a660d684 451
99f09bc1 452 size_t len = original.length();
a660d684 453
99f09bc1
VZ
454 result.Alloc(len);
455
456 for ( size_t n = 0; n < len; n++ )
457 {
458 if ( strchr("aeuio", tolower(original[n])) == NULL )
459 result += original[n];
460 }
461
462 return result;
463}
464
465\end{verbatim}
466
467because it will avoid the need of reallocating string memory many times (in case
468of long strings). Note that it does not set the maximal length of a string - it
469will still expand if more than {\it nLen} characters are stored in it. Also, it
470does not truncate the existing string (use
471\helpref{Truncate()}{wxstringtruncate} for this) even if its current length is
472greater than {\it nLen}
473
474\membersection{wxString::Append}\label{wxstringappend}
b3324be2
JS
475
476\func{wxString\&}{Append}{\param{const char*}{ psz}}
a660d684 477
b3324be2 478Concatenates {\it psz} to this string, returning a reference to it.
a660d684 479
b3324be2 480\func{wxString\&}{Append}{\param{char}{ ch}, \param{int}{ count = 1}}
a660d684 481
b3324be2
JS
482Concatenates character {\it ch} to this string, {\it count} times, returning a reference
483to it.
484
99f09bc1 485\membersection{wxString::AfterFirst}\label{wxstringafterfirst}
b3324be2 486
99f09bc1 487\constfunc{wxString}{AfterFirst}{\param{char}{ ch}}
b3324be2 488
7335902d 489Gets all the characters after the first occurrence of {\it ch}.
b3324be2 490Returns the empty string if {\it ch} is not found.
a660d684 491
99f09bc1 492\membersection{wxString::AfterLast}\label{wxstringafterlast}
a660d684 493
99f09bc1
VZ
494\constfunc{wxString}{AfterLast}{\param{char}{ ch}}
495
7335902d 496Gets all the characters after the last occurrence of {\it ch}.
99f09bc1
VZ
497Returns the whole string if {\it ch} is not found.
498
499\membersection{wxString::BeforeFirst}\label{wxstringbeforefirst}
500
501\constfunc{wxString}{BeforeFirst}{\param{char}{ ch}}
502
7335902d 503Gets all characters before the first occurrence of {\it ch}.
99f09bc1
VZ
504Returns the whole string if {\it ch} is not found.
505
506\membersection{wxString::BeforeLast}\label{wxstringbeforelast}
507
508\constfunc{wxString}{BeforeLast}{\param{char}{ ch}}
b3324be2 509
7335902d 510Gets all characters before the last occurrence of {\it ch}.
99f09bc1 511Returns the empty string if {\it ch} is not found.
a660d684 512
ed93168b
VZ
513\membersection{wxString::c\_str}\label{wxstringcstr}
514
515\constfunc{const char *}{c\_str}{\void}
516
517Returns a pointer to the string data.
518
519\membersection{wxString::Clear}\label{wxstringclear}
520
521\func{void}{Clear}{\void}
522
523Empties the string and frees memory occupied by it.
524
525See also: \helpref{Empty}{wxstringempty}
526
f7bd2698
JS
527\membersection{wxString::Cmp}\label{wxstringcmp}
528
529\constfunc{int}{Cmp}{\param{const char*}{ psz}}
530
531Case-sensitive comparison.
532
99f09bc1 533Returns a positive value if the string is greater than the argument, zero if
f6bcfd97 534it is equal to it or a negative value if it is less than the argument (same semantics
99f09bc1 535as the standard {\it strcmp()} function).
f7bd2698 536
99f09bc1 537See also \helpref{CmpNoCase}{wxstringcmpnocase}, \helpref{IsSameAs}{wxstringissameas}.
f7bd2698
JS
538
539\membersection{wxString::CmpNoCase}\label{wxstringcmpnocase}
540
541\constfunc{int}{CmpNoCase}{\param{const char*}{ psz}}
542
543Case-insensitive comparison.
544
99f09bc1 545Returns a positive value if the string is greater than the argument, zero if
f6bcfd97 546it is equal to it or a negative value if it is less than the argument (same semantics
99f09bc1 547as the standard {\it strcmp()} function).
f7bd2698 548
99f09bc1 549See also \helpref{Cmp}{wxstringcmp}, \helpref{IsSameAs}{wxstringissameas}.
f7bd2698 550
99f09bc1 551\membersection{wxString::CompareTo}\label{wxstringcompareto}
a660d684
KB
552
553\begin{verbatim}
554#define NO_POS ((int)(-1)) // undefined position
b3324be2 555enum caseCompare {exact, ignoreCase};
a660d684 556\end{verbatim}
ed93168b 557
b3324be2 558\constfunc{int}{CompareTo}{\param{const char*}{ psz}, \param{caseCompare}{ cmp = exact}}
a660d684 559
b3324be2 560Case-sensitive comparison. Returns 0 if equal, 1 if greater or -1 if less.
a660d684 561
99f09bc1 562\membersection{wxString::Contains}\label{wxstringcontains}
a660d684 563
99f09bc1 564\constfunc{bool}{Contains}{\param{const wxString\&}{ str}}
a660d684 565
b3324be2 566Returns 1 if target appears anyhere in wxString; else 0.
a660d684 567
f7bd2698 568\membersection{wxString::Empty}\label{wxstringempty}
a660d684 569
f7bd2698
JS
570\func{void}{Empty}{\void}
571
ed93168b
VZ
572Makes the string empty, but doesn't free memory occupied by the string.
573
574See also: \helpref{Clear()}{wxstringclear}.
f7bd2698
JS
575
576\membersection{wxString::Find}\label{wxstringfind}
577
cc81d32f 578\constfunc{int}{Find}{\param{char}{ ch}, \param{bool}{ fromEnd = false}}
f7bd2698
JS
579
580Searches for the given character. Returns the starting index, or -1 if not found.
581
582\constfunc{int}{Find}{\param{const char*}{ sz}}
583
584Searches for the given string. Returns the starting index, or -1 if not found.
a660d684 585
b3324be2 586\membersection{wxString::First}\label{wxstringfirst}
a660d684 587
0aa35d19 588\func{int}{First}{\param{char}{ c}}
a660d684 589
0aa35d19 590\constfunc{int}{First}{\param{const char*}{ psz}}
a660d684 591
0aa35d19 592\constfunc{int}{First}{\param{const wxString\&}{ str}}
a660d684 593
0aa35d19 594Same as \helpref{Find}{wxstringfind}.
a660d684 595
341e7d28
VZ
596\membersection{wxString::Format}\label{wxstringformat}
597
598\func{static wxString}{Format}{\param{const wxChar }{*format}, \param{}{...}}
599
600This static function returns the string containing the result of calling
601\helpref{Printf}{wxstringprintf} with the passed parameters on it.
602
603\wxheading{See also}
604
605\helpref{FormatV}{wxstringformatv}, \helpref{Printf}{wxstringprintf}
606
607\membersection{wxString::FormatV}\label{wxstringformatv}
608
609\func{static wxString}{Format}{\param{const wxChar }{*format}, \param{va\_list }{argptr}}
610
611This static function returns the string containing the result of calling
612\helpref{PrintfV}{wxstringprintfv} with the passed parameters on it.
613
614\wxheading{See also}
615
616\helpref{Format}{wxstringformat}, \helpref{PrintfV}{wxstringprintfv}
617
99f09bc1
VZ
618\membersection{wxString::Freq}\label{wxstringfreq}
619
f6bcfd97 620\constfunc{int}{Freq}{\param{char }{ch}}
99f09bc1 621
f6bcfd97 622Returns the number of occurrences of {\it ch} in the string.
99f09bc1 623
6d9d6350
JS
624\membersection{wxString::FromAscii}\label{wxstringfromascii}
625
626\func{static wxString }{FromAscii}{\param{const char*}{ s}}
627
628\func{static wxString }{FromAscii}{\param{const char}{ c}}
629
630Converts the string or character from an ASCII, 7-bit form
631to the native wxString representation. Most useful when using
fc2171bd 632a Unicode build of wxWidgets.
6d9d6350 633
f7bd2698 634\membersection{wxString::GetChar}\label{wxstringgetchar}
a660d684 635
f7bd2698 636\constfunc{char}{GetChar}{\param{size\_t}{ n}}
a660d684 637
f7bd2698 638Returns the character at position {\it n} (read-only).
a660d684 639
99f09bc1 640\membersection{wxString::GetData}\label{wxstringgetdata}
a660d684 641
f7bd2698 642\constfunc{const char*}{GetData}{\void}
a660d684 643
fc2171bd 644wxWidgets compatibility conversion. Returns a constant pointer to the data in the string.
a660d684 645
f7bd2698 646\membersection{wxString::GetWritableChar}\label{wxstringgetwritablechar}
a660d684 647
f7bd2698 648\func{char\&}{GetWritableChar}{\param{size\_t}{ n}}
a660d684 649
f7bd2698 650Returns a reference to the character at position {\it n}.
a660d684 651
f7bd2698 652\membersection{wxString::GetWriteBuf}\label{wxstringgetwritebuf}
a660d684 653
9a55c2ee 654\func{wxChar*}{GetWriteBuf}{\param{size\_t}{ len}}
a660d684 655
f7bd2698 656Returns a writable buffer of at least {\it len} bytes.
8161ba08
JS
657It returns a pointer to a new memory block, and the
658existing data will not be copied.
a660d684 659
f7bd2698
JS
660Call \helpref{wxString::UngetWriteBuf}{wxstringungetwritebuf} as soon as possible
661to put the string back into a reasonable state.
a660d684 662
99f09bc1 663\membersection{wxString::Index}\label{wxstringindex}
a660d684 664
5ef056a3 665\constfunc{size\_t}{Index}{\param{char}{ ch}}
a660d684 666
f7bd2698 667\constfunc{size\_t}{Index}{\param{const char*}{ sz}}
a660d684 668
f7bd2698 669Same as \helpref{wxString::Find}{wxstringfind}.
a660d684 670
cc81d32f 671\constfunc{size\_t}{Index}{\param{const char*}{ sz}, \param{bool}{ caseSensitive = true}, \param{bool}{ fromEnd = false}}
a660d684 672
f7bd2698 673Search the element in the array, starting from either side.
a660d684 674
cc81d32f 675If {\it fromEnd} is true, reverse search direction.
a660d684 676
f7bd2698 677If {\bf caseSensitive}, comparison is case sensitive (the default).
a660d684 678
2b5f62a0 679Returns the index of the first item matched, or wxNOT\_FOUND.
a660d684 680
8a2c6ef8
JS
681% TODO
682%\membersection{wxString::insert}\label{wxstringinsert}
683% Wrong!
99f09bc1 684%\func{void}{insert}{\param{const wxString\&}{ str}, \param{size\_t}{ index}}
8a2c6ef8
JS
685%
686%Add new element at the given position.
687%
99f09bc1 688\membersection{wxString::IsAscii}\label{wxstringisascii}
a660d684 689
f7bd2698 690\constfunc{bool}{IsAscii}{\void}
a660d684 691
cc81d32f 692Returns true if the string contains only ASCII characters.
a660d684 693
f7bd2698 694\membersection{wxString::IsEmpty}\label{wxstringisempty}
a660d684 695
f7bd2698 696\constfunc{bool}{IsEmpty}{\void}
a660d684 697
cc81d32f 698Returns true if the string is empty.
a660d684 699
99f09bc1 700\membersection{wxString::IsNull}\label{wxstringisnull}
a660d684 701
f7bd2698 702\constfunc{bool}{IsNull}{\void}
a660d684 703
cc81d32f 704Returns true if the string is empty (same as \helpref{IsEmpty}{wxstringisempty}).
a660d684 705
99f09bc1 706\membersection{wxString::IsNumber}\label{wxstringisnumber}
a660d684 707
f7bd2698
JS
708\constfunc{bool}{IsNumber}{\void}
709
cc81d32f 710Returns true if the string is an integer (with possible sign).
f7bd2698
JS
711
712\membersection{wxString::IsSameAs}\label{wxstringissameas}
713
cc81d32f 714\constfunc{bool}{IsSameAs}{\param{const char*}{ psz}, \param{bool}{ caseSensitive = true}}
f7bd2698
JS
715
716Test for string equality, case-sensitive (default) or not.
717
cc81d32f 718caseSensitive is true by default (case matters).
a660d684 719
cc81d32f 720Returns true if strings are equal, false otherwise.
f7bd2698 721
f33fee2a
VZ
722See also \helpref{Cmp}{wxstringcmp}, \helpref{CmpNoCase}{wxstringcmpnocase}, \helpref{IsSameAs}{wxstringissameas2}
723
724\membersection{wxString::IsSameAs}\label{wxstringissameas2}
725
cc81d32f 726\constfunc{bool}{IsSameAs}{\param{char}{ c}, \param{bool}{ caseSensitive = true}}
f33fee2a
VZ
727
728Test whether the string is equal to the single character {\it c}. The test is
cc81d32f 729case-sensitive if {\it caseSensitive} is true (default) or not if it is false.
f33fee2a 730
cc81d32f 731Returns true if the string is equal to the character, false otherwise.
f33fee2a
VZ
732
733See also \helpref{Cmp}{wxstringcmp}, \helpref{CmpNoCase}{wxstringcmpnocase}, \helpref{IsSameAs}{wxstringissameas}
a660d684 734
99f09bc1 735\membersection{wxString::IsWord}\label{wxstringisword}
a660d684 736
f7bd2698 737\constfunc{bool}{IsWord}{\void}
a660d684 738
cc81d32f 739Returns true if the string is a word. TODO: what's the definition of a word?
a660d684 740
99f09bc1 741\membersection{wxString::Last}\label{wxstringlast}
a660d684 742
f7bd2698 743\constfunc{char}{Last}{\void}
a660d684 744
f7bd2698 745Returns the last character.
a660d684 746
f7bd2698 747\func{char\&}{Last}{\void}
a660d684 748
f7bd2698 749Returns a reference to the last character (writable).
a660d684 750
f7bd2698
JS
751\membersection{wxString::Left}\label{wxstringleft}
752
753\constfunc{wxString}{Left}{\param{size\_t}{ count}}
754
fefc4f15 755Returns the first {\it count} characters of the string.
a660d684 756
f7bd2698 757\membersection{wxString::Len}\label{wxstringlen}
a660d684 758
f7bd2698
JS
759\constfunc{size\_t}{Len}{\void}
760
761Returns the length of the string.
762
763\membersection{wxString::Length}\label{wxstringlength}
764
765\constfunc{size\_t}{Length}{\void}
766
767Returns the length of the string (same as Len).
a660d684 768
99f09bc1
VZ
769\membersection{wxString::Lower}\label{wxstringlower}
770
771\constfunc{wxString}{Lower}{\void}
772
773Returns this string converted to the lower case.
774
775\membersection{wxString::LowerCase}\label{wxstringlowercase}
a660d684 776
f7bd2698
JS
777\func{void}{LowerCase}{\void}
778
779Same as MakeLower.
780
781\membersection{wxString::MakeLower}\label{wxstringmakelower}
782
e16f8973 783\func{wxString\&}{MakeLower}{\void}
f7bd2698 784
e16f8973 785Converts all characters to lower case and returns the result.
f7bd2698
JS
786
787\membersection{wxString::MakeUpper}\label{wxstringmakeupper}
788
e16f8973 789\func{wxString\&}{MakeUpper}{\void}
f7bd2698 790
e16f8973 791Converts all characters to upper case and returns the result.
a660d684 792
99f09bc1 793\membersection{wxString::Matches}\label{wxstringmatches}
a660d684 794
f7bd2698
JS
795\constfunc{bool}{Matches}{\param{const char*}{ szMask}}
796
cc81d32f 797Returns true if the string contents matches a mask containing '*' and '?'.
a660d684 798
f7bd2698 799\membersection{wxString::Mid}\label{wxstringmid}
a660d684 800
99f09bc1 801\constfunc{wxString}{Mid}{\param{size\_t}{ first}, \param{size\_t}{ count = wxSTRING\_MAXLEN}}
a660d684 802
f7bd2698
JS
803Returns a substring starting at {\it first}, with length {\it count}, or the rest of
804the string if {\it count} is the default value.
805
806\membersection{wxString::Pad}\label{wxstringpad}
807
cc81d32f 808\func{wxString\&}{Pad}{\param{size\_t}{ count}, \param{char}{ pad = ' '}, \param{bool}{ fromRight = true}}
f7bd2698
JS
809
810Adds {\it count} copies of {\it pad} to the beginning, or to the end of the string (the default).
811
812Removes spaces from the left or from the right (default).
a660d684 813
99f09bc1 814\membersection{wxString::Prepend}\label{wxstringprepend}
a660d684 815
f7bd2698 816\func{wxString\&}{Prepend}{\param{const wxString\&}{ str}}
a660d684 817
f7bd2698 818Prepends {\it str} to this string, returning a reference to this string.
a660d684 819
f7bd2698 820\membersection{wxString::Printf}\label{wxstringprintf}
a660d684 821
f7bd2698
JS
822\func{int}{Printf}{\param{const char* }{pszFormat}, \param{}{...}}
823
99f09bc1
VZ
824Similar to the standard function {\it sprintf()}. Returns the number of
825characters written, or an integer less than zero on error.
826
827{\bf NB:} This function will use a safe version of {\it vsprintf()} (usually called
828{\it vsnprintf()}) whenever available to always allocate the buffer of correct
829size. Unfortunately, this function is not available on all platforms and the
830dangerous {\it vsprintf()} will be used then which may lead to buffer overflows.
a660d684 831
f7bd2698
JS
832\membersection{wxString::PrintfV}\label{wxstringprintfv}
833
834\func{int}{PrintfV}{\param{const char* }{pszFormat}, \param{va\_list}{ argPtr}}
835
836Similar to vprintf. Returns the number of characters written, or an integer less than zero
837on error.
a660d684 838
99f09bc1 839\membersection{wxString::Remove}\label{wxstringremove}
a660d684 840
f7bd2698
JS
841\func{wxString\&}{Remove}{\param{size\_t}{ pos}}
842
843Same as Truncate. Removes the portion from {\it pos} to the end of the string.
844
845\func{wxString\&}{Remove}{\param{size\_t}{ pos}, \param{size\_t}{ len}}
846
42d14d4e 847Removes the {\it len} characters from the string, starting at {\it pos}.
f7bd2698
JS
848
849\membersection{wxString::RemoveLast}\label{wxstringremovelast}
a660d684 850
f7bd2698
JS
851\func{wxString\&}{RemoveLast}{\void}
852
853Removes the last character.
a660d684 854
99f09bc1 855\membersection{wxString::Replace}\label{wxstringreplace}
a660d684 856
cc81d32f 857\func{size\_t}{Replace}{\param{const char*}{ szOld}, \param{const char*}{ szNew}, \param{bool}{ replaceAll = true}}
f7bd2698 858
7335902d 859Replace first (or all) occurrences of substring with another one.
f7bd2698 860
7335902d 861{\it replaceAll}: global replace (default), or only the first occurrence.
f7bd2698
JS
862
863Returns the number of replacements made.
864
865\membersection{wxString::Right}\label{wxstringright}
866
867\constfunc{wxString}{Right}{\param{size\_t}{ count}}
a660d684 868
f7bd2698 869Returns the last {\it count} characters.
a660d684 870
f7bd2698 871\membersection{wxString::SetChar}\label{wxstringsetchar}
a660d684 872
f7bd2698
JS
873\func{void}{SetChar}{\param{size\_t}{ n}, \param{char}{ch}}
874
875Sets the character at position {\it n}.
876
877\membersection{wxString::Shrink}\label{wxstringshrink}
878
879\func{void}{Shrink}{\void}
880
99f09bc1
VZ
881Minimizes the string's memory. This can be useful after a call to
882\helpref{Alloc()}{wxstringalloc} if too much memory were preallocated.
a660d684
KB
883
884\membersection{wxString::sprintf}\label{wxstringsprintf}
a660d684 885
f7bd2698 886\func{void}{sprintf}{\param{const char* }{ fmt}}
a660d684 887
f7bd2698 888The same as Printf.
a660d684 889
f6bcfd97
BP
890\membersection{wxString::StartsWith}\label{wxstringstartswith}
891
892\constfunc{bool}{StartsWith}{\param{const wxChar }{*prefix}, \param{wxString }{*rest = NULL}}
893
894This function can be used to test if the string starts with the specified
cc81d32f 895{\it prefix}. If it does, the function will return {\tt true} and put the rest
f6bcfd97 896of the string (i.e. after the prefix) into {\it rest} string if it is not
cc81d32f 897{\tt NULL}. Otherwise, the function returns {\tt false} and doesn't modify the
f6bcfd97
BP
898{\it rest}.
899
99f09bc1 900\membersection{wxString::Strip}\label{wxstringstrip}
a660d684
KB
901
902\begin{verbatim}
f7bd2698 903enum stripType {leading = 0x1, trailing = 0x2, both = 0x3};
a660d684
KB
904\end{verbatim}
905
f7bd2698 906\constfunc{wxString}{Strip}{\param{stripType}{ s = trailing}}
a660d684 907
f7bd2698
JS
908Strip characters at the front and/or end. The same as Trim except that it
909doesn't change this string.
a660d684 910
99f09bc1
VZ
911\membersection{wxString::SubString}\label{wxstringsubstring}
912
f6bcfd97 913\constfunc{wxString}{SubString}{\param{size\_t}{ from}, \param{size\_t}{ to}}
99f09bc1 914
b855ef77
VZ
915Deprecated, use \helpref{Mid}{wxstringmid} instead (but note that parameters
916have different meaning).
917
918Returns the part of the string between the indices {\it from} and {\it to}
919inclusive.
99f09bc1 920
6d9d6350
JS
921\membersection{wxString::ToAscii}\label{wxstringtoascii}
922
923\constfunc{const char*}{ToAscii}{\void}
924
925Converts the string to an ASCII, 7-bit string (ANSI builds only).
926
927\constfunc{const wxCharBuffer}{ToAscii}{\void}
928
929Converts the string to an ASCII, 7-bit string in the form of
930a wxCharBuffer (Unicode builds only).
931
cd0b1709
VZ
932\membersection{wxString::ToDouble}\label{wxstringtodouble}
933
f6bcfd97 934\constfunc{bool}{ToDouble}{\param{double}{ *val}}
cd0b1709 935
cc81d32f
VS
936Attempts to convert the string to a floating point number. Returns true on
937success (the number is stored in the location pointed to by {\it val}) or false
cd0b1709
VZ
938if the string does not represent such number.
939
f6bcfd97
BP
940\wxheading{See also}
941
942\helpref{wxString::ToLong}{wxstringtolong},\\
943\helpref{wxString::ToULong}{wxstringtoulong}
944
cd0b1709
VZ
945\membersection{wxString::ToLong}\label{wxstringtolong}
946
538f35cc 947\constfunc{bool}{ToLong}{\param{long}{ *val}, \param{int }{base = $10$}}
cd0b1709 948
4eb438cf 949Attempts to convert the string to a signed integer in base {\it base}. Returns
cc81d32f
VS
950{\tt true} on success in which case the number is stored in the location
951pointed to by {\it val} or {\tt false} if the string does not represent a
4eb438cf
VZ
952valid number in the given base.
953
538f35cc
VZ
954The value of {\it base} must be comprised between $2$ and $36$, inclusive, or
955be a special value $0$ which means that the usual rules of {\tt C} numbers are
956applied: if the number starts with {\tt 0x} it is considered to be in base
957$16$, if it starts with {\tt 0} - in base $8$ and in base $10$ otherwise. Note
958that you may not want to specify the base $0$ if you are parsing the numbers
959which may have leading zeroes as they can yield unexpected (to the user not
960familiar with C) results.
cd0b1709 961
f6bcfd97
BP
962\wxheading{See also}
963
964\helpref{wxString::ToDouble}{wxstringtodouble},\\
965\helpref{wxString::ToULong}{wxstringtoulong}
966
cd0b1709
VZ
967\membersection{wxString::ToULong}\label{wxstringtoulong}
968
538f35cc 969\constfunc{bool}{ToULong}{\param{unsigned long}{ *val}, \param{int }{base = $10$}}
4eb438cf
VZ
970
971Attempts to convert the string to a ansigned integer in base {\it base}.
cc81d32f
VS
972Returns {\tt true} on success in which case the number is stored in the
973location pointed to by {\it val} or {\tt false} if the string does not
4eb438cf 974represent a valid number in the given base.
cd0b1709 975
ec64d632
VZ
976See \helpref{wxString::ToLong}{wxstringtolong} for the more detailed
977description of the {\it base} parameter.
cd0b1709 978
f6bcfd97
BP
979\wxheading{See also}
980
981\helpref{wxString::ToDouble}{wxstringtodouble},\\
982\helpref{wxString::ToLong}{wxstringtolong}
983
f7bd2698 984\membersection{wxString::Trim}\label{wxstringtrim}
a660d684 985
cc81d32f 986\func{wxString\&}{Trim}{\param{bool}{ fromRight = true}}
a660d684 987
f7bd2698 988Removes spaces from the left or from the right (default).
a660d684 989
f7bd2698 990\membersection{wxString::Truncate}\label{wxstringtruncate}
a660d684 991
f7bd2698 992\func{wxString\&}{Truncate}{\param{size\_t}{ len}}
a660d684 993
f7bd2698 994Truncate the string to the given length.
a660d684 995
f7bd2698
JS
996\membersection{wxString::UngetWriteBuf}\label{wxstringungetwritebuf}
997
998\func{void}{UngetWriteBuf}{\void}
999
448025b0
VZ
1000\func{void}{UngetWriteBuf}{\param{size\_t }{len}}
1001
1002Puts the string back into a reasonable state (in which it can be used
1003normally), after
f7bd2698 1004\rtfsp\helpref{wxString::GetWriteBuf}{wxstringgetwritebuf} was called.
a660d684 1005
448025b0
VZ
1006The version of the function without the {\it len} parameter will calculate the
1007new string length itself assuming that the string is terminated by the first
1008{\tt NUL} character in it while the second one will use the specified length
1009and thus is the only version which should be used with the strings with
1010embedded {\tt NUL}s (it is also slightly more efficient as {\tt strlen()}
1011doesn't have to be called).
1012
99f09bc1
VZ
1013\membersection{wxString::Upper}\label{wxstringupper}
1014
1015\constfunc{wxString}{Upper}{\void}
1016
1017Returns this string converted to upper case.
1018
1019\membersection{wxString::UpperCase}\label{wxstringuppercase}
a660d684 1020
f7bd2698
JS
1021\func{void}{UpperCase}{\void}
1022
1023The same as MakeUpper.
a660d684 1024
99f09bc1
VZ
1025\membersection{wxString::operator!}\label{wxstringoperatornot}
1026
1027\constfunc{bool}{operator!}{\void}
1028
cc81d32f 1029Empty string is false, so !string will only return true if the string is empty.
99f09bc1
VZ
1030This allows the tests for NULLness of a {\it const char *} pointer and emptyness
1031of the string to look the same in the code and makes it easier to port old code
1032to wxString.
1033
1034See also \helpref{IsEmpty()}{wxstringisempty}.
1035
a660d684
KB
1036\membersection{wxString::operator $=$}\label{wxstringoperatorassign}
1037
f7bd2698
JS
1038\func{wxString\&}{operator $=$}{\param{const wxString\&}{ str}}
1039
1040\func{wxString\&}{operator $=$}{\param{const char*}{ psz}}
1041
1042\func{wxString\&}{operator $=$}{\param{char}{ c}}
1043
1044\func{wxString\&}{operator $=$}{\param{const unsigned char*}{ psz}}
1045
1046\func{wxString\&}{operator $=$}{\param{const wchar\_t*}{ pwz}}
a660d684 1047
99f09bc1
VZ
1048Assignment: the effect of each operation is the same as for the corresponding
1049constructor (see \helpref{wxString constructors}{wxstringconstruct}).
5de76427 1050
f6bcfd97 1051\membersection{wxString::operator $+$}\label{wxstringoperatorplus}
5de76427 1052
99f09bc1
VZ
1053Concatenation: all these operators return a new strign equal to the sum of the
1054operands.
5de76427
JS
1055
1056\func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
1057
1058\func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{const char*}{ y}}
1059
1060\func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{char}{ y}}
1061
1062\func{wxString}{operator $+$}{\param{const char*}{ x}, \param{const wxString\&}{ y}}
1063
99f09bc1 1064\membersection{wxString::operator $+=$}\label{wxstringplusequal}
a660d684 1065
f7bd2698
JS
1066\func{void}{operator $+=$}{\param{const wxString\&}{ str}}
1067
1068\func{void}{operator $+=$}{\param{const char*}{ psz}}
1069
1070\func{void}{operator $+=$}{\param{char}{ c}}
a660d684 1071
99f09bc1 1072Concatenation in place: the argument is appended to the string.
a660d684
KB
1073
1074\membersection{wxString::operator []}\label{wxstringoperatorbracket}
1075
f7bd2698
JS
1076\func{char\&}{operator []}{\param{size\_t}{ i}}
1077
1078\func{char}{operator []}{\param{size\_t}{ i}}
1079
1080\func{char}{operator []}{\param{int}{ i}}
a660d684
KB
1081
1082Element extraction.
1083
1084\membersection{wxString::operator ()}\label{wxstringoperatorparenth}
1085
f7bd2698
JS
1086\func{wxString}{operator ()}{\param{size\_t}{ start}, \param{size\_t}{ len}}
1087
1088Same as Mid (substring extraction).
a660d684
KB
1089
1090\membersection{wxString::operator \cinsert}\label{wxstringoperatorout}
f7bd2698 1091
037267e1 1092\func{wxString\&}{operator \cinsert}{\param{const wxString\&}{ str}}
f7bd2698 1093
037267e1 1094\func{wxString\&}{operator \cinsert}{\param{const char*}{ psz}}
f7bd2698 1095
037267e1 1096\func{wxString\&}{operator \cinsert}{\param{char }{ch}}
f7bd2698
JS
1097
1098Same as $+=$.
a660d684 1099
99f09bc1
VZ
1100\func{wxString\&}{operator \cinsert}{\param{int}{ i}}
1101
1102\func{wxString\&}{operator \cinsert}{\param{float}{ f}}
1103
1104\func{wxString\&}{operator \cinsert}{\param{double}{ d}}
1105
1106These functions work as C++ stream insertion operators: they insert the given
1107value into the string. Precision or format cannot be set using them, you can use
1108\helpref{Printf}{wxstringprintf} for this.
1109
a660d684 1110\membersection{wxString::operator \cextract}\label{wxstringoperatorin}
a660d684 1111
f7bd2698 1112\func{friend istream\&}{operator \cextract}{\param{istream\&}{ is}, \param{wxString\&}{ str}}
a660d684 1113
f7bd2698 1114Extraction from a stream.
a660d684 1115
f7bd2698 1116\membersection{wxString::operator const char*}\label{wxstringoperatorconstcharpt}
a660d684 1117
f7bd2698 1118\constfunc{}{operator const char*}{\void}
a660d684 1119
f7bd2698 1120Implicit conversion to a C string.
a660d684 1121
99f09bc1 1122\membersection{Comparison operators}\label{wxstringcomparison}
a660d684 1123
f7bd2698 1124\func{bool}{operator $==$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 1125
f7bd2698 1126\func{bool}{operator $==$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 1127
f7bd2698 1128\func{bool}{operator $!=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 1129
f7bd2698 1130\func{bool}{operator $!=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 1131
f7bd2698 1132\func{bool}{operator $>$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 1133
f7bd2698 1134\func{bool}{operator $>$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 1135
f7bd2698 1136\func{bool}{operator $>=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 1137
f7bd2698 1138\func{bool}{operator $>=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 1139
f7bd2698 1140\func{bool}{operator $<$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 1141
f7bd2698 1142\func{bool}{operator $<$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 1143
f7bd2698 1144\func{bool}{operator $<=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 1145
f7bd2698 1146\func{bool}{operator $<=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 1147
f7bd2698 1148\wxheading{Remarks}
a660d684 1149
f7bd2698 1150These comparisons are case-sensitive.
a660d684 1151
1d218550
VZ
1152
1153\section{\class{wxStringBuffer}}\label{wxstringbuffer}
1154
1155This tiny class allows to conveniently access the \helpref{wxString}{wxstring}
1156internal buffer as a writable pointer without any risk to forget to restore
1157the string to the usable state later.
1158
1159For example, assuming you have a low-level OS function called
1160{\tt GetMeaningOfLifeAsString(char *)} returning the value in the provided
1161buffer (which must be writable, of course) you might call it like this:
1162
1163\begin{verbatim}
1164 wxString theAnswer;
1165 GetMeaningOfLifeAsString(wxStringBuffer(theAnswer, 1024));
1166 if ( theAnswer != "42" )
1167 {
1168 wxLogError("Something is very wrong!");
1169 }
1170\end{verbatim}
1171
1172\wxheading{Derived from}
1173
1174None
1175
1176\wxheading{Include files}
1177
1178<wx/string.h>
1179
1180\latexignore{\rtfignore{\wxheading{Members}}}
1181
1182\membersection{wxStringBuffer::wxStringBuffer}
1183
1184\func{}{wxStringBuffer}{\param{const wxString\& }{str}, \param{size\_t }{len}}
1185
1186Constructs a writable string buffer object associated with the given string
2edb0bde 1187and containing enough space for at least {\it len} characters. Basically, this
1d218550
VZ
1188is equivalent to calling \helpref{GetWriteBuf}{wxstringgetwritebuf} and
1189saving the result.
1190
1191\membersection{wxStringBuffer::\destruct{wxStringBuffer}}
1192
1193\func{}{\destruct{wxStringBuffer}}{\void}
1194
1195Restores the string passed to the constructor to the usable state by calling
1196\helpref{UngetWriteBuf}{wxstringungetwritebuf} on it.
1197
1198\membersection{wxStringBuffer::operator wxChar *}
1199
1200\constfunc{wxChar *}{operator wxChar *}{\void}
1201
1202Returns the writable pointer to a buffer of the size at least equal to the
1203length specified in the constructor.
1204
1205