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