]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/wxstring.tex
Minor tweek for WXPM
[wxWidgets.git] / docs / latex / wx / wxstring.tex
CommitLineData
a660d684
KB
1\section{\class{wxString}}\label{wxstring}
2
40b480c3
JS
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.
99f09bc1
VZ
8The behaviour of all these functions is identical to the behaviour described
9there.
10
b3324be2
JS
11\wxheading{Derived from}
12
13None
a660d684 14
954b8ae6
JS
15\wxheading{Include files}
16
17<wx/string.h>
18
20e85460
JS
19\wxheading{Predefined objects}
20
21Objects:
22
23{\bf wxEmptyString}
24
b3324be2
JS
25\wxheading{See also}
26
27\overview{Overview}{wxstringoverview}
a660d684 28
99f09bc1
VZ
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
fd34e3a5 65see \helpref{overview}{wxstringadvices} for the cases where it is necessary to
99f09bc1
VZ
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
40b480c3 135These functions replace the standard {\it strchr()} and {\it strstr()}
99f09bc1
VZ
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}\\
40b480c3 148\helpref{operator \cinsert}{wxstringoperatorout}
99f09bc1
VZ
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
ed93168b 197\membersection{std::string compatibility functions}\label{wxstringat}
99f09bc1
VZ
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}}
a660d684
KB
355
356\membersection{wxString::wxString}\label{wxstringconstruct}
357
b3324be2 358\func{}{wxString}{\void}
a660d684 359
b3324be2 360Default constructor.
a660d684 361
b3324be2 362\func{}{wxString}{\param{const wxString\&}{ x}}
a660d684 363
b3324be2 364Copy constructor.
a660d684 365
b3324be2 366\func{}{wxString}{\param{char}{ ch}, \param{size\_t}{ n = 1}}
a660d684 367
b3324be2 368Constructs a string of {\it n} copies of character {\it ch}.
a660d684 369
99f09bc1 370\func{}{wxString}{\param{const char*}{ psz}, \param{size\_t}{ nLength = wxSTRING\_MAXLEN}}
a660d684 371
b3324be2 372Takes first {\it nLength} characters from the C string {\it psz}.
99f09bc1 373The default value of wxSTRING\_MAXLEN means take all the string.
a660d684 374
99f09bc1 375\func{}{wxString}{\param{const unsigned char*}{ psz}, \param{size\_t}{ nLength = wxSTRING\_MAXLEN}}
a660d684 376
b3324be2 377For compilers using unsigned char: takes first {\it nLength} characters from the C string {\it psz}.
99f09bc1 378The default value of wxSTRING\_MAXLEN means take all the string.
a660d684 379
b3324be2 380\func{}{wxString}{\param{const wchar\_t*}{ psz}}
a660d684 381
b3324be2 382Constructs a string from the wide (UNICODE) string.
a660d684 383
b3324be2 384\membersection{wxString::\destruct{wxString}}\label{wxstringdestruct}
a660d684 385
b3324be2 386\func{}{\destruct{wxString}}{\void}
a660d684 387
b3324be2 388String destructor. Note that this is not virtual, so wxString must not be inherited from.
a660d684 389
99f09bc1
VZ
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}
a660d684 399
99f09bc1
VZ
400// delete all vowels from the string
401wxString DeleteAllVowels(const wxString& original)
402{
403 wxString result;
a660d684 404
99f09bc1 405 size_t len = original.length();
a660d684 406
99f09bc1
VZ
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}
b3324be2
JS
428
429\func{wxString\&}{Append}{\param{const char*}{ psz}}
a660d684 430
b3324be2 431Concatenates {\it psz} to this string, returning a reference to it.
a660d684 432
b3324be2 433\func{wxString\&}{Append}{\param{char}{ ch}, \param{int}{ count = 1}}
a660d684 434
b3324be2
JS
435Concatenates character {\it ch} to this string, {\it count} times, returning a reference
436to it.
437
99f09bc1 438\membersection{wxString::AfterFirst}\label{wxstringafterfirst}
b3324be2 439
99f09bc1 440\constfunc{wxString}{AfterFirst}{\param{char}{ ch}}
b3324be2
JS
441
442Gets all the characters after the first occurence of {\it ch}.
443Returns the empty string if {\it ch} is not found.
a660d684 444
99f09bc1 445\membersection{wxString::AfterLast}\label{wxstringafterlast}
a660d684 446
99f09bc1
VZ
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}}
b3324be2
JS
462
463Gets all characters before the last occurence of {\it ch}.
99f09bc1 464Returns the empty string if {\it ch} is not found.
a660d684 465
ed93168b
VZ
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
f7bd2698
JS
480\membersection{wxString::Cmp}\label{wxstringcmp}
481
482\constfunc{int}{Cmp}{\param{const char*}{ psz}}
483
484Case-sensitive comparison.
485
99f09bc1
VZ
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).
f7bd2698 489
99f09bc1 490See also \helpref{CmpNoCase}{wxstringcmpnocase}, \helpref{IsSameAs}{wxstringissameas}.
f7bd2698
JS
491
492\membersection{wxString::CmpNoCase}\label{wxstringcmpnocase}
493
494\constfunc{int}{CmpNoCase}{\param{const char*}{ psz}}
495
496Case-insensitive comparison.
497
99f09bc1
VZ
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).
f7bd2698 501
99f09bc1 502See also \helpref{Cmp}{wxstringcmp}, \helpref{IsSameAs}{wxstringissameas}.
f7bd2698 503
99f09bc1 504\membersection{wxString::CompareTo}\label{wxstringcompareto}
a660d684
KB
505
506\begin{verbatim}
507#define NO_POS ((int)(-1)) // undefined position
b3324be2 508enum caseCompare {exact, ignoreCase};
a660d684 509\end{verbatim}
ed93168b 510
b3324be2 511\constfunc{int}{CompareTo}{\param{const char*}{ psz}, \param{caseCompare}{ cmp = exact}}
a660d684 512
b3324be2 513Case-sensitive comparison. Returns 0 if equal, 1 if greater or -1 if less.
a660d684 514
99f09bc1 515\membersection{wxString::Contains}\label{wxstringcontains}
a660d684 516
99f09bc1 517\constfunc{bool}{Contains}{\param{const wxString\&}{ str}}
a660d684 518
b3324be2 519Returns 1 if target appears anyhere in wxString; else 0.
a660d684 520
f7bd2698 521\membersection{wxString::Empty}\label{wxstringempty}
a660d684 522
f7bd2698
JS
523\func{void}{Empty}{\void}
524
ed93168b
VZ
525Makes the string empty, but doesn't free memory occupied by the string.
526
527See also: \helpref{Clear()}{wxstringclear}.
f7bd2698
JS
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.
a660d684 538
b3324be2 539\membersection{wxString::First}\label{wxstringfirst}
a660d684 540
b3324be2 541\func{size\_t}{First}{\param{char}{ c}}
a660d684 542
b3324be2 543\constfunc{size\_t}{First}{\param{const char*}{ psz}}
a660d684 544
b3324be2 545\constfunc{size\_t}{First}{\param{const wxString\&}{ str}}
a660d684 546
b3324be2 547\constfunc{size\_t}{First}{\param{const char}{ ch}}
a660d684 548
f7bd2698 549Returns the first occurrence of the item.
a660d684 550
99f09bc1
VZ
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
f7bd2698 557\membersection{wxString::GetChar}\label{wxstringgetchar}
a660d684 558
f7bd2698 559\constfunc{char}{GetChar}{\param{size\_t}{ n}}
a660d684 560
f7bd2698 561Returns the character at position {\it n} (read-only).
a660d684 562
99f09bc1 563\membersection{wxString::GetData}\label{wxstringgetdata}
a660d684 564
f7bd2698 565\constfunc{const char*}{GetData}{\void}
a660d684 566
f7bd2698 567wxWindows compatibility conversion. Returns a constant pointer to the data in the string.
a660d684 568
f7bd2698 569\membersection{wxString::GetWritableChar}\label{wxstringgetwritablechar}
a660d684 570
f7bd2698 571\func{char\&}{GetWritableChar}{\param{size\_t}{ n}}
a660d684 572
f7bd2698 573Returns a reference to the character at position {\it n}.
a660d684 574
f7bd2698 575\membersection{wxString::GetWriteBuf}\label{wxstringgetwritebuf}
a660d684 576
99f09bc1 577\func{char*}{GetWriteBuf}{\param{size\_t}{ len}}
a660d684 578
f7bd2698 579Returns a writable buffer of at least {\it len} bytes.
a660d684 580
f7bd2698
JS
581Call \helpref{wxString::UngetWriteBuf}{wxstringungetwritebuf} as soon as possible
582to put the string back into a reasonable state.
a660d684 583
99f09bc1 584\membersection{wxString::Index}\label{wxstringindex}
a660d684 585
f7bd2698 586\constfunc{size\_t}{Index}{\param{char}{ ch}, \param{int}{ startpos = 0}}
a660d684 587
f7bd2698 588Same as \helpref{wxString::Find}{wxstringfind}.
a660d684 589
f7bd2698 590\constfunc{size\_t}{Index}{\param{const char*}{ sz}}
a660d684 591
f7bd2698 592Same as \helpref{wxString::Find}{wxstringfind}.
a660d684 593
f7bd2698 594\constfunc{size\_t}{Index}{\param{const char*}{ sz}, \param{bool}{ caseSensitive = TRUE}, \param{bool}{ fromEnd = FALSE}}
a660d684 595
f7bd2698 596Search the element in the array, starting from either side.
a660d684 597
f7bd2698 598If {\it fromEnd} is TRUE, reverse search direction.
a660d684 599
f7bd2698 600If {\bf caseSensitive}, comparison is case sensitive (the default).
a660d684 601
f7bd2698 602Returns the index of the first item matched, or NOT\_FOUND.
a660d684 603
8a2c6ef8
JS
604% TODO
605%\membersection{wxString::insert}\label{wxstringinsert}
606% Wrong!
99f09bc1 607%\func{void}{insert}{\param{const wxString\&}{ str}, \param{size\_t}{ index}}
8a2c6ef8
JS
608%
609%Add new element at the given position.
610%
99f09bc1 611\membersection{wxString::IsAscii}\label{wxstringisascii}
a660d684 612
f7bd2698 613\constfunc{bool}{IsAscii}{\void}
a660d684 614
f7bd2698 615Returns TRUE if the string is ASCII.
a660d684 616
f7bd2698 617\membersection{wxString::IsEmpty}\label{wxstringisempty}
a660d684 618
f7bd2698 619\constfunc{bool}{IsEmpty}{\void}
a660d684 620
f7bd2698 621Returns TRUE if the string is NULL.
a660d684 622
99f09bc1 623\membersection{wxString::IsNull}\label{wxstringisnull}
a660d684 624
f7bd2698 625\constfunc{bool}{IsNull}{\void}
a660d684 626
f7bd2698 627Returns TRUE if the string is NULL (same as IsEmpty).
a660d684 628
99f09bc1 629\membersection{wxString::IsNumber}\label{wxstringisnumber}
a660d684 630
f7bd2698
JS
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).
a660d684 642
f7bd2698
JS
643Returns TRUE if strings are equal, FALSE otherwise.
644
f33fee2a
VZ
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}
a660d684 657
99f09bc1 658\membersection{wxString::IsWord}\label{wxstringisword}
a660d684 659
f7bd2698 660\constfunc{bool}{IsWord}{\void}
a660d684 661
f7bd2698 662Returns TRUE if the string is a word. TODO: what's the definition of a word?
a660d684 663
99f09bc1 664\membersection{wxString::Last}\label{wxstringlast}
a660d684 665
f7bd2698 666\constfunc{char}{Last}{\void}
a660d684 667
f7bd2698 668Returns the last character.
a660d684 669
f7bd2698 670\func{char\&}{Last}{\void}
a660d684 671
f7bd2698 672Returns a reference to the last character (writable).
a660d684 673
f7bd2698
JS
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.
a660d684 684
f7bd2698 685\membersection{wxString::Len}\label{wxstringlen}
a660d684 686
f7bd2698
JS
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).
a660d684 696
99f09bc1
VZ
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}
a660d684 704
f7bd2698
JS
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.
a660d684 720
99f09bc1 721\membersection{wxString::Matches}\label{wxstringmatches}
a660d684 722
f7bd2698
JS
723\constfunc{bool}{Matches}{\param{const char*}{ szMask}}
724
725Returns TRUE if the string contents matches a mask containing '*' and '?'.
a660d684 726
f7bd2698 727\membersection{wxString::Mid}\label{wxstringmid}
a660d684 728
99f09bc1 729\constfunc{wxString}{Mid}{\param{size\_t}{ first}, \param{size\_t}{ count = wxSTRING\_MAXLEN}}
a660d684 730
f7bd2698
JS
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).
a660d684 741
99f09bc1 742\membersection{wxString::Prepend}\label{wxstringprepend}
a660d684 743
f7bd2698 744\func{wxString\&}{Prepend}{\param{const wxString\&}{ str}}
a660d684 745
f7bd2698 746Prepends {\it str} to this string, returning a reference to this string.
a660d684 747
f7bd2698 748\membersection{wxString::Printf}\label{wxstringprintf}
a660d684 749
f7bd2698
JS
750\func{int}{Printf}{\param{const char* }{pszFormat}, \param{}{...}}
751
99f09bc1
VZ
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.
a660d684 759
f7bd2698
JS
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.
a660d684 766
99f09bc1 767\membersection{wxString::Remove}\label{wxstringremove}
a660d684 768
f7bd2698
JS
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}
a660d684 778
f7bd2698
JS
779\func{wxString\&}{RemoveLast}{\void}
780
781Removes the last character.
a660d684 782
99f09bc1 783\membersection{wxString::Replace}\label{wxstringreplace}
a660d684 784
99f09bc1 785\func{size\_t}{Replace}{\param{const char*}{ szOld}, \param{const char*}{ szNew}, \param{bool}{ replaceAll = TRUE}}
f7bd2698
JS
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}}
a660d684 796
f7bd2698 797Returns the last {\it count} characters.
a660d684 798
f7bd2698 799\membersection{wxString::SetChar}\label{wxstringsetchar}
a660d684 800
f7bd2698
JS
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
99f09bc1
VZ
809Minimizes the string's memory. This can be useful after a call to
810\helpref{Alloc()}{wxstringalloc} if too much memory were preallocated.
a660d684
KB
811
812\membersection{wxString::sprintf}\label{wxstringsprintf}
a660d684 813
f7bd2698 814\func{void}{sprintf}{\param{const char* }{ fmt}}
a660d684 815
f7bd2698 816The same as Printf.
a660d684 817
99f09bc1 818\membersection{wxString::Strip}\label{wxstringstrip}
a660d684
KB
819
820\begin{verbatim}
f7bd2698 821enum stripType {leading = 0x1, trailing = 0x2, both = 0x3};
a660d684
KB
822\end{verbatim}
823
f7bd2698 824\constfunc{wxString}{Strip}{\param{stripType}{ s = trailing}}
a660d684 825
f7bd2698
JS
826Strip characters at the front and/or end. The same as Trim except that it
827doesn't change this string.
a660d684 828
99f09bc1
VZ
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
f7bd2698 835\membersection{wxString::Trim}\label{wxstringtrim}
a660d684 836
f7bd2698 837\func{wxString\&}{Trim}{\param{bool}{ fromRight = TRUE}}
a660d684 838
f7bd2698 839Removes spaces from the left or from the right (default).
a660d684 840
f7bd2698 841\membersection{wxString::Truncate}\label{wxstringtruncate}
a660d684 842
f7bd2698 843\func{wxString\&}{Truncate}{\param{size\_t}{ len}}
a660d684 844
f7bd2698 845Truncate the string to the given length.
a660d684 846
f7bd2698
JS
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.
a660d684 853
99f09bc1
VZ
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}
a660d684 861
f7bd2698
JS
862\func{void}{UpperCase}{\void}
863
864The same as MakeUpper.
a660d684 865
99f09bc1
VZ
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
a660d684
KB
877\membersection{wxString::operator $=$}\label{wxstringoperatorassign}
878
f7bd2698
JS
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}}
a660d684 888
99f09bc1
VZ
889Assignment: the effect of each operation is the same as for the corresponding
890constructor (see \helpref{wxString constructors}{wxstringconstruct}).
5de76427
JS
891
892\membersection{operator wxString::$+$}\label{wxstringoperatorplus}
893
99f09bc1
VZ
894Concatenation: all these operators return a new strign equal to the sum of the
895operands.
5de76427
JS
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
99f09bc1 905\membersection{wxString::operator $+=$}\label{wxstringplusequal}
a660d684 906
f7bd2698
JS
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}}
a660d684 912
99f09bc1 913Concatenation in place: the argument is appended to the string.
a660d684
KB
914
915\membersection{wxString::operator []}\label{wxstringoperatorbracket}
916
f7bd2698
JS
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}}
a660d684
KB
922
923Element extraction.
924
925\membersection{wxString::operator ()}\label{wxstringoperatorparenth}
926
f7bd2698
JS
927\func{wxString}{operator ()}{\param{size\_t}{ start}, \param{size\_t}{ len}}
928
929Same as Mid (substring extraction).
a660d684
KB
930
931\membersection{wxString::operator \cinsert}\label{wxstringoperatorout}
f7bd2698 932
037267e1 933\func{wxString\&}{operator \cinsert}{\param{const wxString\&}{ str}}
f7bd2698 934
037267e1 935\func{wxString\&}{operator \cinsert}{\param{const char*}{ psz}}
f7bd2698 936
037267e1 937\func{wxString\&}{operator \cinsert}{\param{char }{ch}}
f7bd2698
JS
938
939Same as $+=$.
a660d684 940
99f09bc1
VZ
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
a660d684 951\membersection{wxString::operator \cextract}\label{wxstringoperatorin}
a660d684 952
f7bd2698 953\func{friend istream\&}{operator \cextract}{\param{istream\&}{ is}, \param{wxString\&}{ str}}
a660d684 954
f7bd2698 955Extraction from a stream.
a660d684 956
f7bd2698 957\membersection{wxString::operator const char*}\label{wxstringoperatorconstcharpt}
a660d684 958
f7bd2698 959\constfunc{}{operator const char*}{\void}
a660d684 960
f7bd2698 961Implicit conversion to a C string.
a660d684 962
99f09bc1 963\membersection{Comparison operators}\label{wxstringcomparison}
a660d684 964
f7bd2698 965\func{bool}{operator $==$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 966
f7bd2698 967\func{bool}{operator $==$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 968
f7bd2698 969\func{bool}{operator $!=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 970
f7bd2698 971\func{bool}{operator $!=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 972
f7bd2698 973\func{bool}{operator $>$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 974
f7bd2698 975\func{bool}{operator $>$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 976
f7bd2698 977\func{bool}{operator $>=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 978
f7bd2698 979\func{bool}{operator $>=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 980
f7bd2698 981\func{bool}{operator $<$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 982
f7bd2698 983\func{bool}{operator $<$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 984
f7bd2698 985\func{bool}{operator $<=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 986
f7bd2698 987\func{bool}{operator $<=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 988
f7bd2698 989\wxheading{Remarks}
a660d684 990
f7bd2698 991These comparisons are case-sensitive.
a660d684 992