]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/wxstring.tex
Corrected some .tex problems
[wxWidgets.git] / docs / latex / wx / wxstring.tex
1 \section{\class{wxString}}\label{wxstring}
2
3 wxString is a class representing a character string. Please see the
4 \helpref{wxString overview}{wxstringoverview} for more information about it. As explained
5 there, wxString implements about 90\% of methods of the std::string class (iterators
6 are not supported, nor all methods which use them).
7 These standard functions are not documented in this manual so please see the STL documentation.
8 The behaviour of all these functions is identical to the behaviour described
9 there.
10
11 \wxheading{Derived from}
12
13 None
14
15 \wxheading{Include files}
16
17 <wx/string.h>
18
19 \wxheading{See also}
20
21 \overview{Overview}{wxstringoverview}
22
23 \latexignore{\rtfignore{\wxheading{Function groups}}}
24
25 \membersection{Constructors and assignment operators}
26
27 A strign may be constructed either from a C string, (some number of copies of)
28 a single character or a wide (UNICODE) string. For all constructors (except the
29 default which creates an empty string) there is also a corresponding assignment
30 operator.
31
32 \helpref{wxString}{wxstringconstruct}\\
33 \helpref{operator $=$}{wxstringoperatorassign}\\
34 \helpref{\destruct{wxString}}{wxstringdestruct}
35
36 \membersection{String length}
37
38 These functions return the string length and check whether the string is empty
39 or empty it.
40
41 \helpref{Len}{wxstringlen}\\
42 \helpref{IsEmpty}{wxstringisempty}\\
43 \helpref{operator!}{wxstringoperatornot}\\
44 \helpref{Empty}{wxstringempty}\\
45 \helpref{Clear}{wxstringclear}
46
47 \membersection{Character access}
48
49 Many functions in this section take a character index in the string. As with C
50 strings and/or arrays, the indices start from $0$, so the first character of a
51 string is string[$0$]. Attempt to access a character beyond the end of the
52 string (which may be even $0$ if the string is empty) will provocate an assert
53 failure in \helpref{debug build}{debuggingoverview}, but no checks are done in
54 release builds.
55
56 This section also contains both implicit and explicit conversions to C style
57 strings. Although implicit conversion is quite convenient, it is advised to use
58 explicit \helpref{c\_str()}{wxstringcstr} method for the sake of clarity. Also
59 see \helpref{overiview}{wxstringadvices} for the cases where it is necessary to
60 use it.
61
62 \helpref{GetChar}{wxstringgetchar}\\
63 \helpref{GetWritableChar}{wxstringgetwritablechar}\\
64 \helpref{SetChar}{wxstringsetchar}\\
65 \helpref{Last}{wxstringlast}\\
66 \helpref{operator []}{wxstringoperatorbracket}\\
67 \helpref{c\_str}{wxstringcstr}\\
68 \helpref{operator const char*}{wxstringoperatorconstcharpt}
69
70 \membersection{Concatenation}
71
72 Anything may be concatenated (appended to) with a string. However, you can't
73 append something to a C string (including literal constants), so to do this it
74 should be converted to a wxString first.
75
76 \helpref{operator \cinsert}{wxstringoperatorout}\\
77 \helpref{operator $+=$}{wxstringplusequal}\\
78 \helpref{operator $+$}{wxstringoperatorplus}\\
79 \helpref{Append}{wxstringappend}\\
80 \helpref{Prepend}{wxstringprepend}
81
82 \membersection{Comparison}
83
84 The default comparison function \helpref{Cmp}{wxstringcmp} is case-sensitive and
85 so is the default version of \helpref{IsSameAs}{wxstringissameas}. For case
86 insensitive comparisons you should use \helpref{CmpNoCase}{wxstringcmpnocase} or
87 give a second parameter to IsSameAs. This last function is may be more
88 convenient if only equality of the strings matters because it returns a boolean
89 true value if the strings are the same and not 0 (which is usually FALSE in C)
90 as Cmp does.
91
92 \helpref{Matches}{wxstringmatches} is a poor man's regular expression matcher:
93 it only understands '*' and '?' metacharacters in the sense of DOS command line
94 interpreter.
95
96 \helpref{Cmp}{wxstringcmp}\\
97 \helpref{CmpNoCase}{wxstringcmpnocase}\\
98 \helpref{IsSameAs}{wxstringissameas}\\
99 \helpref{Matches}{wxstringmatches}
100
101 \membersection{Substring extraction}
102
103 These functions allow to extract substring from this string. All of them don't
104 modify the original string and return a new string containing the extracted
105 substring.
106
107 \helpref{Mid}{wxstringmid}\\
108 \helpref{operator()}{wxstringoperatorparenth}\\
109 \helpref{Left}{wxstringleft}\\
110 \helpref{Right}{wxstringright}\\
111 \helpref{BeforeFirst}{wxstringbeforefirst}\\
112 \helpref{BeforeLast}{wxstringbeforelast}\\
113 \helpref{AfterFirst}{wxstringafterfirst}\\
114 \helpref{AfterLast}{wxstringafterlast}
115
116 \membersection{Case conversion}
117
118 The MakeXXX() variants modify the string in place, while the other functions
119 return a new string which containts the original text converted to the upper or
120 lower case and leave the original string unchanged.
121
122 \helpref{MakeUpper}{wxstringmakeupper}\\
123 \helpref{Upper}{wxstringupper}\\
124 \helpref{MakeLower}{wxstringmakelower}\\
125 \helpref{Lower}{wxstringlower}
126
127 \membersection{Searching and replacing}
128
129 These functions replace the standard {\it strchr()} and {\it strstr()}
130 functions.
131
132 \helpref{Find}{wxstringfind}\\
133 \helpref{Replace}{wxstringreplace}
134
135 \membersection{Writing values into the string}
136
137 Both formatted versions (\helpref{Printf}{wxstringprintf}) and stream-like
138 insertion operators exist (for basic types only).
139
140 \helpref{Printf}{wxstringprintf}\\
141 \helpref{PrintfV}{wxstringprintfv}\\
142 \helpref{operator \cinsert}{wxstringoperatorout}
143
144 \membersection{Memory management}
145
146 These are "advanced" functions and they will be needed quite rarily.
147 \helpref{Alloc}{wxstringalloc} and \helpref{Shrink}{wxstringshrink} are only
148 interesting for optimization purposes.
149 \helpref{GetWriteBuf}{wxstringgetwritebuf} may be very useful when working with
150 some external API which requires the caller to provide a writable buffer, but
151 extreme care should be taken when using it: before performing any other
152 operation on the string \helpref{UngetWriteBuf}{wxstringungetwritebuf} {\bf
153 must} be called!
154
155 \helpref{Alloc}{wxstringalloc}\\
156 \helpref{Shrink}{wxstringshrink}\\
157 \helpref{GetWriteBuf}{wxstringgetwritebuf}\\
158 \helpref{UngetWriteBuf}{wxstringungetwritebuf}
159
160 \membersection{Miscellaneous}
161
162 Other string functions.
163
164 \helpref{Trim}{wxstringtrim}\\
165 \helpref{Pad}{wxstringpad}\\
166 \helpref{Truncate}{wxstringtruncate}
167
168 \membersection{wxWindows 1.xx compatiblity functions}
169
170 These functiosn are deprecated, please consider using new wxWindows 2.0
171 functions instead of them (or, even better, std::string compatible variants).
172
173 \helpref{SubString}{wxstringsubstring}\\
174 \helpref{sprintf}{wxstringsprintf}\\
175 \helpref{CompareTo}{wxstringcompareto}\\
176 \helpref{Length}{wxstringlength}\\
177 \helpref{Freq}{wxstringfreq}\\
178 \helpref{LowerCase}{wxstringlowercase}\\
179 \helpref{UpperCase}{wxstringuppercase}\\
180 \helpref{Strip}{wxstringstrip}\\
181 \helpref{Index}{wxstringindex}\\
182 \helpref{Remove}{wxstringremove}\\
183 \helpref{First}{wxstringfirst}\\
184 \helpref{Last}{wxstringlast}\\
185 \helpref{Contains}{wxstringcontains}\\
186 \helpref{IsNull}{wxstringisnull}\\
187 \helpref{IsAscii}{wxstringisascii}\\
188 \helpref{IsNumber}{wxstringisnumber}\\
189 \helpref{IsWord}{wxstringisword}
190
191 \membersection{std::string compatibility functions}
192
193 The supported functions are only listed here, please see any STL reference for
194 their documentation.
195
196 \begin{verbatim}
197 // take nLen chars starting at nPos
198 wxString(const wxString& str, size_t nPos, size_t nLen);
199 // take all characters from pStart to pEnd (poor man's iterators)
200 wxString(const void *pStart, const void *pEnd);
201
202 // lib.string.capacity
203 // return the length of the string
204 size_t size() const;
205 // return the length of the string
206 size_t length() const;
207 // return the maximum size of the string
208 size_t max_size() const;
209 // resize the string, filling the space with c if c != 0
210 void resize(size_t nSize, char ch = '\0');
211 // delete the contents of the string
212 void clear();
213 // returns true if the string is empty
214 bool empty() const;
215
216 // lib.string.access
217 // return the character at position n
218 char at(size_t n) const;
219 // returns the writable character at position n
220 char& at(size_t n);
221
222 // lib.string.modifiers
223 // append a string
224 wxString& append(const wxString& str);
225 // append elements str[pos], ..., str[pos+n]
226 wxString& append(const wxString& str, size_t pos, size_t n);
227 // append first n (or all if n == npos) characters of sz
228 wxString& append(const char *sz, size_t n = npos);
229
230 // append n copies of ch
231 wxString& append(size_t n, char ch);
232
233 // same as `this_string = str'
234 wxString& assign(const wxString& str);
235 // same as ` = str[pos..pos + n]
236 wxString& assign(const wxString& str, size_t pos, size_t n);
237 // same as `= first n (or all if n == npos) characters of sz'
238 wxString& assign(const char *sz, size_t n = npos);
239 // same as `= n copies of ch'
240 wxString& assign(size_t n, char ch);
241
242 // insert another string
243 wxString& insert(size_t nPos, const wxString& str);
244 // insert n chars of str starting at nStart (in str)
245 wxString& insert(size_t nPos, const wxString& str, size_t nStart, size_t n);
246
247 // insert first n (or all if n == npos) characters of sz
248 wxString& insert(size_t nPos, const char *sz, size_t n = npos);
249 // insert n copies of ch
250 wxString& insert(size_t nPos, size_t n, char ch);
251
252 // delete characters from nStart to nStart + nLen
253 wxString& erase(size_t nStart = 0, size_t nLen = npos);
254
255 // replaces the substring of length nLen starting at nStart
256 wxString& replace(size_t nStart, size_t nLen, const char* sz);
257 // replaces the substring with nCount copies of ch
258 wxString& replace(size_t nStart, size_t nLen, size_t nCount, char ch);
259 // replaces a substring with another substring
260 wxString& replace(size_t nStart, size_t nLen,
261 const wxString& str, size_t nStart2, size_t nLen2);
262 // replaces the substring with first nCount chars of sz
263 wxString& replace(size_t nStart, size_t nLen,
264 const char* sz, size_t nCount);
265
266 // swap two strings
267 void swap(wxString& str);
268
269 // All find() functions take the nStart argument which specifies the
270 // position to start the search on, the default value is 0. All functions
271 // return npos if there were no match.
272
273 // find a substring
274 size_t find(const wxString& str, size_t nStart = 0) const;
275
276 // find first n characters of sz
277 size_t find(const char* sz, size_t nStart = 0, size_t n = npos) const;
278
279 // find the first occurence of character ch after nStart
280 size_t find(char ch, size_t nStart = 0) const;
281
282 // rfind() family is exactly like find() but works right to left
283
284 // as find, but from the end
285 size_t rfind(const wxString& str, size_t nStart = npos) const;
286
287 // as find, but from the end
288 size_t rfind(const char* sz, size_t nStart = npos,
289 size_t n = npos) const;
290 // as find, but from the end
291 size_t rfind(char ch, size_t nStart = npos) const;
292
293 // find first/last occurence of any character in the set
294
295 //
296 size_t find_first_of(const wxString& str, size_t nStart = 0) const;
297 //
298 size_t find_first_of(const char* sz, size_t nStart = 0) const;
299 // same as find(char, size_t)
300 size_t find_first_of(char c, size_t nStart = 0) const;
301 //
302 size_t find_last_of (const wxString& str, size_t nStart = npos) const;
303 //
304 size_t find_last_of (const char* s, size_t nStart = npos) const;
305 // same as rfind(char, size_t)
306 size_t find_last_of (char c, size_t nStart = npos) const;
307
308 // find first/last occurence of any character not in the set
309
310 //
311 size_t find_first_not_of(const wxString& str, size_t nStart = 0) const;
312 //
313 size_t find_first_not_of(const char* s, size_t nStart = 0) const;
314 //
315 size_t find_first_not_of(char ch, size_t nStart = 0) const;
316 //
317 size_t find_last_not_of(const wxString& str, size_t nStart=npos) const;
318 //
319 size_t find_last_not_of(const char* s, size_t nStart = npos) const;
320 //
321 size_t find_last_not_of(char ch, size_t nStart = npos) const;
322
323 // All compare functions return a negative, zero or positive value
324 // if the [sub]string is less, equal or greater than the compare() argument.
325
326 // just like strcmp()
327 int compare(const wxString& str) const;
328 // comparison with a substring
329 int compare(size_t nStart, size_t nLen, const wxString& str) const;
330 // comparison of 2 substrings
331 int compare(size_t nStart, size_t nLen,
332 const wxString& str, size_t nStart2, size_t nLen2) const;
333 // just like strcmp()
334 int compare(const char* sz) const;
335 // substring comparison with first nCount characters of sz
336 int compare(size_t nStart, size_t nLen,
337 const char* sz, size_t nCount = npos) const;
338
339 // substring extraction
340 wxString substr(size_t nStart = 0, size_t nLen = npos) const;
341 \end{verbatim}
342
343 %%%%% MEMBERS HERE %%%%%
344 \helponly{\insertatlevel{2}{
345
346 \wxheading{Members}
347
348 }}
349
350 \membersection{wxString::wxString}\label{wxstringconstruct}
351
352 \func{}{wxString}{\void}
353
354 Default constructor.
355
356 \func{}{wxString}{\param{const wxString\&}{ x}}
357
358 Copy constructor.
359
360 \func{}{wxString}{\param{char}{ ch}, \param{size\_t}{ n = 1}}
361
362 Constructs a string of {\it n} copies of character {\it ch}.
363
364 \func{}{wxString}{\param{const char*}{ psz}, \param{size\_t}{ nLength = wxSTRING\_MAXLEN}}
365
366 Takes first {\it nLength} characters from the C string {\it psz}.
367 The default value of wxSTRING\_MAXLEN means take all the string.
368
369 \func{}{wxString}{\param{const unsigned char*}{ psz}, \param{size\_t}{ nLength = wxSTRING\_MAXLEN}}
370
371 For compilers using unsigned char: takes first {\it nLength} characters from the C string {\it psz}.
372 The default value of wxSTRING\_MAXLEN means take all the string.
373
374 \func{}{wxString}{\param{const wchar\_t*}{ psz}}
375
376 Constructs a string from the wide (UNICODE) string.
377
378 \membersection{wxString::\destruct{wxString}}\label{wxstringdestruct}
379
380 \func{}{\destruct{wxString}}{\void}
381
382 String destructor. Note that this is not virtual, so wxString must not be inherited from.
383
384 \membersection{wxString::Alloc}\label{wxstringalloc}
385
386 \func{void}{Alloc}{\param{size\_t}{ nLen}}
387
388 Preallocate enough space for wxString to store {\it nLen} characters. This function
389 may be used to increase speed when the string is constructed by repeated
390 concatenation as in
391
392 \begin{verbatim}
393
394 // delete all vowels from the string
395 wxString DeleteAllVowels(const wxString& original)
396 {
397 wxString result;
398
399 size_t len = original.length();
400
401 result.Alloc(len);
402
403 for ( size_t n = 0; n < len; n++ )
404 {
405 if ( strchr("aeuio", tolower(original[n])) == NULL )
406 result += original[n];
407 }
408
409 return result;
410 }
411
412 \end{verbatim}
413
414 because it will avoid the need of reallocating string memory many times (in case
415 of long strings). Note that it does not set the maximal length of a string - it
416 will still expand if more than {\it nLen} characters are stored in it. Also, it
417 does not truncate the existing string (use
418 \helpref{Truncate()}{wxstringtruncate} for this) even if its current length is
419 greater than {\it nLen}
420
421 \membersection{wxString::Append}\label{wxstringappend}
422
423 \func{wxString\&}{Append}{\param{const char*}{ psz}}
424
425 Concatenates {\it psz} to this string, returning a reference to it.
426
427 \func{wxString\&}{Append}{\param{char}{ ch}, \param{int}{ count = 1}}
428
429 Concatenates character {\it ch} to this string, {\it count} times, returning a reference
430 to it.
431
432 \membersection{wxString::AfterFirst}\label{wxstringafterfirst}
433
434 \constfunc{wxString}{AfterFirst}{\param{char}{ ch}}
435
436 Gets all the characters after the first occurence of {\it ch}.
437 Returns the empty string if {\it ch} is not found.
438
439 \membersection{wxString::AfterLast}\label{wxstringafterlast}
440
441 \constfunc{wxString}{AfterLast}{\param{char}{ ch}}
442
443 Gets all the characters after the last occurence of {\it ch}.
444 Returns the whole string if {\it ch} is not found.
445
446 \membersection{wxString::BeforeFirst}\label{wxstringbeforefirst}
447
448 \constfunc{wxString}{BeforeFirst}{\param{char}{ ch}}
449
450 Gets all characters before the first occurence of {\it ch}.
451 Returns the whole string if {\it ch} is not found.
452
453 \membersection{wxString::BeforeLast}\label{wxstringbeforelast}
454
455 \constfunc{wxString}{BeforeLast}{\param{char}{ ch}}
456
457 Gets all characters before the last occurence of {\it ch}.
458 Returns the empty string if {\it ch} is not found.
459
460 \membersection{wxString::Cmp}\label{wxstringcmp}
461
462 \constfunc{int}{Cmp}{\param{const char*}{ psz}}
463
464 Case-sensitive comparison.
465
466 Returns a positive value if the string is greater than the argument, zero if
467 it si equal to it or negative value if it is less than argument (same semantics
468 as the standard {\it strcmp()} function).
469
470 See also \helpref{CmpNoCase}{wxstringcmpnocase}, \helpref{IsSameAs}{wxstringissameas}.
471
472 \membersection{wxString::CmpNoCase}\label{wxstringcmpnocase}
473
474 \constfunc{int}{CmpNoCase}{\param{const char*}{ psz}}
475
476 Case-insensitive comparison.
477
478 Returns a positive value if the string is greater than the argument, zero if
479 it si equal to it or negative value if it is less than argument (same semantics
480 as the standard {\it strcmp()} function).
481
482 See also \helpref{Cmp}{wxstringcmp}, \helpref{IsSameAs}{wxstringissameas}.
483
484 \membersection{wxString::CompareTo}\label{wxstringcompareto}
485
486 \begin{verbatim}
487 #define NO_POS ((int)(-1)) // undefined position
488 enum caseCompare {exact, ignoreCase};
489 \end{verbatim}
490
491 \constfunc{int}{CompareTo}{\param{const char*}{ psz}, \param{caseCompare}{ cmp = exact}}
492
493 Case-sensitive comparison. Returns 0 if equal, 1 if greater or -1 if less.
494
495 \membersection{wxString::Contains}\label{wxstringcontains}
496
497 \constfunc{bool}{Contains}{\param{const wxString\&}{ str}}
498
499 Returns 1 if target appears anyhere in wxString; else 0.
500
501 \membersection{wxString::Empty}\label{wxstringempty}
502
503 \func{void}{Empty}{\void}
504
505 Reinitializes the string and frees the data.
506
507 \membersection{wxString::Find}\label{wxstringfind}
508
509 \constfunc{int}{Find}{\param{char}{ ch}, \param{bool}{ fromEnd = FALSE}}
510
511 Searches for the given character. Returns the starting index, or -1 if not found.
512
513 \constfunc{int}{Find}{\param{const char*}{ sz}}
514
515 Searches for the given string. Returns the starting index, or -1 if not found.
516
517 \membersection{wxString::First}\label{wxstringfirst}
518
519 \func{size\_t}{First}{\param{char}{ c}}
520
521 \constfunc{size\_t}{First}{\param{const char*}{ psz}}
522
523 \constfunc{size\_t}{First}{\param{const wxString\&}{ str}}
524
525 \constfunc{size\_t}{First}{\param{const char}{ ch}}
526
527 Returns the first occurrence of the item.
528
529 \membersection{wxString::Freq}\label{wxstringfreq}
530
531 \constfunc{int}{Frec}{\param{char }{ch}}
532
533 Returns the number of occurences of {it ch} in the string.
534
535 \membersection{wxString::GetChar}\label{wxstringgetchar}
536
537 \constfunc{char}{GetChar}{\param{size\_t}{ n}}
538
539 Returns the character at position {\it n} (read-only).
540
541 \membersection{wxString::GetData}\label{wxstringgetdata}
542
543 \constfunc{const char*}{GetData}{\void}
544
545 wxWindows compatibility conversion. Returns a constant pointer to the data in the string.
546
547 \membersection{wxString::GetWritableChar}\label{wxstringgetwritablechar}
548
549 \func{char\&}{GetWritableChar}{\param{size\_t}{ n}}
550
551 Returns a reference to the character at position {\it n}.
552
553 \membersection{wxString::GetWriteBuf}\label{wxstringgetwritebuf}
554
555 \func{char*}{GetWriteBuf}{\param{size\_t}{ len}}
556
557 Returns a writable buffer of at least {\it len} bytes.
558
559 Call \helpref{wxString::UngetWriteBuf}{wxstringungetwritebuf} as soon as possible
560 to put the string back into a reasonable state.
561
562 \membersection{wxString::Index}\label{wxstringindex}
563
564 \constfunc{size\_t}{Index}{\param{char}{ ch}, \param{int}{ startpos = 0}}
565
566 Same as \helpref{wxString::Find}{wxstringfind}.
567
568 \constfunc{size\_t}{Index}{\param{const char*}{ sz}}
569
570 Same as \helpref{wxString::Find}{wxstringfind}.
571
572 \constfunc{size\_t}{Index}{\param{const char*}{ sz}, \param{bool}{ caseSensitive = TRUE}, \param{bool}{ fromEnd = FALSE}}
573
574 Search the element in the array, starting from either side.
575
576 If {\it fromEnd} is TRUE, reverse search direction.
577
578 If {\bf caseSensitive}, comparison is case sensitive (the default).
579
580 Returns the index of the first item matched, or NOT\_FOUND.
581
582 % TODO
583 %\membersection{wxString::insert}\label{wxstringinsert}
584 % Wrong!
585 %\func{void}{insert}{\param{const wxString\&}{ str}, \param{size\_t}{ index}}
586 %
587 %Add new element at the given position.
588 %
589 \membersection{wxString::IsAscii}\label{wxstringisascii}
590
591 \constfunc{bool}{IsAscii}{\void}
592
593 Returns TRUE if the string is ASCII.
594
595 \membersection{wxString::IsEmpty}\label{wxstringisempty}
596
597 \constfunc{bool}{IsEmpty}{\void}
598
599 Returns TRUE if the string is NULL.
600
601 \membersection{wxString::IsNull}\label{wxstringisnull}
602
603 \constfunc{bool}{IsNull}{\void}
604
605 Returns TRUE if the string is NULL (same as IsEmpty).
606
607 \membersection{wxString::IsNumber}\label{wxstringisnumber}
608
609 \constfunc{bool}{IsNumber}{\void}
610
611 Returns TRUE if the string is a number.
612
613 \membersection{wxString::IsSameAs}\label{wxstringissameas}
614
615 \constfunc{bool}{IsSameAs}{\param{const char*}{ psz}, \param{bool}{ caseSensitive = TRUE}}
616
617 Test for string equality, case-sensitive (default) or not.
618
619 caseSensitive is TRUE by default (case matters).
620
621 Returns TRUE if strings are equal, FALSE otherwise.
622
623 See also \helpref{Cmp}{wxstringcmp}, \helpref{CmpNoCase}{wxstringcmpnocase}.
624
625 \membersection{wxString::IsWord}\label{wxstringisword}
626
627 \constfunc{bool}{IsWord}{\void}
628
629 Returns TRUE if the string is a word. TODO: what's the definition of a word?
630
631 \membersection{wxString::Last}\label{wxstringlast}
632
633 \constfunc{char}{Last}{\void}
634
635 Returns the last character.
636
637 \func{char\&}{Last}{\void}
638
639 Returns a reference to the last character (writable).
640
641 \membersection{wxString::Left}\label{wxstringleft}
642
643 \constfunc{wxString}{Left}{\param{size\_t}{ count}}
644
645 Returns the first {\it count} characters.
646
647 \constfunc{wxString}{Left}{\param{char}{ ch}}
648
649 Returns all characters before the first occurence of {\it ch}.
650 Returns the whole string if {\it ch} is not found.
651
652 \membersection{wxString::Len}\label{wxstringlen}
653
654 \constfunc{size\_t}{Len}{\void}
655
656 Returns the length of the string.
657
658 \membersection{wxString::Length}\label{wxstringlength}
659
660 \constfunc{size\_t}{Length}{\void}
661
662 Returns the length of the string (same as Len).
663
664 \membersection{wxString::Lower}\label{wxstringlower}
665
666 \constfunc{wxString}{Lower}{\void}
667
668 Returns this string converted to the lower case.
669
670 \membersection{wxString::LowerCase}\label{wxstringlowercase}
671
672 \func{void}{LowerCase}{\void}
673
674 Same as MakeLower.
675
676 \membersection{wxString::MakeLower}\label{wxstringmakelower}
677
678 \func{void}{MakeLower}{\void}
679
680 Converts all characters to lower case.
681
682 \membersection{wxString::MakeUpper}\label{wxstringmakeupper}
683
684 \func{void}{MakeUpper}{\void}
685
686 Converts all characters to upper case.
687
688 \membersection{wxString::Matches}\label{wxstringmatches}
689
690 \constfunc{bool}{Matches}{\param{const char*}{ szMask}}
691
692 Returns TRUE if the string contents matches a mask containing '*' and '?'.
693
694 \membersection{wxString::Mid}\label{wxstringmid}
695
696 \constfunc{wxString}{Mid}{\param{size\_t}{ first}, \param{size\_t}{ count = wxSTRING\_MAXLEN}}
697
698 Returns a substring starting at {\it first}, with length {\it count}, or the rest of
699 the string if {\it count} is the default value.
700
701 \membersection{wxString::Pad}\label{wxstringpad}
702
703 \func{wxString\&}{Pad}{\param{size\_t}{ count}, \param{char}{ pad = ' '}, \param{bool}{ fromRight = TRUE}}
704
705 Adds {\it count} copies of {\it pad} to the beginning, or to the end of the string (the default).
706
707 Removes spaces from the left or from the right (default).
708
709 \membersection{wxString::Prepend}\label{wxstringprepend}
710
711 \func{wxString\&}{Prepend}{\param{const wxString\&}{ str}}
712
713 Prepends {\it str} to this string, returning a reference to this string.
714
715 \membersection{wxString::Printf}\label{wxstringprintf}
716
717 \func{int}{Printf}{\param{const char* }{pszFormat}, \param{}{...}}
718
719 Similar to the standard function {\it sprintf()}. Returns the number of
720 characters written, or an integer less than zero on error.
721
722 {\bf NB:} This function will use a safe version of {\it vsprintf()} (usually called
723 {\it vsnprintf()}) whenever available to always allocate the buffer of correct
724 size. Unfortunately, this function is not available on all platforms and the
725 dangerous {\it vsprintf()} will be used then which may lead to buffer overflows.
726
727 \membersection{wxString::PrintfV}\label{wxstringprintfv}
728
729 \func{int}{PrintfV}{\param{const char* }{pszFormat}, \param{va\_list}{ argPtr}}
730
731 Similar to vprintf. Returns the number of characters written, or an integer less than zero
732 on error.
733
734 \membersection{wxString::Remove}\label{wxstringremove}
735
736 \func{wxString\&}{Remove}{\param{size\_t}{ pos}}
737
738 Same as Truncate. Removes the portion from {\it pos} to the end of the string.
739
740 \func{wxString\&}{Remove}{\param{size\_t}{ pos}, \param{size\_t}{ len}}
741
742 Removes the last {\it len} characters from the string, starting at {\it pos}.
743
744 \membersection{wxString::RemoveLast}\label{wxstringremovelast}
745
746 \func{wxString\&}{RemoveLast}{\void}
747
748 Removes the last character.
749
750 \membersection{wxString::Replace}\label{wxstringreplace}
751
752 \func{size\_t}{Replace}{\param{const char*}{ szOld}, \param{const char*}{ szNew}, \param{bool}{ replaceAll = TRUE}}
753
754 Replace first (or all) occurences of substring with another one.
755
756 {\it replaceAll}: global replace (default), or only the first occurence.
757
758 Returns the number of replacements made.
759
760 \membersection{wxString::Right}\label{wxstringright}
761
762 \constfunc{wxString}{Right}{\param{size\_t}{ count}}
763
764 Returns the last {\it count} characters.
765
766 \constfunc{wxString}{Right}{\param{char}{ ch}}
767
768 Returns all characters after the last occurence of {\it ch}.
769 Returns the whole string if {\it ch} is not found.
770
771 \membersection{wxString::SetChar}\label{wxstringsetchar}
772
773 \func{void}{SetChar}{\param{size\_t}{ n}, \param{char}{ch}}
774
775 Sets the character at position {\it n}.
776
777 \membersection{wxString::Shrink}\label{wxstringshrink}
778
779 \func{void}{Shrink}{\void}
780
781 Minimizes the string's memory. This can be useful after a call to
782 \helpref{Alloc()}{wxstringalloc} if too much memory were preallocated.
783
784 \membersection{wxString::sprintf}\label{wxstringsprintf}
785
786 \func{void}{sprintf}{\param{const char* }{ fmt}}
787
788 The same as Printf.
789
790 \membersection{wxString::Strip}\label{wxstringstrip}
791
792 \begin{verbatim}
793 enum stripType {leading = 0x1, trailing = 0x2, both = 0x3};
794 \end{verbatim}
795
796 \constfunc{wxString}{Strip}{\param{stripType}{ s = trailing}}
797
798 Strip characters at the front and/or end. The same as Trim except that it
799 doesn't change this string.
800
801 \membersection{wxString::SubString}\label{wxstringsubstring}
802
803 \constfunc{wxString}{SubString}{\param{size\_t}{ to}, \param{size\_t}{ from}}
804
805 Same as \helpref{Mid}{wxstringmid}.
806
807 \membersection{wxString::Trim}\label{wxstringtrim}
808
809 \func{wxString\&}{Trim}{\param{bool}{ fromRight = TRUE}}
810
811 Removes spaces from the left or from the right (default).
812
813 \membersection{wxString::Truncate}\label{wxstringtruncate}
814
815 \func{wxString\&}{Truncate}{\param{size\_t}{ len}}
816
817 Truncate the string to the given length.
818
819 \membersection{wxString::UngetWriteBuf}\label{wxstringungetwritebuf}
820
821 \func{void}{UngetWriteBuf}{\void}
822
823 Puts the string back into a reasonable state, after
824 \rtfsp\helpref{wxString::GetWriteBuf}{wxstringgetwritebuf} was called.
825
826 \membersection{wxString::Upper}\label{wxstringupper}
827
828 \constfunc{wxString}{Upper}{\void}
829
830 Returns this string converted to upper case.
831
832 \membersection{wxString::UpperCase}\label{wxstringuppercase}
833
834 \func{void}{UpperCase}{\void}
835
836 The same as MakeUpper.
837
838 \membersection{wxString::operator!}\label{wxstringoperatornot}
839
840 \constfunc{bool}{operator!}{\void}
841
842 Empty string is FALSE, so !string will only return TRUE if the string is empty.
843 This allows the tests for NULLness of a {\it const char *} pointer and emptyness
844 of the string to look the same in the code and makes it easier to port old code
845 to wxString.
846
847 See also \helpref{IsEmpty()}{wxstringisempty}.
848
849 \membersection{wxString::operator $=$}\label{wxstringoperatorassign}
850
851 \func{wxString\&}{operator $=$}{\param{const wxString\&}{ str}}
852
853 \func{wxString\&}{operator $=$}{\param{const char*}{ psz}}
854
855 \func{wxString\&}{operator $=$}{\param{char}{ c}}
856
857 \func{wxString\&}{operator $=$}{\param{const unsigned char*}{ psz}}
858
859 \func{wxString\&}{operator $=$}{\param{const wchar\_t*}{ pwz}}
860
861 Assignment: the effect of each operation is the same as for the corresponding
862 constructor (see \helpref{wxString constructors}{wxstringconstruct}).
863
864 \membersection{operator wxString::$+$}\label{wxstringoperatorplus}
865
866 Concatenation: all these operators return a new strign equal to the sum of the
867 operands.
868
869 \func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
870
871 \func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{const char*}{ y}}
872
873 \func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{char}{ y}}
874
875 \func{wxString}{operator $+$}{\param{const char*}{ x}, \param{const wxString\&}{ y}}
876
877 \membersection{wxString::operator $+=$}\label{wxstringplusequal}
878
879 \func{void}{operator $+=$}{\param{const wxString\&}{ str}}
880
881 \func{void}{operator $+=$}{\param{const char*}{ psz}}
882
883 \func{void}{operator $+=$}{\param{char}{ c}}
884
885 Concatenation in place: the argument is appended to the string.
886
887 \membersection{wxString::operator []}\label{wxstringoperatorbracket}
888
889 \func{char\&}{operator []}{\param{size\_t}{ i}}
890
891 \func{char}{operator []}{\param{size\_t}{ i}}
892
893 \func{char}{operator []}{\param{int}{ i}}
894
895 Element extraction.
896
897 \membersection{wxString::operator ()}\label{wxstringoperatorparenth}
898
899 \func{wxString}{operator ()}{\param{size\_t}{ start}, \param{size\_t}{ len}}
900
901 Same as Mid (substring extraction).
902
903 \membersection{wxString::operator \cinsert}\label{wxstringoperatorout}
904
905 \func{wxString\&}{operator \cinsert}{\param{const wxString\&}{ str}}
906
907 \func{wxString\&}{operator \cinsert}{\param{const char*}{ psz}}
908
909 \func{wxString\&}{operator \cinsert}{\param{char }{ch}}
910
911 Same as $+=$.
912
913 \func{wxString\&}{operator \cinsert}{\param{int}{ i}}
914
915 \func{wxString\&}{operator \cinsert}{\param{float}{ f}}
916
917 \func{wxString\&}{operator \cinsert}{\param{double}{ d}}
918
919 These functions work as C++ stream insertion operators: they insert the given
920 value into the string. Precision or format cannot be set using them, you can use
921 \helpref{Printf}{wxstringprintf} for this.
922
923 \membersection{wxString::operator \cextract}\label{wxstringoperatorin}
924
925 \func{friend istream\&}{operator \cextract}{\param{istream\&}{ is}, \param{wxString\&}{ str}}
926
927 Extraction from a stream.
928
929 \membersection{wxString::operator const char*}\label{wxstringoperatorconstcharpt}
930
931 \constfunc{}{operator const char*}{\void}
932
933 Implicit conversion to a C string.
934
935 \membersection{Comparison operators}\label{wxstringcomparison}
936
937 \func{bool}{operator $==$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
938
939 \func{bool}{operator $==$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
940
941 \func{bool}{operator $!=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
942
943 \func{bool}{operator $!=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
944
945 \func{bool}{operator $>$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
946
947 \func{bool}{operator $>$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
948
949 \func{bool}{operator $>=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
950
951 \func{bool}{operator $>=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
952
953 \func{bool}{operator $<$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
954
955 \func{bool}{operator $<$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
956
957 \func{bool}{operator $<=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
958
959 \func{bool}{operator $<=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
960
961 \wxheading{Remarks}
962
963 These comparisons are case-sensitive.
964