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