]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/wxstring.tex
don't declare inline function with dllexport declaration, this provokes mingw32 warni...
[wxWidgets.git] / docs / latex / wx / wxstring.tex
... / ...
CommitLineData
1\section{\class{wxString}}\label{wxstring}
2
3wxString is a class representing a character string. Please see the
4\helpref{wxString overview}{wxstringoverview} for more information about it.
5
6As explained there, wxString implements most of the methods of the std::string
7class.
8These standard functions are not documented in this manual, please see the
9\urlref{STL documentation}{http://www.cppreference.com/cppstl.html}).
10The behaviour of all these functions is identical to the behaviour described
11there.
12
13You may notice that wxString sometimes has many functions which do the same
14thing like, for example, \helpref{Length()}{wxstringlength},
15\helpref{Len()}{wxstringlen} and {\tt length()} which all return the string
16length. In all cases of such duplication the {\tt std::string}-compatible
17method ({\tt length()} in this case, always the lowercase version) should be
18used as it will ensure smoother transition to {\tt std::string} when wxWidgets
19starts using it instead of wxString.
20
21\wxheading{Derived from}
22
23None
24
25\wxheading{Include files}
26
27<wx/string.h>
28
29\wxheading{Predefined objects}
30
31Objects:
32
33{\bf wxEmptyString}
34
35\wxheading{See also}
36
37\helpref{wxString overview}{wxstringoverview}, \helpref{Unicode overview}{unicode}
38
39\latexignore{\rtfignore{\wxheading{Function groups}}}
40
41
42\membersection{Constructors and assignment operators}\label{constructorsinwxstring}
43
44A string may be constructed either from a C string, (some number of copies of)
45a single character or a wide (UNICODE) string. For all constructors (except the
46default which creates an empty string) there is also a corresponding assignment
47operator.
48
49\helpref{wxString}{wxstringconstruct}\\
50\helpref{operator $=$}{wxstringoperatorassign}\\
51\helpref{\destruct{wxString}}{wxstringdestruct}
52
53
54\membersection{String length}\label{lengthfunctionsinwxstring}
55
56These functions return the string length and check whether the string is empty
57or empty it.
58
59\helpref{Len}{wxstringlen}\\
60\helpref{IsEmpty}{wxstringisempty}\\
61\helpref{operator!}{wxstringoperatornot}\\
62\helpref{Empty}{wxstringempty}\\
63\helpref{Clear}{wxstringclear}
64
65
66\membersection{Character access}\label{characteraccessinwxstring}
67
68Many functions in this section take a character index in the string. As with C
69strings and/or arrays, the indices start from $0$, so the first character of a
70string is string[$0$]. Attempt to access a character beyond the end of the
71string (which may be even $0$ if the string is empty) will provoke an assert
72failure in \helpref{debug build}{debuggingoverview}, but no checks are done in
73release builds.
74
75This section also contains both implicit and explicit conversions to C style
76strings. Although implicit conversion is quite convenient, it is advised to use
77explicit \helpref{c\_str()}{wxstringcstr} method for the sake of clarity. Also
78see \helpref{overview}{wxstringadvices} for the cases where it is necessary to
79use it.
80
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}
91
92
93\membersection{Concatenation}\label{concatenationinwxstring}
94
95Anything may be concatenated (appended to) with a string. However, you can't
96append something to a C string (including literal constants), so to do this it
97should be converted to a wxString first.
98
99\helpref{operator \cinsert}{wxstringoperatorout}\\
100\helpref{operator $+=$}{wxstringplusequal}\\
101\helpref{operator $+$}{wxstringoperatorplus}\\
102\helpref{Append}{wxstringappend}\\
103\helpref{Prepend}{wxstringprepend}
104
105
106\membersection{Comparison}\label{comparisoninwxstring}
107
108The default comparison function \helpref{Cmp}{wxstringcmp} is case-sensitive and
109so is the default version of \helpref{IsSameAs}{wxstringissameas}. For case
110insensitive comparisons you should use \helpref{CmpNoCase}{wxstringcmpnocase} or
111give a second parameter to IsSameAs. This last function is may be more
112convenient 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)
114as {\tt Cmp()} does.
115
116\helpref{Matches}{wxstringmatches} is a poor man's regular expression matcher:
117it only understands '*' and '?' metacharacters in the sense of DOS command line
118interpreter.
119
120\helpref{StartsWith}{wxstringstartswith} is helpful when parsing a line of
121text which should start with some predefined prefix and is more efficient than
122doing direct string comparison as you would also have to precalculate the
123length of the prefix then.
124
125\helpref{Cmp}{wxstringcmp}\\
126\helpref{CmpNoCase}{wxstringcmpnocase}\\
127\helpref{IsSameAs}{wxstringissameas}\\
128\helpref{Matches}{wxstringmatches}\\
129\helpref{StartsWith}{wxstringstartswith}\\
130\helpref{EndsWith}{wxstringendswith}
131
132
133\membersection{Substring extraction}\label{substringextractioninwxstring}
134
135These functions allow to extract substring from this string. All of them don't
136modify the original string and return a new string containing the extracted
137substring.
138
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}
149
150
151
152\membersection{Case conversion}\label{caseconversioninwxstring}
153
154The MakeXXX() variants modify the string in place, while the other functions
155return a new string which contains the original text converted to the upper or
156lower case and leave the original string unchanged.
157
158\helpref{MakeUpper}{wxstringmakeupper}\\
159\helpref{Upper}{wxstringupper}\\
160\helpref{MakeLower}{wxstringmakelower}\\
161\helpref{Lower}{wxstringlower}
162
163
164\membersection{Searching and replacing}\label{searchingandreplacinginwxstring}
165
166These functions replace the standard {\it strchr()} and {\it strstr()}
167functions.
168
169\helpref{Find}{wxstringfind}\\
170\helpref{Replace}{wxstringreplace}
171
172
173\membersection{Conversion to numbers}\label{conversiontonumbersinwxstring}
174
175The string provides functions for conversion to signed and unsigned integer and
176floating point numbers. All three functions take a pointer to the variable to
177put the numeric value in and return \true if the {\bf entire} string could be
178converted to a number.
179
180\helpref{ToLong}{wxstringtolong}\\
181\helpref{ToLongLong}{wxstringtolonglong}\\
182\helpref{ToULong}{wxstringtoulong}\\
183\helpref{ToULongLong}{wxstringtoulonglong}\\
184\helpref{ToDouble}{wxstringtodouble}
185
186
187\membersection{Writing values into the string}\label{writingintostringinwxstring}
188
189Both formatted versions (\helpref{Printf}{wxstringprintf}) and stream-like
190insertion operators exist (for basic types only). Additionally, the
191\helpref{Format}{wxstringformat} function allows to use simply append
192formatted value to a string:
193
194\begin{verbatim}
195 // the following 2 snippets are equivalent
196
197 wxString s = "...";
198 s += wxString::Format("%d", n);
199
200 wxString s;
201 s.Printf("...%d", n);
202\end{verbatim}
203
204\helpref{Format}{wxstringformat}\\
205\helpref{FormatV}{wxstringformatv}\\
206\helpref{Printf}{wxstringprintf}\\
207\helpref{PrintfV}{wxstringprintfv}\\
208\helpref{operator \cinsert}{wxstringoperatorout}
209
210
211\membersection{Memory management}\label{memoryinwxstring}
212
213These are "advanced" functions and they will be needed quite rarely.
214\helpref{Alloc}{wxstringalloc} and \helpref{Shrink}{wxstringshrink} are only
215interesting for optimization purposes.
216\helpref{wxStringBuffer}{wxstringbuffer}
217and \helpref{wxStringBufferLength}{wxstringbufferlength} classes may be very
218useful when working with some external API which requires the caller to provide
219a writable buffer.
220
221\helpref{Alloc}{wxstringalloc}\\
222\helpref{Shrink}{wxstringshrink}\\
223\helpref{wxStringBuffer}{wxstringbuffer}\\
224\helpref{wxStringBufferLength}{wxstringbufferlength}
225
226
227\membersection{Miscellaneous}\label{miscellaneousinwxstring}
228
229Other string functions.
230
231\helpref{Trim}{wxstringtrim}\\
232\helpref{Truncate}{wxstringtruncate}\\
233\helpref{Pad}{wxstringpad}
234
235
236\membersection{wxWidgets 1.xx compatibility functions}\label{backwardcompatibilityinwxstring}
237
238These functions are deprecated, please consider using new wxWidgets 2.0
239functions instead of them (or, even better, std::string compatible variants).
240
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}
258
259
260\membersection{std::string compatibility functions}\label{wxstringat}
261
262The supported functions are only listed here, please see any STL reference for
263their documentation.
264
265\begin{verbatim}
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);
270
271 // lib.string.capacity
272 // return the length of the string
273 size_t size() const;
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
281 void clear();
282 // returns true if the string is empty
283 bool empty() const;
284
285 // lib.string.access
286 // return the character at position n
287 char at(size_t n) const;
288 // returns the writable character at position n
289 char& at(size_t n);
290
291 // lib.string.modifiers
292 // append a string
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);
298
299 // append n copies of ch
300 wxString& append(size_t n, char ch);
301
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);
310
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);
315
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);
320
321 // delete characters from nStart to nStart + nLen
322 wxString& erase(size_t nStart = 0, size_t nLen = npos);
323
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);
334
335 // swap two strings
336 void swap(wxString& str);
337
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.
341
342 // find a substring
343 size_t find(const wxString& str, size_t nStart = 0) const;
344
345 // find first n characters of sz
346 size_t find(const char* sz, size_t nStart = 0, size_t n = npos) const;
347
348 // find the first occurrence of character ch after nStart
349 size_t find(char ch, size_t nStart = 0) const;
350
351 // rfind() family is exactly like find() but works right to left
352
353 // as find, but from the end
354 size_t rfind(const wxString& str, size_t nStart = npos) const;
355
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;
361
362 // find first/last occurrence of any character in the set
363
364 //
365 size_t find_first_of(const wxString& str, size_t nStart = 0) const;
366 //
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;
370 //
371 size_t find_last_of (const wxString& str, size_t nStart = npos) const;
372 //
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;
376
377 // find first/last occurrence of any character not in the set
378
379 //
380 size_t find_first_not_of(const wxString& str, size_t nStart = 0) const;
381 //
382 size_t find_first_not_of(const char* s, size_t nStart = 0) const;
383 //
384 size_t find_first_not_of(char ch, size_t nStart = 0) const;
385 //
386 size_t find_last_not_of(const wxString& str, size_t nStart=npos) const;
387 //
388 size_t find_last_not_of(const char* s, size_t nStart = npos) const;
389 //
390 size_t find_last_not_of(char ch, size_t nStart = npos) const;
391
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.
394
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;
407
408 // substring extraction
409 wxString substr(size_t nStart = 0, size_t nLen = npos) const;
410\end{verbatim}
411
412%%%%% MEMBERS HERE %%%%%
413\helponly{\insertatlevel{2}{
414
415\wxheading{Members}
416
417}}
418
419
420\membersection{wxString::wxString}\label{wxstringconstruct}
421
422\func{}{wxString}{\void}
423
424Default constructor. Initializes the string to {\tt ""} (empty string).
425
426\func{}{wxString}{\param{const wxString\&}{ x}}
427
428Copy constructor.
429
430\func{}{wxString}{\param{wxChar}{ ch}, \param{size\_t}{ n = 1}}
431
432Constructs a string of {\it n} copies of character {\it ch}.
433
434\func{}{wxString}{\param{const wxChar*}{ psz}, \param{size\_t}{ nLength = wxSTRING\_MAXLEN}}
435
436Takes first {\it nLength} characters from the C string {\it psz}.
437The default value of {\tt wxSTRING\_MAXLEN} means to take all the string.
438
439Note that this constructor may be used even if {\it psz} points to a buffer
440with binary data (i.e. containing {\tt NUL} characters) as long as you provide
441the correct value for {\it nLength}. However, the default form of it works
442only with strings without intermediate {\tt NUL}s because it uses
443{\tt strlen()} to calculate the effective length and it would not give correct
444results otherwise.
445
446\func{}{wxString}{\param{const unsigned char*}{ psz}, \param{size\_t}{ nLength = wxSTRING\_MAXLEN}}
447
448For compilers using unsigned char: takes first {\it nLength} characters from the C string {\it psz}.
449The default value of {\tt wxSTRING\_MAXLEN} means take all the string.
450For ANSI builds only (note the use of {\tt char} instead of {\tt wxChar}).
451
452\wxheading{Constructors with conversion}
453
454The following constructors allow you to construct wxString from a wide string
455in ANSI build or from a C string in Unicode build.
456
457\func{}{wxString}{\param{const wchar\_t*}{ psz}, \param{wxMBConv\&}{ conv}, \param{size\_t}{ nLength = wxSTRING\_MAXLEN}}
458
459Initializes the string from first \arg{nLength} characters of wide string.
460The default value of {\tt wxSTRING\_MAXLEN} means take all the string.
461In ANSI build, \arg{conv}'s
462\helpref{WC2MB}{wxmbconvwc2mb} method is called to
463convert \arg{psz} to wide string. It is ignored in Unicode build.
464
465\func{}{wxString}{\param{const char*}{ psz}, \param{wxMBConv\&}{ conv = wxConvLibc}, \param{size\_t}{ nLength = wxSTRING\_MAXLEN}}
466
467Initializes the string from first \arg{nLength} characters of C string.
468The default value of {\tt wxSTRING\_MAXLEN} means take all the string.
469In Unicode build, \arg{conv}'s
470\helpref{MB2WC}{wxmbconvmb2wc} method is called to
471convert \arg{psz} to wide string (the default converter uses current locale's
472charset). It is ignored in ANSI build.
473
474\wxheading{See also}
475
476\helpref{wxMBConv classes}{mbconvclasses}, \helpref{mb\_str}{wxstringmbstr},
477\helpref{wc\_str}{wxstringwcstr}
478
479
480\membersection{wxString::\destruct{wxString}}\label{wxstringdestruct}
481
482\func{}{\destruct{wxString}}{\void}
483
484String destructor. Note that this is not virtual, so wxString must not be inherited from.
485
486
487\membersection{wxString::Alloc}\label{wxstringalloc}
488
489\func{void}{Alloc}{\param{size\_t}{ nLen}}
490
491Preallocate enough space for wxString to store {\it nLen} characters. This function
492may be used to increase speed when the string is constructed by repeated
493concatenation as in
494
495\begin{verbatim}
496
497// delete all vowels from the string
498wxString DeleteAllVowels(const wxString& original)
499{
500 wxString result;
501
502 size_t len = original.length();
503
504 result.Alloc(len);
505
506 for ( size_t n = 0; n < len; n++ )
507 {
508 if ( strchr("aeuio", tolower(original[n])) == NULL )
509 result += original[n];
510 }
511
512 return result;
513}
514
515\end{verbatim}
516
517because it will avoid the need to reallocate string memory many times (in case
518of long strings). Note that it does not set the maximal length of a string - it
519will still expand if more than {\it nLen} characters are stored in it. Also, it
520does not truncate the existing string (use
521\helpref{Truncate()}{wxstringtruncate} for this) even if its current length is
522greater than {\it nLen}
523
524
525\membersection{wxString::Append}\label{wxstringappend}
526
527\func{wxString\&}{Append}{\param{const wxChar*}{ psz}}
528
529Concatenates {\it psz} to this string, returning a reference to it.
530
531\func{wxString\&}{Append}{\param{wxChar}{ ch}, \param{int}{ count = 1}}
532
533Concatenates character {\it ch} to this string, {\it count} times, returning a reference
534to it.
535
536
537\membersection{wxString::AfterFirst}\label{wxstringafterfirst}
538
539\constfunc{wxString}{AfterFirst}{\param{wxChar}{ ch}}
540
541Gets all the characters after the first occurrence of {\it ch}.
542Returns the empty string if {\it ch} is not found.
543
544
545\membersection{wxString::AfterLast}\label{wxstringafterlast}
546
547\constfunc{wxString}{AfterLast}{\param{wxChar}{ ch}}
548
549Gets all the characters after the last occurrence of {\it ch}.
550Returns the whole string if {\it ch} is not found.
551
552
553\membersection{wxString::BeforeFirst}\label{wxstringbeforefirst}
554
555\constfunc{wxString}{BeforeFirst}{\param{wxChar}{ ch}}
556
557Gets all characters before the first occurrence of {\it ch}.
558Returns the whole string if {\it ch} is not found.
559
560
561\membersection{wxString::BeforeLast}\label{wxstringbeforelast}
562
563\constfunc{wxString}{BeforeLast}{\param{wxChar}{ ch}}
564
565Gets all characters before the last occurrence of {\it ch}.
566Returns the empty string if {\it ch} is not found.
567
568
569\membersection{wxString::c\_str}\label{wxstringcstr}
570
571\constfunc{const wxChar *}{c\_str}{\void}
572
573Returns a pointer to the string data ({\tt const char*} in ANSI build,
574{\tt const wchar\_t*} in Unicode build).
575
576Note that the returned value is not convertible to {\tt char*} or
577{\tt wchar\_t*}, use \helpref{char\_str}{wxstringcharstr} or
578\helpref{wchar\_string}{wxstringwcharstr} if you need to pass string value
579to a function expecting non-const pointer.
580
581\wxheading{See also}
582
583\helpref{mb\_str}{wxstringmbstr}, \helpref{wc\_str}{wxstringwcstr},
584\helpref{fn\_str}{wxstringfnstr}, \helpref{char\_str}{wxstringcharstr},
585\helpref{wchar\_string}{wxstringwcharstr}
586
587\membersection{wxString::char\_str}\label{wxstringcharstr}
588
589\constfunc{wxWritableCharBuffer}{char\_str}{\param{wxMBConv\&}{ conv = wxConvLibc}}
590
591Returns an object with string data that is implicitly convertible to
592{\tt char*} pointer. Note that any change to the returned buffer is lost and so
593this function is only usable for passing strings to legacy libraries that
594don't have const-correct API. Use \helpref{wxStringBuffer}{wxstringbuffer} if
595you want to modify the string.
596
597\wxheading{See also}
598
599\helpref{mb\_str}{wxstringmbstr}, \helpref{wc\_str}{wxstringwcstr},
600\helpref{fn\_str}{wxstringfnstr}, \helpref{c\_str}{wxstringcstr},
601\helpref{wchar\_str}{wxstringwcharstr}
602
603
604\membersection{wxString::Clear}\label{wxstringclear}
605
606\func{void}{Clear}{\void}
607
608Empties the string and frees memory occupied by it.
609
610See also: \helpref{Empty}{wxstringempty}
611
612
613\membersection{wxString::Cmp}\label{wxstringcmp}
614
615\constfunc{int}{Cmp}{\param{const wxString\&}{ s}}
616
617\constfunc{int}{Cmp}{\param{const wxChar*}{ psz}}
618
619Case-sensitive comparison.
620
621Returns a positive value if the string is greater than the argument, zero if
622it is equal to it or a negative value if it is less than the argument (same semantics
623as the standard {\it strcmp()} function).
624
625See also \helpref{CmpNoCase}{wxstringcmpnocase}, \helpref{IsSameAs}{wxstringissameas}.
626
627
628\membersection{wxString::CmpNoCase}\label{wxstringcmpnocase}
629
630\constfunc{int}{CmpNoCase}{\param{const wxString\&}{ s}}
631
632\constfunc{int}{CmpNoCase}{\param{const wxChar*}{ psz}}
633
634Case-insensitive comparison.
635
636Returns a positive value if the string is greater than the argument, zero if
637it is equal to it or a negative value if it is less than the argument (same semantics
638as the standard {\it strcmp()} function).
639
640See also \helpref{Cmp}{wxstringcmp}, \helpref{IsSameAs}{wxstringissameas}.
641
642
643\membersection{wxString::CompareTo}\label{wxstringcompareto}
644
645\begin{verbatim}
646enum wxString::caseCompare {exact, ignoreCase};
647\end{verbatim}
648
649\constfunc{int}{CompareTo}{\param{const wxChar*}{ psz}, \param{caseCompare}{ cmp = exact}}
650
651Case-sensitive comparison. Returns 0 if equal, 1 if greater or -1 if less.
652
653This is a wxWidgets 1.xx compatibility function; use \helpref{Cmp}{wxstringcmp} instead.
654
655
656\membersection{wxString::Contains}\label{wxstringcontains}
657
658\constfunc{bool}{Contains}{\param{const wxString\&}{ str}}
659
660Returns \true if target appears anywhere in wxString; else \false.
661
662This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
663
664
665\membersection{wxString::Empty}\label{wxstringempty}
666
667\func{void}{Empty}{\void}
668
669Makes the string empty, but doesn't free memory occupied by the string.
670
671See also: \helpref{Clear()}{wxstringclear}.
672
673
674\membersection{wxString::Find}\label{wxstringfind}
675
676\constfunc{int}{Find}{\param{wxUniChar}{ ch}, \param{bool}{ fromEnd = false}}
677
678Searches for the given character. Returns the starting index, or {\tt wxNOT\_FOUND} if not found.
679
680\constfunc{int}{Find}{\param{const wxString\&}{ sub}}
681
682Searches for the given string. Returns the starting index, or {\tt wxNOT\_FOUND} if not found.
683
684
685\membersection{wxString::First}\label{wxstringfirst}
686
687\func{int}{First}{\param{wxChar}{ c}}
688
689\constfunc{int}{First}{\param{const wxChar*}{ psz}}
690
691\constfunc{int}{First}{\param{const wxString\&}{ str}}
692
693Same as \helpref{Find}{wxstringfind}.
694
695This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
696
697
698\membersection{wxString::fn\_str}\label{wxstringfnstr}
699
700\constfunc{const wchar\_t*}{fn\_str}{\void}
701
702\constfunc{const char*}{fn\_str}{\void}
703
704\constfunc{const wxCharBuffer}{fn\_str}{\void}
705
706Returns string representation suitable for passing to OS' functions for
707file handling. In ANSI build, this is same as \helpref{c\_str}{wxstringcstr}.
708In Unicode build, returned value can be either wide character string
709or C string in charset matching the {\tt wxConvFileName} object, depending on
710the OS.
711
712\wxheading{See also}
713
714\helpref{wxMBConv}{wxmbconv},
715\helpref{wc\_str}{wxstringwcstr}, \helpref{mb\_str}{wxstringwcstr}
716
717
718\membersection{wxString::Format}\label{wxstringformat}
719
720\func{static wxString}{Format}{\param{const wxChar }{*format}, \param{}{...}}
721
722This static function returns the string containing the result of calling
723\helpref{Printf}{wxstringprintf} with the passed parameters on it.
724
725\wxheading{See also}
726
727\helpref{FormatV}{wxstringformatv}, \helpref{Printf}{wxstringprintf}
728
729
730\membersection{wxString::FormatV}\label{wxstringformatv}
731
732\func{static wxString}{FormatV}{\param{const wxChar }{*format}, \param{va\_list }{argptr}}
733
734This static function returns the string containing the result of calling
735\helpref{PrintfV}{wxstringprintfv} with the passed parameters on it.
736
737\wxheading{See also}
738
739\helpref{Format}{wxstringformat}, \helpref{PrintfV}{wxstringprintfv}
740
741
742\membersection{wxString::Freq}\label{wxstringfreq}
743
744\constfunc{int}{Freq}{\param{wxChar }{ch}}
745
746Returns the number of occurrences of {\it ch} in the string.
747
748This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
749
750
751\membersection{wxString::FromAscii}\label{wxstringfromascii}
752
753\func{static wxString }{FromAscii}{\param{const char*}{ s}}
754
755\func{static wxString }{FromAscii}{\param{const char}{ c}}
756
757Converts the string or character from an ASCII, 7-bit form
758to the native wxString representation. Most useful when using
759a Unicode build of wxWidgets (note the use of {\tt char} instead of {\tt wxChar}).
760Use \helpref{wxString constructors}{wxstringconstruct} if you
761need to convert from another charset.
762
763
764\membersection{wxString::GetChar}\label{wxstringgetchar}
765
766\constfunc{wxChar}{GetChar}{\param{size\_t}{ n}}
767
768Returns the character at position {\it n} (read-only).
769
770
771\membersection{wxString::GetData}\label{wxstringgetdata}
772
773\constfunc{const wxChar*}{GetData}{\void}
774
775wxWidgets compatibility conversion. Returns a constant pointer to the data in the string.
776
777
778\membersection{wxString::GetWritableChar}\label{wxstringgetwritablechar}
779
780\func{wxChar\&}{GetWritableChar}{\param{size\_t}{ n}}
781
782Returns a reference to the character at position {\it n}.
783
784
785\membersection{wxString::GetWriteBuf}\label{wxstringgetwritebuf}
786
787\func{wxChar*}{GetWriteBuf}{\param{size\_t}{ len}}
788
789Returns a writable buffer of at least {\it len} bytes.
790It returns a pointer to a new memory block, and the
791existing data will not be copied.
792
793Call \helpref{wxString::UngetWriteBuf}{wxstringungetwritebuf} as soon as
794possible to put the string back into a reasonable state.
795
796This method is deprecated, please use
797\helpref{wxStringBuffer}{wxstringbuffer} or
798\helpref{wxStringBufferLength}{wxstringbufferlength} instead.
799
800
801\membersection{wxString::Index}\label{wxstringindex}
802
803\constfunc{size\_t}{Index}{\param{wxChar}{ ch}}
804
805\constfunc{size\_t}{Index}{\param{const wxChar*}{ sz}}
806
807Same as \helpref{wxString::Find}{wxstringfind}.
808
809This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
810
811
812\membersection{wxString::IsAscii}\label{wxstringisascii}
813
814\constfunc{bool}{IsAscii}{\void}
815
816Returns \true if the string contains only ASCII characters.
817
818This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
819
820
821\membersection{wxString::IsEmpty}\label{wxstringisempty}
822
823\constfunc{bool}{IsEmpty}{\void}
824
825Returns \true if the string is empty.
826
827
828\membersection{wxString::IsNull}\label{wxstringisnull}
829
830\constfunc{bool}{IsNull}{\void}
831
832Returns \true if the string is empty (same as \helpref{IsEmpty}{wxstringisempty}).
833
834This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
835
836
837\membersection{wxString::IsNumber}\label{wxstringisnumber}
838
839\constfunc{bool}{IsNumber}{\void}
840
841Returns \true if the string is an integer (with possible sign).
842
843This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
844
845
846\membersection{wxString::IsSameAs}\label{wxstringissameas}
847
848\constfunc{bool}{IsSameAs}{\param{const wxChar*}{ psz}, \param{bool}{ caseSensitive = true}}
849
850Test for string equality, case-sensitive (default) or not.
851
852caseSensitive is \true by default (case matters).
853
854Returns \true if strings are equal, \false otherwise.
855
856See also \helpref{Cmp}{wxstringcmp}, \helpref{CmpNoCase}{wxstringcmpnocase}
857
858\constfunc{bool}{IsSameAs}{\param{wxChar}{ c}, \param{bool}{ caseSensitive = true}}
859
860Test whether the string is equal to the single character {\it c}. The test is
861case-sensitive if {\it caseSensitive} is \true (default) or not if it is \false.
862
863Returns \true if the string is equal to the character, \false otherwise.
864
865See also \helpref{Cmp}{wxstringcmp}, \helpref{CmpNoCase}{wxstringcmpnocase}
866
867
868\membersection{wxString::IsWord}\label{wxstringisword}
869
870\constfunc{bool}{IsWord}{\void}
871
872Returns \true if the string is a word.
873
874This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
875
876
877\membersection{wxString::Last}\label{wxstringlast}
878
879\constfunc{wxChar}{Last}{\void}
880
881Returns the last character.
882
883\func{wxChar\&}{Last}{\void}
884
885Returns a reference to the last character (writable).
886
887This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
888
889
890\membersection{wxString::Left}\label{wxstringleft}
891
892\constfunc{wxString}{Left}{\param{size\_t}{ count}}
893
894Returns the first {\it count} characters of the string.
895
896
897\membersection{wxString::Len}\label{wxstringlen}
898
899\constfunc{size\_t}{Len}{\void}
900
901Returns the length of the string.
902
903
904\membersection{wxString::Length}\label{wxstringlength}
905
906\constfunc{size\_t}{Length}{\void}
907
908Returns the length of the string (same as Len).
909
910This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
911
912
913\membersection{wxString::Lower}\label{wxstringlower}
914
915\constfunc{wxString}{Lower}{\void}
916
917Returns this string converted to the lower case.
918
919
920\membersection{wxString::LowerCase}\label{wxstringlowercase}
921
922\func{void}{LowerCase}{\void}
923
924Same as MakeLower.
925
926This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
927
928
929\membersection{wxString::MakeLower}\label{wxstringmakelower}
930
931\func{wxString\&}{MakeLower}{\void}
932
933Converts all characters to lower case and returns the result.
934
935
936\membersection{wxString::MakeUpper}\label{wxstringmakeupper}
937
938\func{wxString\&}{MakeUpper}{\void}
939
940Converts all characters to upper case and returns the result.
941
942
943\membersection{wxString::Matches}\label{wxstringmatches}
944
945\constfunc{bool}{Matches}{\param{const wxString\&}{ mask}}
946
947Returns \true if the string contents matches a mask containing '*' and '?'.
948
949
950\membersection{wxString::mb\_str}\label{wxstringmbstr}
951
952\constfunc{const char*}{mb\_str}{\param{wxMBConv\&}{ conv = wxConvLibc}}
953
954\constfunc{const wxCharBuffer}{mb\_str}{\param{wxMBConv\&}{ conv = wxConvLibc}}
955
956Returns multibyte (C string) representation of the string.
957In Unicode build, converts using \arg{conv}'s \helpref{cWC2MB}{wxmbconvcwc2mb}
958method and returns wxCharBuffer. In ANSI build, this function is same
959as \helpref{c\_str}{wxstringcstr}.
960The macro wxWX2MBbuf is defined as the correct return type (without const).
961
962\wxheading{See also}
963
964\helpref{wxMBConv}{wxmbconv},
965\helpref{c\_str}{wxstringcstr}, \helpref{wc\_str}{wxstringwcstr},
966\helpref{fn\_str}{wxstringfnstr}, \helpref{char\_str}{wxstringcharstr}
967
968
969\membersection{wxString::Mid}\label{wxstringmid}
970
971\constfunc{wxString}{Mid}{\param{size\_t}{ first}, \param{size\_t}{ count = wxSTRING\_MAXLEN}}
972
973Returns a substring starting at {\it first}, with length {\it count}, or the rest of
974the string if {\it count} is the default value.
975
976
977\membersection{wxString::Pad}\label{wxstringpad}
978
979\func{wxString\&}{Pad}{\param{size\_t}{ count}, \param{wxChar}{ pad = ' '}, \param{bool}{ fromRight = true}}
980
981Adds {\it count} copies of {\it pad} to the beginning, or to the end of the string (the default).
982
983Removes spaces from the left or from the right (default).
984
985
986\membersection{wxString::Prepend}\label{wxstringprepend}
987
988\func{wxString\&}{Prepend}{\param{const wxString\&}{ str}}
989
990Prepends {\it str} to this string, returning a reference to this string.
991
992
993\membersection{wxString::Printf}\label{wxstringprintf}
994
995\func{int}{Printf}{\param{const wxChar* }{pszFormat}, \param{}{...}}
996
997Similar to the standard function {\it sprintf()}. Returns the number of
998characters written, or an integer less than zero on error.
999
1000Note that if {\tt wxUSE\_PRINTF\_POS\_PARAMS} is set to 1, then this function supports
1001Unix98-style positional parameters:
1002
1003\begin{verbatim}
1004 wxString str;
1005
1006 str.Printf(wxT("%d %d %d"), 1, 2, 3);
1007 // str now contains "1 2 3"
1008
1009 str.Printf(wxT("%2$d %3$d %1$d"), 1, 2, 3);
1010 // str now contains "2 3 1"
1011\end{verbatim}
1012
1013{\bf NB:} This function will use a safe version of {\it vsprintf()} (usually called
1014{\it vsnprintf()}) whenever available to always allocate the buffer of correct
1015size. Unfortunately, this function is not available on all platforms and the
1016dangerous {\it vsprintf()} will be used then which may lead to buffer overflows.
1017
1018
1019\membersection{wxString::PrintfV}\label{wxstringprintfv}
1020
1021\func{int}{PrintfV}{\param{const wxChar* }{pszFormat}, \param{va\_list}{ argPtr}}
1022
1023Similar to vprintf. Returns the number of characters written, or an integer less than zero
1024on error.
1025
1026
1027\membersection{wxString::Remove}\label{wxstringremove}
1028
1029\func{wxString\&}{Remove}{\param{size\_t}{ pos}}
1030
1031Same as Truncate. Removes the portion from {\it pos} to the end of the string.
1032
1033\func{wxString\&}{Remove}{\param{size\_t}{ pos}, \param{size\_t}{ len}}
1034
1035Removes {\it len} characters from the string, starting at {\it pos}.
1036
1037This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
1038
1039
1040\membersection{wxString::RemoveLast}\label{wxstringremovelast}
1041
1042\func{wxString\&}{RemoveLast}{\void}
1043
1044Removes the last character.
1045
1046
1047\membersection{wxString::Replace}\label{wxstringreplace}
1048
1049\func{size\_t}{Replace}{\param{const wxString\&}{ strOld}, \param{const wxString\&}{ strNew}, \param{bool}{ replaceAll = true}}
1050
1051Replace first (or all) occurrences of substring with another one.
1052
1053{\it replaceAll}: global replace (default), or only the first occurrence.
1054
1055Returns the number of replacements made.
1056
1057
1058\membersection{wxString::Right}\label{wxstringright}
1059
1060\constfunc{wxString}{Right}{\param{size\_t}{ count}}
1061
1062Returns the last {\it count} characters.
1063
1064
1065\membersection{wxString::SetChar}\label{wxstringsetchar}
1066
1067\func{void}{SetChar}{\param{size\_t}{ n}, \param{wxChar}{ch}}
1068
1069Sets the character at position {\it n}.
1070
1071
1072\membersection{wxString::Shrink}\label{wxstringshrink}
1073
1074\func{void}{Shrink}{\void}
1075
1076Minimizes the string's memory. This can be useful after a call to
1077\helpref{Alloc()}{wxstringalloc} if too much memory were preallocated.
1078
1079
1080\membersection{wxString::StartsWith}\label{wxstringstartswith}
1081
1082\constfunc{bool}{StartsWith}{\param{const wxChar }{*prefix}, \param{wxString }{*rest = NULL}}
1083
1084This function can be used to test if the string starts with the specified
1085{\it prefix}. If it does, the function will return \true and put the rest
1086of the string (i.e. after the prefix) into {\it rest} string if it is not
1087{\tt NULL}. Otherwise, the function returns \false and doesn't modify the
1088{\it rest}.
1089
1090
1091\membersection{wxString::EndsWith}\label{wxstringendswith}
1092
1093\constfunc{bool}{EndsWith}{\param{const wxChar }{*suffix}, \param{wxString }{*rest = NULL}}
1094
1095This function can be used to test if the string ends with the specified
1096{\it suffix}. If it does, the function will return \true and put the
1097beginning of the string before the suffix into {\it rest} string if it is not
1098{\tt NULL}. Otherwise, the function returns \false and doesn't
1099modify the {\it rest}.
1100
1101
1102\membersection{wxString::Strip}\label{wxstringstrip}
1103
1104\begin{verbatim}
1105enum wxString::stripType {leading = 0x1, trailing = 0x2, both = 0x3};
1106\end{verbatim}
1107
1108\constfunc{wxString}{Strip}{\param{stripType}{ s = trailing}}
1109
1110Strip characters at the front and/or end. The same as Trim except that it
1111doesn't change this string.
1112
1113This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
1114
1115
1116\membersection{wxString::SubString}\label{wxstringsubstring}
1117
1118\constfunc{wxString}{SubString}{\param{size\_t}{ from}, \param{size\_t}{ to}}
1119
1120Returns the part of the string between the indices {\it from} and {\it to}
1121inclusive.
1122
1123This is a wxWidgets 1.xx compatibility function, use \helpref{Mid}{wxstringmid}
1124instead (but note that parameters have different meaning).
1125
1126
1127\membersection{wxString::ToAscii}\label{wxstringtoascii}
1128
1129\constfunc{const char*}{ToAscii}{\void}
1130
1131Converts the string to an ASCII, 7-bit string (ANSI builds only).
1132
1133\constfunc{const wxCharBuffer}{ToAscii}{\void}
1134
1135Converts the string to an ASCII, 7-bit string in the form of
1136a wxCharBuffer (Unicode builds only).
1137
1138Note that this conversion only works if the string contains only ASCII
1139characters. The \helpref{mb\_str}{wxstringmbstr} method provides more
1140powerful means of converting wxString to C string.
1141
1142
1143\membersection{wxString::ToDouble}\label{wxstringtodouble}
1144
1145\constfunc{bool}{ToDouble}{\param{double}{ *val}}
1146
1147Attempts to convert the string to a floating point number. Returns \true on
1148success (the number is stored in the location pointed to by {\it val}) or \false
1149if the string does not represent such number.
1150
1151\wxheading{See also}
1152
1153\helpref{wxString::ToLong}{wxstringtolong},\\
1154\helpref{wxString::ToULong}{wxstringtoulong}
1155
1156
1157\membersection{wxString::ToLong}\label{wxstringtolong}
1158
1159\constfunc{bool}{ToLong}{\param{long}{ *val}, \param{int }{base = $10$}}
1160
1161Attempts to convert the string to a signed integer in base {\it base}. Returns
1162\true on success in which case the number is stored in the location
1163pointed to by {\it val} or \false if the string does not represent a
1164valid number in the given base.
1165
1166The value of {\it base} must be comprised between $2$ and $36$, inclusive, or
1167be a special value $0$ which means that the usual rules of {\tt C} numbers are
1168applied: if the number starts with {\tt 0x} it is considered to be in base
1169$16$, if it starts with {\tt 0} - in base $8$ and in base $10$ otherwise. Note
1170that you may not want to specify the base $0$ if you are parsing the numbers
1171which may have leading zeroes as they can yield unexpected (to the user not
1172familiar with C) results.
1173
1174\wxheading{See also}
1175
1176\helpref{wxString::ToDouble}{wxstringtodouble},\\
1177\helpref{wxString::ToULong}{wxstringtoulong}
1178
1179
1180\membersection{wxString::ToLongLong}\label{wxstringtolonglong}
1181
1182\constfunc{bool}{ToLongLong}{\param{wxLongLong\_t}{ *val}, \param{int }{base = $10$}}
1183
1184This is exactly the same as \helpref{ToLong}{wxstringtolong} but works with 64
1185bit integer numbers.
1186
1187Notice that currently it doesn't work (always returns \false) if parsing of 64
1188bit numbers is not supported by the underlying C run-time library. Compilers
1189with C99 support and Microsoft Visual C++ version 7 and higher do support this.
1190
1191\wxheading{See also}
1192
1193\helpref{wxString::ToLong}{wxstringtolong},\\
1194\helpref{wxString::ToULongLong}{wxstringtoulonglong}
1195
1196
1197\membersection{wxString::ToULong}\label{wxstringtoulong}
1198
1199\constfunc{bool}{ToULong}{\param{unsigned long}{ *val}, \param{int }{base = $10$}}
1200
1201Attempts to convert the string to an unsigned integer in base {\it base}.
1202Returns \true on success in which case the number is stored in the
1203location pointed to by {\it val} or \false if the string does not
1204represent a valid number in the given base. Please notice that this function
1205behaves in the same way as the standard \texttt{strtoul()} and so it simply
1206converts negative numbers to unsigned representation instead of rejecting them
1207(e.g. $-1$ is returned as \texttt{ULONG\_MAX}).
1208
1209See \helpref{wxString::ToLong}{wxstringtolong} for the more detailed
1210description of the {\it base} parameter.
1211
1212\wxheading{See also}
1213
1214\helpref{wxString::ToDouble}{wxstringtodouble},\\
1215\helpref{wxString::ToLong}{wxstringtolong}
1216
1217
1218\membersection{wxString::ToULongLong}\label{wxstringtoulonglong}
1219
1220\constfunc{bool}{ToULongLong}{\param{wxULongLong\_t}{ *val}, \param{int }{base = $10$}}
1221
1222This is exactly the same as \helpref{ToULong}{wxstringtoulong} but works with 64
1223bit integer numbers.
1224
1225Please see \helpref{ToLongLong}{wxstringtolonglong} for additional remarks.
1226
1227
1228\membersection{wxString::Trim}\label{wxstringtrim}
1229
1230\func{wxString\&}{Trim}{\param{bool}{ fromRight = true}}
1231
1232Removes white-space (space, tabs, form feed, newline and carriage return) from
1233the left or from the right end of the string (right is default).
1234
1235
1236\membersection{wxString::Truncate}\label{wxstringtruncate}
1237
1238\func{wxString\&}{Truncate}{\param{size\_t}{ len}}
1239
1240Truncate the string to the given length.
1241
1242
1243\membersection{wxString::UngetWriteBuf}\label{wxstringungetwritebuf}
1244
1245\func{void}{UngetWriteBuf}{\void}
1246
1247\func{void}{UngetWriteBuf}{\param{size\_t }{len}}
1248
1249Puts the string back into a reasonable state (in which it can be used
1250normally), after
1251\rtfsp\helpref{wxString::GetWriteBuf}{wxstringgetwritebuf} was called.
1252
1253The version of the function without the {\it len} parameter will calculate the
1254new string length itself assuming that the string is terminated by the first
1255{\tt NUL} character in it while the second one will use the specified length
1256and thus is the only version which should be used with the strings with
1257embedded {\tt NUL}s (it is also slightly more efficient as {\tt strlen()}
1258doesn't have to be called).
1259
1260This method is deprecated, please use
1261\helpref{wxStringBuffer}{wxstringbuffer} or
1262\helpref{wxStringBufferLength}{wxstringbufferlength} instead.
1263
1264
1265\membersection{wxString::Upper}\label{wxstringupper}
1266
1267\constfunc{wxString}{Upper}{\void}
1268
1269Returns this string converted to upper case.
1270
1271
1272\membersection{wxString::UpperCase}\label{wxstringuppercase}
1273
1274\func{void}{UpperCase}{\void}
1275
1276The same as MakeUpper.
1277
1278This is a wxWidgets 1.xx compatibility function; you should not use it in new code.
1279
1280
1281\membersection{wxString::wc\_str}\label{wxstringwcstr}
1282
1283\constfunc{const wchar\_t*}{wc\_str}{\param{wxMBConv\&}{ conv}}
1284
1285\constfunc{const wxWCharBuffer}{wc\_str}{\param{wxMBConv\&}{ conv}}
1286
1287Returns wide character representation of the string.
1288In ANSI build, converts using \arg{conv}'s \helpref{cMB2WC}{wxmbconvcmb2wc}
1289method and returns wxWCharBuffer. In Unicode build, this function is same
1290as \helpref{c\_str}{wxstringcstr}.
1291The macro wxWX2WCbuf is defined as the correct return type (without const).
1292
1293\wxheading{See also}
1294
1295\helpref{wxMBConv}{wxmbconv},
1296\helpref{c\_str}{wxstringcstr}, \helpref{mb\_str}{wxstringwcstr},
1297\helpref{fn\_str}{wxstringfnstr}, \helpref{wchar\_str}{wxstringwcharstr}
1298
1299\membersection{wxString::wchar\_str}\label{wxstringwcharstr}
1300
1301\constfunc{wxWritableWCharBuffer}{wchar\_str}{\void}
1302
1303Returns an object with string data that is implicitly convertible to
1304{\tt char*} pointer. Note that any change to the returned buffer is lost and so
1305this function is only usable for passing strings to legacy libraries that
1306don't have const-correct API. Use \helpref{wxStringBuffer}{wxstringbuffer} if
1307you want to modify the string.
1308
1309\wxheading{See also}
1310
1311\helpref{mb\_str}{wxstringmbstr}, \helpref{wc\_str}{wxstringwcstr},
1312\helpref{fn\_str}{wxstringfnstr}, \helpref{c\_str}{wxstringcstr},
1313\helpref{char\_str}{wxstringcharstr}
1314
1315
1316\membersection{wxString::operator!}\label{wxstringoperatornot}
1317
1318\constfunc{bool}{operator!}{\void}
1319
1320Empty string is \false, so !string will only return \true if the string is empty.
1321This allows the tests for NULLness of a {\it const wxChar *} pointer and emptiness
1322of the string to look the same in the code and makes it easier to port old code
1323to wxString.
1324
1325See also \helpref{IsEmpty()}{wxstringisempty}.
1326
1327
1328\membersection{wxString::operator $=$}\label{wxstringoperatorassign}
1329
1330\func{wxString\&}{operator $=$}{\param{const wxString\&}{ str}}
1331
1332\func{wxString\&}{operator $=$}{\param{const wxChar*}{ psz}}
1333
1334\func{wxString\&}{operator $=$}{\param{wxChar}{ c}}
1335
1336Assignment: the effect of each operation is the same as for the corresponding
1337constructor (see \helpref{wxString constructors}{wxstringconstruct}).
1338
1339
1340\membersection{wxString::operator $+$}\label{wxstringoperatorplus}
1341
1342Concatenation: all these operators return a new string equal to the
1343concatenation of the operands.
1344
1345\func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
1346
1347\func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{const wxChar*}{ y}}
1348
1349\func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{wxChar}{ y}}
1350
1351\func{wxString}{operator $+$}{\param{const wxChar*}{ x}, \param{const wxString\&}{ y}}
1352
1353
1354\membersection{wxString::operator $+=$}\label{wxstringplusequal}
1355
1356\func{void}{operator $+=$}{\param{const wxString\&}{ str}}
1357
1358\func{void}{operator $+=$}{\param{const wxChar*}{ psz}}
1359
1360\func{void}{operator $+=$}{\param{wxChar}{ c}}
1361
1362Concatenation in place: the argument is appended to the string.
1363
1364
1365\membersection{wxString::operator []}\label{wxstringoperatorbracket}
1366
1367\func{wxChar\&}{operator []}{\param{size\_t}{ i}}
1368
1369\constfunc{wxChar}{operator []}{\param{size\_t}{ i}}
1370
1371\func{wxChar\&}{operator []}{\param{int}{ i}}
1372
1373\constfunc{wxChar}{operator []}{\param{int}{ i}}
1374
1375Element extraction.
1376
1377
1378\membersection{wxString::operator ()}\label{wxstringoperatorparenth}
1379
1380\func{wxString}{operator ()}{\param{size\_t}{ start}, \param{size\_t}{ len}}
1381
1382Same as Mid (substring extraction).
1383
1384
1385\membersection{wxString::operator \cinsert}\label{wxstringoperatorout}
1386
1387\func{wxString\&}{operator \cinsert}{\param{const wxString\&}{ str}}
1388
1389\func{wxString\&}{operator \cinsert}{\param{const wxChar*}{ psz}}
1390
1391\func{wxString\&}{operator \cinsert}{\param{wxChar }{ch}}
1392
1393Same as $+=$.
1394
1395\func{wxString\&}{operator \cinsert}{\param{int}{ i}}
1396
1397\func{wxString\&}{operator \cinsert}{\param{float}{ f}}
1398
1399\func{wxString\&}{operator \cinsert}{\param{double}{ d}}
1400
1401These functions work as C++ stream insertion operators: they insert the given
1402value into the string. Precision or format cannot be set using them, you can use
1403\helpref{Printf}{wxstringprintf} for this.
1404
1405
1406\membersection{wxString::operator \cextract}\label{wxstringoperatorin}
1407
1408\func{friend istream\&}{operator \cextract}{\param{istream\&}{ is}, \param{wxString\&}{ str}}
1409
1410Extraction from a stream.
1411
1412
1413\membersection{wxString::operator const wxChar*}\label{wxstringoperatorconstcharpt}
1414
1415\constfunc{}{operator const wxChar*}{\void}
1416
1417Implicit conversion to a C string.
1418
1419
1420\membersection{Comparison operators}\label{wxstringcomparison}
1421
1422\func{bool}{operator $==$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
1423
1424\func{bool}{operator $==$}{\param{const wxString\&}{ x}, \param{const wxChar*}{ t}}
1425
1426\func{bool}{operator $!=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
1427
1428\func{bool}{operator $!=$}{\param{const wxString\&}{ x}, \param{const wxChar*}{ t}}
1429
1430\func{bool}{operator $>$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
1431
1432\func{bool}{operator $>$}{\param{const wxString\&}{ x}, \param{const wxChar*}{ t}}
1433
1434\func{bool}{operator $>=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
1435
1436\func{bool}{operator $>=$}{\param{const wxString\&}{ x}, \param{const wxChar*}{ t}}
1437
1438\func{bool}{operator $<$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
1439
1440\func{bool}{operator $<$}{\param{const wxString\&}{ x}, \param{const wxChar*}{ t}}
1441
1442\func{bool}{operator $<=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
1443
1444\func{bool}{operator $<=$}{\param{const wxString\&}{ x}, \param{const wxChar*}{ t}}
1445
1446\wxheading{Remarks}
1447
1448These comparisons are case-sensitive.
1449
1450
1451\section{\class{wxStringBuffer}}\label{wxstringbuffer}
1452
1453This tiny class allows to conveniently access the \helpref{wxString}{wxstring}
1454internal buffer as a writable pointer without any risk of forgetting to restore
1455the string to the usable state later.
1456
1457For example, assuming you have a low-level OS function called
1458{\tt GetMeaningOfLifeAsString(char *)} returning the value in the provided
1459buffer (which must be writable, of course) you might call it like this:
1460
1461\begin{verbatim}
1462 wxString theAnswer;
1463 GetMeaningOfLifeAsString(wxStringBuffer(theAnswer, 1024));
1464 if ( theAnswer != "42" )
1465 {
1466 wxLogError("Something is very wrong!");
1467 }
1468\end{verbatim}
1469
1470Note that the exact usage of this depends on whether on not wxUSE\_STL is enabled. If
1471wxUSE\_STL is enabled, wxStringBuffer creates a separate empty character buffer, and
1472if wxUSE\_STL is disabled, it uses GetWriteBuf() from wxString, keeping the same buffer
1473wxString uses intact. In other words, relying on wxStringBuffer containing the old
1474wxString data is probably not a good idea if you want to build your program in both
1475with and without wxUSE\_STL.
1476
1477\wxheading{Derived from}
1478
1479None
1480
1481\wxheading{Include files}
1482
1483<wx/string.h>
1484
1485\latexignore{\rtfignore{\wxheading{Members}}}
1486
1487
1488\membersection{wxStringBuffer::wxStringBuffer}\label{wxstringbufferctor}
1489
1490\func{}{wxStringBuffer}{\param{const wxString\& }{str}, \param{size\_t }{len}}
1491
1492Constructs a writable string buffer object associated with the given string
1493and containing enough space for at least {\it len} characters. Basically, this
1494is equivalent to calling \helpref{GetWriteBuf}{wxstringgetwritebuf} and
1495saving the result.
1496
1497
1498\membersection{wxStringBuffer::\destruct{wxStringBuffer}}\label{wxstringbufferdtor}
1499
1500\func{}{\destruct{wxStringBuffer}}{\void}
1501
1502Restores the string passed to the constructor to the usable state by calling
1503\helpref{UngetWriteBuf}{wxstringungetwritebuf} on it.
1504
1505
1506\membersection{wxStringBuffer::operator wxChar *}\label{wxstringbufferwxchar}
1507
1508\func{wxChar *}{operator wxChar *}{\void}
1509
1510Returns the writable pointer to a buffer of the size at least equal to the
1511length specified in the constructor.
1512
1513
1514
1515\section{\class{wxStringBufferLength}}\label{wxstringbufferlength}
1516
1517This tiny class allows to conveniently access the \helpref{wxString}{wxstring}
1518internal buffer as a writable pointer without any risk of forgetting to restore
1519the string to the usable state later, and allows the user to set the internal
1520length of the string.
1521
1522For example, assuming you have a low-level OS function called
1523{\tt int GetMeaningOfLifeAsString(char *)} copying the value in the provided
1524buffer (which must be writable, of course), and returning the actual length
1525of the string, you might call it like this:
1526
1527\begin{verbatim}
1528 wxString theAnswer;
1529 wxStringBuffer theAnswerBuffer(theAnswer, 1024);
1530 int nLength = GetMeaningOfLifeAsString(theAnswerBuffer);
1531 theAnswerBuffer.SetLength(nLength);
1532 if ( theAnswer != "42" )
1533 {
1534 wxLogError("Something is very wrong!");
1535 }
1536\end{verbatim}
1537
1538Note that the exact usage of this depends on whether on not wxUSE\_STL is enabled. If
1539wxUSE\_STL is enabled, wxStringBuffer creates a separate empty character buffer, and
1540if wxUSE\_STL is disabled, it uses GetWriteBuf() from wxString, keeping the same buffer
1541wxString uses intact. In other words, relying on wxStringBuffer containing the old
1542wxString data is probably not a good idea if you want to build your program in both
1543with and without wxUSE\_STL.
1544
1545Note that SetLength {\tt must} be called before wxStringBufferLength destructs.
1546
1547\wxheading{Derived from}
1548
1549None
1550
1551\wxheading{Include files}
1552
1553<wx/string.h>
1554
1555\latexignore{\rtfignore{\wxheading{Members}}}
1556
1557
1558\membersection{wxStringBufferLength::wxStringBufferLength}\label{wxstringbufferlengthctor}
1559
1560\func{}{wxStringBufferLength}{\param{const wxString\& }{str}, \param{size\_t }{len}}
1561
1562Constructs a writable string buffer object associated with the given string
1563and containing enough space for at least {\it len} characters. Basically, this
1564is equivalent to calling \helpref{GetWriteBuf}{wxstringgetwritebuf} and
1565saving the result.
1566
1567
1568\membersection{wxStringBufferLength::\destruct{wxStringBufferLength}}\label{wxstringbufferlengthdtor}
1569
1570\func{}{\destruct{wxStringBufferLength}}{\void}
1571
1572Restores the string passed to the constructor to the usable state by calling
1573\helpref{UngetWriteBuf}{wxstringungetwritebuf} on it.
1574
1575
1576\membersection{wxStringBufferLength::SetLength}\label{wxstringbufferlengthsetlength}
1577
1578\func{void}{SetLength}{\param{size\_t }{nLength}}
1579
1580Sets the internal length of the string referred to by wxStringBufferLength to
1581{\it nLength} characters.
1582
1583Must be called before wxStringBufferLength destructs.
1584
1585
1586\membersection{wxStringBufferLength::operator wxChar *}\label{wxstringbufferlengthwxchar}
1587
1588\func{wxChar *}{operator wxChar *}{\void}
1589
1590Returns the writable pointer to a buffer of the size at least equal to the
1591length specified in the constructor.
1592
1593