]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/wxstring.tex
fixed bug in PS clipping (non-virtual SetClippingRegion was overloaded)
[wxWidgets.git] / docs / latex / wx / wxstring.tex
... / ...
CommitLineData
1\section{\class{wxString}}\label{wxstring}
2
3wxString is a class representing a character string. Please see the
4\helpref{wxString overview}{wxstringoverview} for more information about it. As explained
5there, wxString implements about 90\% of methods of the std::string class (iterators
6are not supported, nor all methods which use them).
7These standard functions are not documented in this manual so please see the STL documentation.
8The behaviour of all these functions is identical to the behaviour described
9there.
10
11\wxheading{Derived from}
12
13None
14
15\wxheading{Include files}
16
17<wx/string.h>
18
19\wxheading{Predefined objects}
20
21Objects:
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
33A strign may be constructed either from a C string, (some number of copies of)
34a single character or a wide (UNICODE) string. For all constructors (except the
35default which creates an empty string) there is also a corresponding assignment
36operator.
37
38\helpref{wxString}{wxstringconstruct}\\
39\helpref{operator $=$}{wxstringoperatorassign}\\
40\helpref{\destruct{wxString}}{wxstringdestruct}
41
42\membersection{String length}
43
44These functions return the string length and check whether the string is empty
45or 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
55Many functions in this section take a character index in the string. As with C
56strings and/or arrays, the indices start from $0$, so the first character of a
57string is string[$0$]. Attempt to access a character beyond the end of the
58string (which may be even $0$ if the string is empty) will provocate an assert
59failure in \helpref{debug build}{debuggingoverview}, but no checks are done in
60release builds.
61
62This section also contains both implicit and explicit conversions to C style
63strings. Although implicit conversion is quite convenient, it is advised to use
64explicit \helpref{c\_str()}{wxstringcstr} method for the sake of clarity. Also
65see \helpref{overview}{wxstringadvices} for the cases where it is necessary to
66use 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
78Anything may be concatenated (appended to) with a string. However, you can't
79append something to a C string (including literal constants), so to do this it
80should 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
90The default comparison function \helpref{Cmp}{wxstringcmp} is case-sensitive and
91so is the default version of \helpref{IsSameAs}{wxstringissameas}. For case
92insensitive comparisons you should use \helpref{CmpNoCase}{wxstringcmpnocase} or
93give a second parameter to IsSameAs. This last function is may be more
94convenient if only equality of the strings matters because it returns a boolean
95true value if the strings are the same and not 0 (which is usually FALSE in C)
96as Cmp does.
97
98\helpref{Matches}{wxstringmatches} is a poor man's regular expression matcher:
99it only understands '*' and '?' metacharacters in the sense of DOS command line
100interpreter.
101
102\helpref{Cmp}{wxstringcmp}\\
103\helpref{CmpNoCase}{wxstringcmpnocase}\\
104\helpref{IsSameAs}{wxstringissameas}\\
105\helpref{Matches}{wxstringmatches}
106
107\membersection{Substring extraction}
108
109These functions allow to extract substring from this string. All of them don't
110modify the original string and return a new string containing the extracted
111substring.
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
124The MakeXXX() variants modify the string in place, while the other functions
125return a new string which containts the original text converted to the upper or
126lower 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
135These functions replace the standard {\it strchr()} and {\it strstr()}
136functions.
137
138\helpref{Find}{wxstringfind}\\
139\helpref{Replace}{wxstringreplace}
140
141\membersection{Writing values into the string}
142
143Both formatted versions (\helpref{Printf}{wxstringprintf}) and stream-like
144insertion 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
152These are "advanced" functions and they will be needed quite rarily.
153\helpref{Alloc}{wxstringalloc} and \helpref{Shrink}{wxstringshrink} are only
154interesting for optimization purposes.
155\helpref{GetWriteBuf}{wxstringgetwritebuf} may be very useful when working with
156some external API which requires the caller to provide a writable buffer, but
157extreme care should be taken when using it: before performing any other
158operation on the string \helpref{UngetWriteBuf}{wxstringungetwritebuf} {\bf
159must} be called!
160
161\helpref{Alloc}{wxstringalloc}\\
162\helpref{Shrink}{wxstringshrink}\\
163\helpref{GetWriteBuf}{wxstringgetwritebuf}\\
164\helpref{UngetWriteBuf}{wxstringungetwritebuf}
165
166\membersection{Miscellaneous}
167
168Other string functions.
169
170\helpref{Trim}{wxstringtrim}\\
171\helpref{Pad}{wxstringpad}\\
172\helpref{Truncate}{wxstringtruncate}
173
174\membersection{wxWindows 1.xx compatiblity functions}
175
176These functiosn are deprecated, please consider using new wxWindows 2.0
177functions 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
199The supported functions are only listed here, please see any STL reference for
200their 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
360Default constructor.
361
362\func{}{wxString}{\param{const wxString\&}{ x}}
363
364Copy constructor.
365
366\func{}{wxString}{\param{char}{ ch}, \param{size\_t}{ n = 1}}
367
368Constructs 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
372Takes first {\it nLength} characters from the C string {\it psz}.
373The 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
377For compilers using unsigned char: takes first {\it nLength} characters from the C string {\it psz}.
378The default value of wxSTRING\_MAXLEN means take all the string.
379
380\func{}{wxString}{\param{const wchar\_t*}{ psz}}
381
382Constructs a string from the wide (UNICODE) string.
383
384\membersection{wxString::\destruct{wxString}}\label{wxstringdestruct}
385
386\func{}{\destruct{wxString}}{\void}
387
388String 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
394Preallocate enough space for wxString to store {\it nLen} characters. This function
395may be used to increase speed when the string is constructed by repeated
396concatenation as in
397
398\begin{verbatim}
399
400// delete all vowels from the string
401wxString 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
420because it will avoid the need of reallocating string memory many times (in case
421of long strings). Note that it does not set the maximal length of a string - it
422will still expand if more than {\it nLen} characters are stored in it. Also, it
423does not truncate the existing string (use
424\helpref{Truncate()}{wxstringtruncate} for this) even if its current length is
425greater than {\it nLen}
426
427\membersection{wxString::Append}\label{wxstringappend}
428
429\func{wxString\&}{Append}{\param{const char*}{ psz}}
430
431Concatenates {\it psz} to this string, returning a reference to it.
432
433\func{wxString\&}{Append}{\param{char}{ ch}, \param{int}{ count = 1}}
434
435Concatenates character {\it ch} to this string, {\it count} times, returning a reference
436to it.
437
438\membersection{wxString::AfterFirst}\label{wxstringafterfirst}
439
440\constfunc{wxString}{AfterFirst}{\param{char}{ ch}}
441
442Gets all the characters after the first occurence of {\it ch}.
443Returns 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
449Gets all the characters after the last occurence of {\it ch}.
450Returns 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
456Gets all characters before the first occurence of {\it ch}.
457Returns 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
463Gets all characters before the last occurence of {\it ch}.
464Returns 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
470Returns a pointer to the string data.
471
472\membersection{wxString::Clear}\label{wxstringclear}
473
474\func{void}{Clear}{\void}
475
476Empties the string and frees memory occupied by it.
477
478See also: \helpref{Empty}{wxstringempty}
479
480\membersection{wxString::Cmp}\label{wxstringcmp}
481
482\constfunc{int}{Cmp}{\param{const char*}{ psz}}
483
484Case-sensitive comparison.
485
486Returns a positive value if the string is greater than the argument, zero if
487it si equal to it or negative value if it is less than argument (same semantics
488as the standard {\it strcmp()} function).
489
490See also \helpref{CmpNoCase}{wxstringcmpnocase}, \helpref{IsSameAs}{wxstringissameas}.
491
492\membersection{wxString::CmpNoCase}\label{wxstringcmpnocase}
493
494\constfunc{int}{CmpNoCase}{\param{const char*}{ psz}}
495
496Case-insensitive comparison.
497
498Returns a positive value if the string is greater than the argument, zero if
499it si equal to it or negative value if it is less than argument (same semantics
500as the standard {\it strcmp()} function).
501
502See 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
508enum caseCompare {exact, ignoreCase};
509\end{verbatim}
510
511\constfunc{int}{CompareTo}{\param{const char*}{ psz}, \param{caseCompare}{ cmp = exact}}
512
513Case-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
519Returns 1 if target appears anyhere in wxString; else 0.
520
521\membersection{wxString::Empty}\label{wxstringempty}
522
523\func{void}{Empty}{\void}
524
525Makes the string empty, but doesn't free memory occupied by the string.
526
527See also: \helpref{Clear()}{wxstringclear}.
528
529\membersection{wxString::Find}\label{wxstringfind}
530
531\constfunc{int}{Find}{\param{char}{ ch}, \param{bool}{ fromEnd = FALSE}}
532
533Searches for the given character. Returns the starting index, or -1 if not found.
534
535\constfunc{int}{Find}{\param{const char*}{ sz}}
536
537Searches 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
549Returns the first occurrence of the item.
550
551\membersection{wxString::Freq}\label{wxstringfreq}
552
553\constfunc{int}{Frec}{\param{char }{ch}}
554
555Returns 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
561Returns the character at position {\it n} (read-only).
562
563\membersection{wxString::GetData}\label{wxstringgetdata}
564
565\constfunc{const char*}{GetData}{\void}
566
567wxWindows 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
573Returns 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
579Returns a writable buffer of at least {\it len} bytes.
580
581Call \helpref{wxString::UngetWriteBuf}{wxstringungetwritebuf} as soon as possible
582to 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
588Same as \helpref{wxString::Find}{wxstringfind}.
589
590\constfunc{size\_t}{Index}{\param{const char*}{ sz}}
591
592Same as \helpref{wxString::Find}{wxstringfind}.
593
594\constfunc{size\_t}{Index}{\param{const char*}{ sz}, \param{bool}{ caseSensitive = TRUE}, \param{bool}{ fromEnd = FALSE}}
595
596Search the element in the array, starting from either side.
597
598If {\it fromEnd} is TRUE, reverse search direction.
599
600If {\bf caseSensitive}, comparison is case sensitive (the default).
601
602Returns 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
615Returns TRUE if the string is ASCII.
616
617\membersection{wxString::IsEmpty}\label{wxstringisempty}
618
619\constfunc{bool}{IsEmpty}{\void}
620
621Returns TRUE if the string is NULL.
622
623\membersection{wxString::IsNull}\label{wxstringisnull}
624
625\constfunc{bool}{IsNull}{\void}
626
627Returns TRUE if the string is NULL (same as IsEmpty).
628
629\membersection{wxString::IsNumber}\label{wxstringisnumber}
630
631\constfunc{bool}{IsNumber}{\void}
632
633Returns 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
639Test for string equality, case-sensitive (default) or not.
640
641caseSensitive is TRUE by default (case matters).
642
643Returns TRUE if strings are equal, FALSE otherwise.
644
645See also \helpref{Cmp}{wxstringcmp}, \helpref{CmpNoCase}{wxstringcmpnocase}, \helpref{IsSameAs}{wxstringissameas2}
646
647\membersection{wxString::IsSameAs}\label{wxstringissameas2}
648
649\constfunc{bool}{IsSameAs}{\param{char}{ c}, \param{bool}{ caseSensitive = TRUE}}
650
651Test whether the string is equal to the single character {\it c}. The test is
652case-sensitive if {\it caseSensitive} is TRUE (default) or not if it is FALSE.
653
654Returns TRUE if the string is equal to the character, FALSE otherwise.
655
656See also \helpref{Cmp}{wxstringcmp}, \helpref{CmpNoCase}{wxstringcmpnocase}, \helpref{IsSameAs}{wxstringissameas}
657
658\membersection{wxString::IsWord}\label{wxstringisword}
659
660\constfunc{bool}{IsWord}{\void}
661
662Returns TRUE if the string is a word. TODO: what's the definition of a word?
663
664\membersection{wxString::Last}\label{wxstringlast}
665
666\constfunc{char}{Last}{\void}
667
668Returns the last character.
669
670\func{char\&}{Last}{\void}
671
672Returns a reference to the last character (writable).
673
674\membersection{wxString::Left}\label{wxstringleft}
675
676\constfunc{wxString}{Left}{\param{size\_t}{ count}}
677
678Returns the first {\it count} characters.
679
680\constfunc{wxString}{Left}{\param{char}{ ch}}
681
682Returns all characters before the first occurence of {\it ch}.
683Returns the whole string if {\it ch} is not found.
684
685\membersection{wxString::Len}\label{wxstringlen}
686
687\constfunc{size\_t}{Len}{\void}
688
689Returns the length of the string.
690
691\membersection{wxString::Length}\label{wxstringlength}
692
693\constfunc{size\_t}{Length}{\void}
694
695Returns the length of the string (same as Len).
696
697\membersection{wxString::Lower}\label{wxstringlower}
698
699\constfunc{wxString}{Lower}{\void}
700
701Returns this string converted to the lower case.
702
703\membersection{wxString::LowerCase}\label{wxstringlowercase}
704
705\func{void}{LowerCase}{\void}
706
707Same as MakeLower.
708
709\membersection{wxString::MakeLower}\label{wxstringmakelower}
710
711\func{void}{MakeLower}{\void}
712
713Converts all characters to lower case.
714
715\membersection{wxString::MakeUpper}\label{wxstringmakeupper}
716
717\func{void}{MakeUpper}{\void}
718
719Converts all characters to upper case.
720
721\membersection{wxString::Matches}\label{wxstringmatches}
722
723\constfunc{bool}{Matches}{\param{const char*}{ szMask}}
724
725Returns TRUE if the string contents matches a mask containing '*' and '?'.
726
727\membersection{wxString::Mid}\label{wxstringmid}
728
729\constfunc{wxString}{Mid}{\param{size\_t}{ first}, \param{size\_t}{ count = wxSTRING\_MAXLEN}}
730
731Returns a substring starting at {\it first}, with length {\it count}, or the rest of
732the string if {\it count} is the default value.
733
734\membersection{wxString::Pad}\label{wxstringpad}
735
736\func{wxString\&}{Pad}{\param{size\_t}{ count}, \param{char}{ pad = ' '}, \param{bool}{ fromRight = TRUE}}
737
738Adds {\it count} copies of {\it pad} to the beginning, or to the end of the string (the default).
739
740Removes spaces from the left or from the right (default).
741
742\membersection{wxString::Prepend}\label{wxstringprepend}
743
744\func{wxString\&}{Prepend}{\param{const wxString\&}{ str}}
745
746Prepends {\it str} to this string, returning a reference to this string.
747
748\membersection{wxString::Printf}\label{wxstringprintf}
749
750\func{int}{Printf}{\param{const char* }{pszFormat}, \param{}{...}}
751
752Similar to the standard function {\it sprintf()}. Returns the number of
753characters written, or an integer less than zero on error.
754
755{\bf NB:} This function will use a safe version of {\it vsprintf()} (usually called
756{\it vsnprintf()}) whenever available to always allocate the buffer of correct
757size. Unfortunately, this function is not available on all platforms and the
758dangerous {\it vsprintf()} will be used then which may lead to buffer overflows.
759
760\membersection{wxString::PrintfV}\label{wxstringprintfv}
761
762\func{int}{PrintfV}{\param{const char* }{pszFormat}, \param{va\_list}{ argPtr}}
763
764Similar to vprintf. Returns the number of characters written, or an integer less than zero
765on error.
766
767\membersection{wxString::Remove}\label{wxstringremove}
768
769\func{wxString\&}{Remove}{\param{size\_t}{ pos}}
770
771Same as Truncate. Removes the portion from {\it pos} to the end of the string.
772
773\func{wxString\&}{Remove}{\param{size\_t}{ pos}, \param{size\_t}{ len}}
774
775Removes the last {\it len} characters from the string, starting at {\it pos}.
776
777\membersection{wxString::RemoveLast}\label{wxstringremovelast}
778
779\func{wxString\&}{RemoveLast}{\void}
780
781Removes the last character.
782
783\membersection{wxString::Replace}\label{wxstringreplace}
784
785\func{size\_t}{Replace}{\param{const char*}{ szOld}, \param{const char*}{ szNew}, \param{bool}{ replaceAll = TRUE}}
786
787Replace first (or all) occurences of substring with another one.
788
789{\it replaceAll}: global replace (default), or only the first occurence.
790
791Returns the number of replacements made.
792
793\membersection{wxString::Right}\label{wxstringright}
794
795\constfunc{wxString}{Right}{\param{size\_t}{ count}}
796
797Returns the last {\it count} characters.
798
799\membersection{wxString::SetChar}\label{wxstringsetchar}
800
801\func{void}{SetChar}{\param{size\_t}{ n}, \param{char}{ch}}
802
803Sets the character at position {\it n}.
804
805\membersection{wxString::Shrink}\label{wxstringshrink}
806
807\func{void}{Shrink}{\void}
808
809Minimizes the string's memory. This can be useful after a call to
810\helpref{Alloc()}{wxstringalloc} if too much memory were preallocated.
811
812\membersection{wxString::sprintf}\label{wxstringsprintf}
813
814\func{void}{sprintf}{\param{const char* }{ fmt}}
815
816The same as Printf.
817
818\membersection{wxString::Strip}\label{wxstringstrip}
819
820\begin{verbatim}
821enum stripType {leading = 0x1, trailing = 0x2, both = 0x3};
822\end{verbatim}
823
824\constfunc{wxString}{Strip}{\param{stripType}{ s = trailing}}
825
826Strip characters at the front and/or end. The same as Trim except that it
827doesn't change this string.
828
829\membersection{wxString::SubString}\label{wxstringsubstring}
830
831\constfunc{wxString}{SubString}{\param{size\_t}{ to}, \param{size\_t}{ from}}
832
833Same as \helpref{Mid}{wxstringmid}.
834
835\membersection{wxString::Trim}\label{wxstringtrim}
836
837\func{wxString\&}{Trim}{\param{bool}{ fromRight = TRUE}}
838
839Removes spaces from the left or from the right (default).
840
841\membersection{wxString::Truncate}\label{wxstringtruncate}
842
843\func{wxString\&}{Truncate}{\param{size\_t}{ len}}
844
845Truncate the string to the given length.
846
847\membersection{wxString::UngetWriteBuf}\label{wxstringungetwritebuf}
848
849\func{void}{UngetWriteBuf}{\void}
850
851Puts the string back into a reasonable state, after
852\rtfsp\helpref{wxString::GetWriteBuf}{wxstringgetwritebuf} was called.
853
854\membersection{wxString::Upper}\label{wxstringupper}
855
856\constfunc{wxString}{Upper}{\void}
857
858Returns this string converted to upper case.
859
860\membersection{wxString::UpperCase}\label{wxstringuppercase}
861
862\func{void}{UpperCase}{\void}
863
864The same as MakeUpper.
865
866\membersection{wxString::operator!}\label{wxstringoperatornot}
867
868\constfunc{bool}{operator!}{\void}
869
870Empty string is FALSE, so !string will only return TRUE if the string is empty.
871This allows the tests for NULLness of a {\it const char *} pointer and emptyness
872of the string to look the same in the code and makes it easier to port old code
873to wxString.
874
875See also \helpref{IsEmpty()}{wxstringisempty}.
876
877\membersection{wxString::operator $=$}\label{wxstringoperatorassign}
878
879\func{wxString\&}{operator $=$}{\param{const wxString\&}{ str}}
880
881\func{wxString\&}{operator $=$}{\param{const char*}{ psz}}
882
883\func{wxString\&}{operator $=$}{\param{char}{ c}}
884
885\func{wxString\&}{operator $=$}{\param{const unsigned char*}{ psz}}
886
887\func{wxString\&}{operator $=$}{\param{const wchar\_t*}{ pwz}}
888
889Assignment: the effect of each operation is the same as for the corresponding
890constructor (see \helpref{wxString constructors}{wxstringconstruct}).
891
892\membersection{operator wxString::$+$}\label{wxstringoperatorplus}
893
894Concatenation: all these operators return a new strign equal to the sum of the
895operands.
896
897\func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
898
899\func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{const char*}{ y}}
900
901\func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{char}{ y}}
902
903\func{wxString}{operator $+$}{\param{const char*}{ x}, \param{const wxString\&}{ y}}
904
905\membersection{wxString::operator $+=$}\label{wxstringplusequal}
906
907\func{void}{operator $+=$}{\param{const wxString\&}{ str}}
908
909\func{void}{operator $+=$}{\param{const char*}{ psz}}
910
911\func{void}{operator $+=$}{\param{char}{ c}}
912
913Concatenation in place: the argument is appended to the string.
914
915\membersection{wxString::operator []}\label{wxstringoperatorbracket}
916
917\func{char\&}{operator []}{\param{size\_t}{ i}}
918
919\func{char}{operator []}{\param{size\_t}{ i}}
920
921\func{char}{operator []}{\param{int}{ i}}
922
923Element extraction.
924
925\membersection{wxString::operator ()}\label{wxstringoperatorparenth}
926
927\func{wxString}{operator ()}{\param{size\_t}{ start}, \param{size\_t}{ len}}
928
929Same as Mid (substring extraction).
930
931\membersection{wxString::operator \cinsert}\label{wxstringoperatorout}
932
933\func{wxString\&}{operator \cinsert}{\param{const wxString\&}{ str}}
934
935\func{wxString\&}{operator \cinsert}{\param{const char*}{ psz}}
936
937\func{wxString\&}{operator \cinsert}{\param{char }{ch}}
938
939Same as $+=$.
940
941\func{wxString\&}{operator \cinsert}{\param{int}{ i}}
942
943\func{wxString\&}{operator \cinsert}{\param{float}{ f}}
944
945\func{wxString\&}{operator \cinsert}{\param{double}{ d}}
946
947These functions work as C++ stream insertion operators: they insert the given
948value into the string. Precision or format cannot be set using them, you can use
949\helpref{Printf}{wxstringprintf} for this.
950
951\membersection{wxString::operator \cextract}\label{wxstringoperatorin}
952
953\func{friend istream\&}{operator \cextract}{\param{istream\&}{ is}, \param{wxString\&}{ str}}
954
955Extraction from a stream.
956
957\membersection{wxString::operator const char*}\label{wxstringoperatorconstcharpt}
958
959\constfunc{}{operator const char*}{\void}
960
961Implicit conversion to a C string.
962
963\membersection{Comparison operators}\label{wxstringcomparison}
964
965\func{bool}{operator $==$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
966
967\func{bool}{operator $==$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
968
969\func{bool}{operator $!=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
970
971\func{bool}{operator $!=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
972
973\func{bool}{operator $>$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
974
975\func{bool}{operator $>$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
976
977\func{bool}{operator $>=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
978
979\func{bool}{operator $>=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
980
981\func{bool}{operator $<$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
982
983\func{bool}{operator $<$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
984
985\func{bool}{operator $<=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
986
987\func{bool}{operator $<=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
988
989\wxheading{Remarks}
990
991These comparisons are case-sensitive.
992