]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/wxstring.tex
ODBC updates
[wxWidgets.git] / docs / latex / wx / wxstring.tex
CommitLineData
a660d684
KB
1\section{\class{wxString}}\label{wxstring}
2
b3324be2
JS
3\wxheading{Derived from}
4
5None
a660d684 6
b3324be2
JS
7\wxheading{See also}
8
9\overview{Overview}{wxstringoverview}
a660d684 10
b3324be2 11\latexignore{\rtfignore{\wxheading{Members}}}
a660d684
KB
12
13\membersection{wxString::wxString}\label{wxstringconstruct}
14
b3324be2 15\func{}{wxString}{\void}
a660d684 16
b3324be2 17Default constructor.
a660d684 18
b3324be2 19\func{}{wxString}{\param{const wxString\&}{ x}}
a660d684 20
b3324be2 21Copy constructor.
a660d684 22
b3324be2 23\func{}{wxString}{\param{char}{ ch}, \param{size\_t}{ n = 1}}
a660d684 24
b3324be2 25Constructs a string of {\it n} copies of character {\it ch}.
a660d684 26
b3324be2 27\func{}{wxString}{\param{const char*}{ psz}, \param{size\_t}{ nLength = STRING\_MAXLEN}}
a660d684 28
b3324be2
JS
29Takes first {\it nLength} characters from the C string {\it psz}.
30The default value of STRING\_MAXLEN means take all the string.
a660d684 31
b3324be2 32\func{}{wxString}{\param{const unsigned char*}{ psz}, \param{size\_t}{ nLength = STRING\_MAXLEN}}
a660d684 33
b3324be2
JS
34For compilers using unsigned char: takes first {\it nLength} characters from the C string {\it psz}.
35The default value of STRING\_MAXLEN means take all the string.
a660d684 36
b3324be2 37\func{}{wxString}{\param{const wchar\_t*}{ psz}}
a660d684 38
b3324be2 39Constructs a string from the wide (UNICODE) string.
a660d684 40
b3324be2 41\membersection{wxString::\destruct{wxString}}\label{wxstringdestruct}
a660d684 42
b3324be2 43\func{}{\destruct{wxString}}{\void}
a660d684 44
b3324be2 45String destructor. Note that this is not virtual, so wxString must not be inherited from.
a660d684 46
b3324be2 47\membersection{wxString::Alloc}\label{wxstringAlloc}
a660d684 48
b3324be2 49\func{void}{Alloc}{\param{uint}{ newsize}}
a660d684 50
b3324be2 51Preallocate some space for wxString. Only works if the data of this string is not shared.
a660d684 52
b3324be2
JS
53\membersection{wxString::Append}\label{wxstringAppend}
54
55\func{wxString\&}{Append}{\param{const char*}{ psz}}
a660d684 56
b3324be2 57Concatenates {\it psz} to this string, returning a reference to it.
a660d684 58
b3324be2 59\func{wxString\&}{Append}{\param{char}{ ch}, \param{int}{ count = 1}}
a660d684 60
b3324be2
JS
61Concatenates character {\it ch} to this string, {\it count} times, returning a reference
62to it.
63
64\membersection{wxString::After}\label{wxstringAfter}
65
66\constfunc{wxString}{After}{\param{char}{ ch}}
67
68Gets all the characters after the first occurence of {\it ch}.
69Returns the empty string if {\it ch} is not found.
a660d684
KB
70
71\membersection{wxString::Before}\label{wxstringBefore}
72
b3324be2
JS
73\constfunc{wxString}{Before}{\param{char}{ ch}}
74
75Gets all characters before the last occurence of {\it ch}.
76Returns empty string if {\it ch} is not found.
a660d684 77
f7bd2698
JS
78\membersection{wxString::Cmp}\label{wxstringcmp}
79
80\constfunc{int}{Cmp}{\param{const char*}{ psz}}
81
82Case-sensitive comparison.
83
84Returns 0 if equal, +1 if greater or -1 if less.
85
86See also CmpNoCase, IsSameAs.
87
88\membersection{wxString::CmpNoCase}\label{wxstringcmpnocase}
89
90\constfunc{int}{CmpNoCase}{\param{const char*}{ psz}}
91
92Case-insensitive comparison.
93
94Returns 0 if equal, +1 if greater or -1 if less.
95
96See also Cmp, IsSameAs.
97
a660d684
KB
98\membersection{wxString::CompareTo}\label{wxstringCompareTo}
99
100\begin{verbatim}
101#define NO_POS ((int)(-1)) // undefined position
b3324be2 102enum caseCompare {exact, ignoreCase};
a660d684
KB
103\end{verbatim}
104
b3324be2 105\constfunc{int}{CompareTo}{\param{const char*}{ psz}, \param{caseCompare}{ cmp = exact}}
a660d684 106
b3324be2 107Case-sensitive comparison. Returns 0 if equal, 1 if greater or -1 if less.
a660d684 108
b3324be2 109\membersection{wxString::Contains}\label{wxstringContains}
a660d684 110
b3324be2 111\func{bool}{Contains}{\param{const wxString\&}{ str}}
a660d684 112
b3324be2 113Returns 1 if target appears anyhere in wxString; else 0.
a660d684 114
f7bd2698 115\membersection{wxString::Empty}\label{wxstringempty}
a660d684 116
f7bd2698
JS
117\func{void}{Empty}{\void}
118
119Reinitializes the string and frees the data.
120
121\membersection{wxString::Find}\label{wxstringfind}
122
123\constfunc{int}{Find}{\param{char}{ ch}, \param{bool}{ fromEnd = FALSE}}
124
125Searches for the given character. Returns the starting index, or -1 if not found.
126
127\constfunc{int}{Find}{\param{const char*}{ sz}}
128
129Searches for the given string. Returns the starting index, or -1 if not found.
a660d684 130
b3324be2 131\membersection{wxString::First}\label{wxstringfirst}
a660d684 132
b3324be2 133\func{size\_t}{First}{\param{char}{ c}}
a660d684 134
b3324be2 135\constfunc{size\_t}{First}{\param{const char*}{ psz}}
a660d684 136
b3324be2 137\constfunc{size\_t}{First}{\param{const wxString\&}{ str}}
a660d684 138
b3324be2 139\constfunc{size\_t}{First}{\param{const char}{ ch}}
a660d684 140
f7bd2698 141Returns the first occurrence of the item.
a660d684 142
f7bd2698 143\membersection{wxString::GetChar}\label{wxstringgetchar}
a660d684 144
f7bd2698 145\constfunc{char}{GetChar}{\param{size\_t}{ n}}
a660d684 146
f7bd2698 147Returns the character at position {\it n} (read-only).
a660d684 148
f7bd2698 149\membersection{wxString::GetData}\label{wxstringGetData}
a660d684 150
f7bd2698 151\constfunc{const char*}{GetData}{\void}
a660d684 152
f7bd2698 153wxWindows compatibility conversion. Returns a constant pointer to the data in the string.
a660d684 154
f7bd2698 155\membersection{wxString::GetWritableChar}\label{wxstringgetwritablechar}
a660d684 156
f7bd2698 157\func{char\&}{GetWritableChar}{\param{size\_t}{ n}}
a660d684 158
f7bd2698 159Returns a reference to the character at position {\it n}.
a660d684 160
f7bd2698 161\membersection{wxString::GetWriteBuf}\label{wxstringgetwritebuf}
a660d684 162
f7bd2698 163\func{char*}{GetWriteBuf}{\param{uint}{ len}}
a660d684 164
f7bd2698 165Returns a writable buffer of at least {\it len} bytes.
a660d684 166
f7bd2698
JS
167Call \helpref{wxString::UngetWriteBuf}{wxstringungetwritebuf} as soon as possible
168to put the string back into a reasonable state.
a660d684 169
f7bd2698 170\membersection{wxString::Index}\label{wxstringIndex}
a660d684 171
f7bd2698 172\constfunc{size\_t}{Index}{\param{char}{ ch}, \param{int}{ startpos = 0}}
a660d684 173
f7bd2698 174Same as \helpref{wxString::Find}{wxstringfind}.
a660d684 175
f7bd2698 176\constfunc{size\_t}{Index}{\param{const char*}{ sz}}
a660d684 177
f7bd2698 178Same as \helpref{wxString::Find}{wxstringfind}.
a660d684 179
f7bd2698 180\constfunc{size\_t}{Index}{\param{const char*}{ sz}, \param{bool}{ caseSensitive = TRUE}, \param{bool}{ fromEnd = FALSE}}
a660d684 181
f7bd2698 182Search the element in the array, starting from either side.
a660d684 183
f7bd2698 184If {\it fromEnd} is TRUE, reverse search direction.
a660d684 185
f7bd2698 186If {\bf caseSensitive}, comparison is case sensitive (the default).
a660d684 187
f7bd2698 188Returns the index of the first item matched, or NOT\_FOUND.
a660d684 189
8a2c6ef8
JS
190% TODO
191%\membersection{wxString::insert}\label{wxstringinsert}
192% Wrong!
193%\func{void}{insert}{\param{const wxString\&}{ str}, \param{uint}{ index}}
194%
195%Add new element at the given position.
196%
a660d684
KB
197\membersection{wxString::IsAscii}\label{wxstringIsAscii}
198
f7bd2698 199\constfunc{bool}{IsAscii}{\void}
a660d684 200
f7bd2698 201Returns TRUE if the string is ASCII.
a660d684 202
f7bd2698 203\membersection{wxString::IsEmpty}\label{wxstringisempty}
a660d684 204
f7bd2698 205\constfunc{bool}{IsEmpty}{\void}
a660d684 206
f7bd2698 207Returns TRUE if the string is NULL.
a660d684
KB
208
209\membersection{wxString::IsNull}\label{wxstringIsNull}
210
f7bd2698 211\constfunc{bool}{IsNull}{\void}
a660d684 212
f7bd2698 213Returns TRUE if the string is NULL (same as IsEmpty).
a660d684
KB
214
215\membersection{wxString::IsNumber}\label{wxstringIsNumber}
216
f7bd2698
JS
217\constfunc{bool}{IsNumber}{\void}
218
219Returns TRUE if the string is a number.
220
221\membersection{wxString::IsSameAs}\label{wxstringissameas}
222
223\constfunc{bool}{IsSameAs}{\param{const char*}{ psz}, \param{bool}{ caseSensitive = TRUE}}
224
225Test for string equality, case-sensitive (default) or not.
226
227caseSensitive is TRUE by default (case matters).
a660d684 228
f7bd2698
JS
229Returns TRUE if strings are equal, FALSE otherwise.
230
231See also Cmp, CmpNoCase.
a660d684
KB
232
233\membersection{wxString::IsWord}\label{wxstringIsWord}
234
f7bd2698 235\constfunc{bool}{IsWord}{\void}
a660d684 236
f7bd2698 237Returns TRUE if the string is a word. TODO: what's the definition of a word?
a660d684
KB
238
239\membersection{wxString::Last}\label{wxstringLast}
240
f7bd2698 241\constfunc{char}{Last}{\void}
a660d684 242
f7bd2698 243Returns the last character.
a660d684 244
f7bd2698 245\func{char\&}{Last}{\void}
a660d684 246
f7bd2698 247Returns a reference to the last character (writable).
a660d684 248
f7bd2698
JS
249\membersection{wxString::Left}\label{wxstringleft}
250
251\constfunc{wxString}{Left}{\param{size\_t}{ count}}
252
253Returns the first {\it count} characters.
254
255\constfunc{wxString}{Left}{\param{char}{ ch}}
256
257Returns all characters before the first occurence of {\it ch}.
258Returns the whole string if {\it ch} is not found.
a660d684 259
f7bd2698 260\membersection{wxString::Len}\label{wxstringlen}
a660d684 261
f7bd2698
JS
262\constfunc{size\_t}{Len}{\void}
263
264Returns the length of the string.
265
266\membersection{wxString::Length}\label{wxstringlength}
267
268\constfunc{size\_t}{Length}{\void}
269
270Returns the length of the string (same as Len).
a660d684
KB
271
272\membersection{wxString::LowerCase}\label{wxstringLowerCase}
273
f7bd2698
JS
274\func{void}{LowerCase}{\void}
275
276Same as MakeLower.
277
278\membersection{wxString::MakeLower}\label{wxstringmakelower}
279
280\func{void}{MakeLower}{\void}
281
282Converts all characters to lower case.
283
284\membersection{wxString::MakeUpper}\label{wxstringmakeupper}
285
286\func{void}{MakeUpper}{\void}
287
288Converts all characters to upper case.
a660d684
KB
289
290\membersection{wxString::Matches}\label{wxstringMatches}
291
f7bd2698
JS
292\constfunc{bool}{Matches}{\param{const char*}{ szMask}}
293
294Returns TRUE if the string contents matches a mask containing '*' and '?'.
a660d684 295
f7bd2698 296\membersection{wxString::Mid}\label{wxstringmid}
a660d684 297
f7bd2698 298\constfunc{wxString}{Mid}{\param{size\_t}{ first}, \param{size\_t}{ count = STRING\_MAXLEN}}
a660d684 299
f7bd2698
JS
300Returns a substring starting at {\it first}, with length {\it count}, or the rest of
301the string if {\it count} is the default value.
302
303\membersection{wxString::Pad}\label{wxstringpad}
304
305\func{wxString\&}{Pad}{\param{size\_t}{ count}, \param{char}{ pad = ' '}, \param{bool}{ fromRight = TRUE}}
306
307Adds {\it count} copies of {\it pad} to the beginning, or to the end of the string (the default).
308
309Removes spaces from the left or from the right (default).
a660d684
KB
310
311\membersection{wxString::Prepend}\label{wxstringPrepend}
312
f7bd2698 313\func{wxString\&}{Prepend}{\param{const wxString\&}{ str}}
a660d684 314
f7bd2698 315Prepends {\it str} to this string, returning a reference to this string.
a660d684 316
f7bd2698 317\membersection{wxString::Printf}\label{wxstringprintf}
a660d684 318
f7bd2698
JS
319\func{int}{Printf}{\param{const char* }{pszFormat}, \param{}{...}}
320
321Similar to sprintf. Returns the number of characters written, or an integer less than zero
322on error.
a660d684 323
f7bd2698
JS
324\membersection{wxString::PrintfV}\label{wxstringprintfv}
325
326\func{int}{PrintfV}{\param{const char* }{pszFormat}, \param{va\_list}{ argPtr}}
327
328Similar to vprintf. Returns the number of characters written, or an integer less than zero
329on error.
a660d684
KB
330
331\membersection{wxString::Remove}\label{wxstringRemove}
332
f7bd2698
JS
333\func{wxString\&}{Remove}{\param{size\_t}{ pos}}
334
335Same as Truncate. Removes the portion from {\it pos} to the end of the string.
336
337\func{wxString\&}{Remove}{\param{size\_t}{ pos}, \param{size\_t}{ len}}
338
339Removes the last {\it len} characters from the string, starting at {\it pos}.
340
341\membersection{wxString::RemoveLast}\label{wxstringremovelast}
a660d684 342
f7bd2698
JS
343\func{wxString\&}{RemoveLast}{\void}
344
345Removes the last character.
a660d684
KB
346
347\membersection{wxString::Replace}\label{wxstringReplace}
348
f7bd2698
JS
349\func{uint}{Replace}{\param{const char*}{ szOld}, \param{const char*}{ szNew}, \param{bool}{ replaceAll}}
350
351Replace first (or all) occurences of substring with another one.
352
353{\it replaceAll}: global replace (default), or only the first occurence.
354
355Returns the number of replacements made.
356
357\membersection{wxString::Right}\label{wxstringright}
358
359\constfunc{wxString}{Right}{\param{size\_t}{ count}}
a660d684 360
f7bd2698 361Returns the last {\it count} characters.
a660d684 362
f7bd2698 363\constfunc{wxString}{Right}{\param{char}{ ch}}
a660d684 364
f7bd2698
JS
365Returns all characters after the last occurence of {\it ch}.
366Returns the whole string if {\it ch} is not found.
a660d684 367
f7bd2698 368\membersection{wxString::SetChar}\label{wxstringsetchar}
a660d684 369
f7bd2698
JS
370\func{void}{SetChar}{\param{size\_t}{ n}, \param{char}{ch}}
371
372Sets the character at position {\it n}.
373
374\membersection{wxString::Shrink}\label{wxstringshrink}
375
376\func{void}{Shrink}{\void}
377
378Minimizes the string's memory. Only works if the data of this string is not shared.
a660d684
KB
379
380\membersection{wxString::sprintf}\label{wxstringsprintf}
a660d684 381
f7bd2698 382\func{void}{sprintf}{\param{const char* }{ fmt}}
a660d684 383
f7bd2698 384The same as Printf.
a660d684
KB
385
386\membersection{wxString::Strip}\label{wxstringStrip}
387
388\begin{verbatim}
f7bd2698 389enum stripType {leading = 0x1, trailing = 0x2, both = 0x3};
a660d684
KB
390\end{verbatim}
391
f7bd2698 392\constfunc{wxString}{Strip}{\param{stripType}{ s = trailing}}
a660d684 393
f7bd2698
JS
394Strip characters at the front and/or end. The same as Trim except that it
395doesn't change this string.
a660d684 396
f7bd2698 397\membersection{wxString::Trim}\label{wxstringtrim}
a660d684 398
f7bd2698 399\func{wxString\&}{Trim}{\param{bool}{ fromRight = TRUE}}
a660d684 400
f7bd2698 401Removes spaces from the left or from the right (default).
a660d684 402
f7bd2698 403\membersection{wxString::Truncate}\label{wxstringtruncate}
a660d684 404
f7bd2698 405\func{wxString\&}{Truncate}{\param{size\_t}{ len}}
a660d684 406
f7bd2698 407Truncate the string to the given length.
a660d684 408
f7bd2698
JS
409\membersection{wxString::UngetWriteBuf}\label{wxstringungetwritebuf}
410
411\func{void}{UngetWriteBuf}{\void}
412
413Puts the string back into a reasonable state, after
414\rtfsp\helpref{wxString::GetWriteBuf}{wxstringgetwritebuf} was called.
a660d684
KB
415
416\membersection{wxString::UpperCase}\label{wxstringUpperCase}
417
f7bd2698
JS
418\func{void}{UpperCase}{\void}
419
420The same as MakeUpper.
a660d684
KB
421
422\membersection{wxString::operator $=$}\label{wxstringoperatorassign}
423
f7bd2698
JS
424\func{wxString\&}{operator $=$}{\param{const wxString\&}{ str}}
425
426\func{wxString\&}{operator $=$}{\param{const char*}{ psz}}
427
428\func{wxString\&}{operator $=$}{\param{char}{ c}}
429
430\func{wxString\&}{operator $=$}{\param{const unsigned char*}{ psz}}
431
432\func{wxString\&}{operator $=$}{\param{const wchar\_t*}{ pwz}}
a660d684
KB
433
434Assignment.
5de76427
JS
435
436\membersection{operator wxString::$+$}\label{wxstringoperatorplus}
437
438Concatenation.
439
440\func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
441
442\func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{const char*}{ y}}
443
444\func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{char}{ y}}
445
446\func{wxString}{operator $+$}{\param{const char*}{ x}, \param{const wxString\&}{ y}}
447
a660d684
KB
448\membersection{wxString::operator $+=$}\label{wxstringPlusEqual}
449
f7bd2698
JS
450\func{void}{operator $+=$}{\param{const wxString\&}{ str}}
451
452\func{void}{operator $+=$}{\param{const char*}{ psz}}
453
454\func{void}{operator $+=$}{\param{char}{ c}}
a660d684
KB
455
456Concatenation.
457
458\membersection{wxString::operator []}\label{wxstringoperatorbracket}
459
f7bd2698
JS
460\func{char\&}{operator []}{\param{size\_t}{ i}}
461
462\func{char}{operator []}{\param{size\_t}{ i}}
463
464\func{char}{operator []}{\param{int}{ i}}
a660d684
KB
465
466Element extraction.
467
468\membersection{wxString::operator ()}\label{wxstringoperatorparenth}
469
f7bd2698
JS
470\func{wxString}{operator ()}{\param{size\_t}{ start}, \param{size\_t}{ len}}
471
472Same as Mid (substring extraction).
a660d684
KB
473
474\membersection{wxString::operator \cinsert}\label{wxstringoperatorout}
f7bd2698
JS
475
476\func{wxString\&}{operator \cinsert}{\\param{const wxString\&}{ str}}
477
478\func{wxString\&}{operator \cinsert}{\\param{const char*}{ psz}}
479
480\func{wxString\&}{operator \cinsert}{\\param{char }{ch}}
481
482Same as $+=$.
a660d684
KB
483
484\membersection{wxString::operator \cextract}\label{wxstringoperatorin}
a660d684 485
f7bd2698 486\func{friend istream\&}{operator \cextract}{\param{istream\&}{ is}, \param{wxString\&}{ str}}
a660d684 487
f7bd2698 488Extraction from a stream.
a660d684 489
f7bd2698 490\membersection{wxString::operator const char*}\label{wxstringoperatorconstcharpt}
a660d684 491
f7bd2698 492\constfunc{}{operator const char*}{\void}
a660d684 493
f7bd2698 494Implicit conversion to a C string.
a660d684 495
f7bd2698 496\membersection{Comparison operators}\label{wxstringComparison}
a660d684 497
f7bd2698 498\func{bool}{operator $==$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 499
f7bd2698 500\func{bool}{operator $==$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 501
f7bd2698 502\func{bool}{operator $!=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 503
f7bd2698 504\func{bool}{operator $!=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 505
f7bd2698 506\func{bool}{operator $>$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 507
f7bd2698 508\func{bool}{operator $>$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 509
f7bd2698 510\func{bool}{operator $>=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 511
f7bd2698 512\func{bool}{operator $>=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 513
f7bd2698 514\func{bool}{operator $<$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 515
f7bd2698 516\func{bool}{operator $<$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 517
f7bd2698 518\func{bool}{operator $<=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}
a660d684 519
f7bd2698 520\func{bool}{operator $<=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}
a660d684 521
f7bd2698 522\wxheading{Remarks}
a660d684 523
f7bd2698 524These comparisons are case-sensitive.
a660d684 525
a660d684 526