]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxString}}\label{wxstring} |
2 | ||
40b480c3 JS |
3 | wxString is a class representing a character string. Please see the |
4 | \helpref{wxString overview}{wxstringoverview} for more information about it. As explained | |
5 | there, wxString implements about 90\% of methods of the std::string class (iterators | |
6 | are not supported, nor all methods which use them). | |
7 | These standard functions are not documented in this manual so please see the STL documentation. | |
99f09bc1 VZ |
8 | The behaviour of all these functions is identical to the behaviour described |
9 | there. | |
10 | ||
b3324be2 JS |
11 | \wxheading{Derived from} |
12 | ||
13 | None | |
a660d684 | 14 | |
954b8ae6 JS |
15 | \wxheading{Include files} |
16 | ||
17 | <wx/string.h> | |
18 | ||
20e85460 JS |
19 | \wxheading{Predefined objects} |
20 | ||
21 | Objects: | |
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 | ||
2edb0bde | 33 | A string may be constructed either from a C string, (some number of copies of) |
99f09bc1 VZ |
34 | a single character or a wide (UNICODE) string. For all constructors (except the |
35 | default which creates an empty string) there is also a corresponding assignment | |
36 | operator. | |
37 | ||
38 | \helpref{wxString}{wxstringconstruct}\\ | |
39 | \helpref{operator $=$}{wxstringoperatorassign}\\ | |
40 | \helpref{\destruct{wxString}}{wxstringdestruct} | |
41 | ||
42 | \membersection{String length} | |
43 | ||
44 | These functions return the string length and check whether the string is empty | |
45 | or empty it. | |
46 | ||
47 | \helpref{Len}{wxstringlen}\\ | |
48 | \helpref{IsEmpty}{wxstringisempty}\\ | |
49 | \helpref{operator!}{wxstringoperatornot}\\ | |
50 | \helpref{Empty}{wxstringempty}\\ | |
51 | \helpref{Clear}{wxstringclear} | |
52 | ||
53 | \membersection{Character access} | |
54 | ||
55 | Many functions in this section take a character index in the string. As with C | |
56 | strings and/or arrays, the indices start from $0$, so the first character of a | |
57 | string is string[$0$]. Attempt to access a character beyond the end of the | |
2edb0bde | 58 | string (which may be even $0$ if the string is empty) will provoke an assert |
99f09bc1 VZ |
59 | failure in \helpref{debug build}{debuggingoverview}, but no checks are done in |
60 | release builds. | |
61 | ||
62 | This section also contains both implicit and explicit conversions to C style | |
63 | strings. Although implicit conversion is quite convenient, it is advised to use | |
64 | explicit \helpref{c\_str()}{wxstringcstr} method for the sake of clarity. Also | |
fd34e3a5 | 65 | see \helpref{overview}{wxstringadvices} for the cases where it is necessary to |
99f09bc1 VZ |
66 | use it. |
67 | ||
68 | \helpref{GetChar}{wxstringgetchar}\\ | |
69 | \helpref{GetWritableChar}{wxstringgetwritablechar}\\ | |
70 | \helpref{SetChar}{wxstringsetchar}\\ | |
71 | \helpref{Last}{wxstringlast}\\ | |
72 | \helpref{operator []}{wxstringoperatorbracket}\\ | |
73 | \helpref{c\_str}{wxstringcstr}\\ | |
74 | \helpref{operator const char*}{wxstringoperatorconstcharpt} | |
75 | ||
76 | \membersection{Concatenation} | |
77 | ||
78 | Anything may be concatenated (appended to) with a string. However, you can't | |
79 | append something to a C string (including literal constants), so to do this it | |
80 | should be converted to a wxString first. | |
81 | ||
82 | \helpref{operator \cinsert}{wxstringoperatorout}\\ | |
83 | \helpref{operator $+=$}{wxstringplusequal}\\ | |
84 | \helpref{operator $+$}{wxstringoperatorplus}\\ | |
85 | \helpref{Append}{wxstringappend}\\ | |
86 | \helpref{Prepend}{wxstringprepend} | |
87 | ||
88 | \membersection{Comparison} | |
89 | ||
90 | The default comparison function \helpref{Cmp}{wxstringcmp} is case-sensitive and | |
91 | so is the default version of \helpref{IsSameAs}{wxstringissameas}. For case | |
92 | insensitive comparisons you should use \helpref{CmpNoCase}{wxstringcmpnocase} or | |
93 | give a second parameter to IsSameAs. This last function is may be more | |
94 | convenient if only equality of the strings matters because it returns a boolean | |
95 | true value if the strings are the same and not 0 (which is usually FALSE in C) | |
f6bcfd97 | 96 | as {\tt Cmp()} does. |
99f09bc1 VZ |
97 | |
98 | \helpref{Matches}{wxstringmatches} is a poor man's regular expression matcher: | |
99 | it only understands '*' and '?' metacharacters in the sense of DOS command line | |
100 | interpreter. | |
101 | ||
f6bcfd97 BP |
102 | \helpref{StartsWith}{wxstringstartswith} is helpful when parsing a line of |
103 | text which should start with some predefined prefix and is more efficient than | |
2edb0bde | 104 | doing direct string comparison as you would also have to precalculate the |
f6bcfd97 BP |
105 | length of the prefix then. |
106 | ||
99f09bc1 VZ |
107 | \helpref{Cmp}{wxstringcmp}\\ |
108 | \helpref{CmpNoCase}{wxstringcmpnocase}\\ | |
109 | \helpref{IsSameAs}{wxstringissameas}\\ | |
f6bcfd97 BP |
110 | \helpref{Matches}{wxstringmatches}\\ |
111 | \helpref{StartsWith}{wxstringstartswith} | |
99f09bc1 VZ |
112 | |
113 | \membersection{Substring extraction} | |
114 | ||
115 | These functions allow to extract substring from this string. All of them don't | |
116 | modify the original string and return a new string containing the extracted | |
117 | substring. | |
118 | ||
119 | \helpref{Mid}{wxstringmid}\\ | |
120 | \helpref{operator()}{wxstringoperatorparenth}\\ | |
121 | \helpref{Left}{wxstringleft}\\ | |
122 | \helpref{Right}{wxstringright}\\ | |
123 | \helpref{BeforeFirst}{wxstringbeforefirst}\\ | |
124 | \helpref{BeforeLast}{wxstringbeforelast}\\ | |
125 | \helpref{AfterFirst}{wxstringafterfirst}\\ | |
f6bcfd97 BP |
126 | \helpref{AfterLast}{wxstringafterlast}\\ |
127 | \helpref{StartsWith}{wxstringstartswith} | |
99f09bc1 VZ |
128 | |
129 | \membersection{Case conversion} | |
130 | ||
131 | The MakeXXX() variants modify the string in place, while the other functions | |
2edb0bde | 132 | return a new string which contains the original text converted to the upper or |
99f09bc1 VZ |
133 | lower case and leave the original string unchanged. |
134 | ||
135 | \helpref{MakeUpper}{wxstringmakeupper}\\ | |
136 | \helpref{Upper}{wxstringupper}\\ | |
137 | \helpref{MakeLower}{wxstringmakelower}\\ | |
138 | \helpref{Lower}{wxstringlower} | |
139 | ||
140 | \membersection{Searching and replacing} | |
141 | ||
40b480c3 | 142 | These functions replace the standard {\it strchr()} and {\it strstr()} |
99f09bc1 VZ |
143 | functions. |
144 | ||
145 | \helpref{Find}{wxstringfind}\\ | |
146 | \helpref{Replace}{wxstringreplace} | |
147 | ||
cd0b1709 VZ |
148 | \membersection{Conversion to numbers} |
149 | ||
150 | The string provides functions for conversion to signed and unsigned integer and | |
151 | floating point numbers. All three functions take a pointer to the variable to | |
152 | put the numeric value in and return TRUE if the {\bf entire} string could be | |
153 | converted to a number. | |
154 | ||
155 | \helpref{ToLong}{wxstringtolong}\\ | |
156 | \helpref{ToULong}{wxstringtoulong}\\ | |
157 | \helpref{ToDouble}{wxstringtodouble} | |
158 | ||
99f09bc1 VZ |
159 | \membersection{Writing values into the string} |
160 | ||
161 | Both formatted versions (\helpref{Printf}{wxstringprintf}) and stream-like | |
341e7d28 VZ |
162 | insertion operators exist (for basic types only). Additionally, the |
163 | \helpref{Format}{wxstringformat} function allows to use simply append | |
164 | formatted value to a string: | |
99f09bc1 | 165 | |
341e7d28 VZ |
166 | \begin{verbatim} |
167 | // the following 2 snippets are equivalent | |
168 | ||
169 | wxString s = "..."; | |
170 | s += wxString::Format("%d", n); | |
171 | ||
172 | wxString s; | |
173 | s.Printf("...%d", n); | |
174 | \end{verbatim} | |
175 | ||
176 | \helpref{Format}{wxstringformat}\\ | |
177 | \helpref{FormatV}{wxstringformatv}\\ | |
99f09bc1 VZ |
178 | \helpref{Printf}{wxstringprintf}\\ |
179 | \helpref{PrintfV}{wxstringprintfv}\\ | |
40b480c3 | 180 | \helpref{operator \cinsert}{wxstringoperatorout} |
99f09bc1 VZ |
181 | |
182 | \membersection{Memory management} | |
183 | ||
2edb0bde | 184 | These are "advanced" functions and they will be needed quite rarely. |
99f09bc1 VZ |
185 | \helpref{Alloc}{wxstringalloc} and \helpref{Shrink}{wxstringshrink} are only |
186 | interesting for optimization purposes. | |
187 | \helpref{GetWriteBuf}{wxstringgetwritebuf} may be very useful when working with | |
188 | some external API which requires the caller to provide a writable buffer, but | |
189 | extreme care should be taken when using it: before performing any other | |
190 | operation on the string \helpref{UngetWriteBuf}{wxstringungetwritebuf} {\bf | |
191 | must} be called! | |
192 | ||
193 | \helpref{Alloc}{wxstringalloc}\\ | |
194 | \helpref{Shrink}{wxstringshrink}\\ | |
195 | \helpref{GetWriteBuf}{wxstringgetwritebuf}\\ | |
196 | \helpref{UngetWriteBuf}{wxstringungetwritebuf} | |
197 | ||
198 | \membersection{Miscellaneous} | |
199 | ||
200 | Other string functions. | |
201 | ||
202 | \helpref{Trim}{wxstringtrim}\\ | |
203 | \helpref{Pad}{wxstringpad}\\ | |
204 | \helpref{Truncate}{wxstringtruncate} | |
205 | ||
f6bcfd97 | 206 | \membersection{wxWindows 1.xx compatibility functions} |
99f09bc1 | 207 | |
f6bcfd97 | 208 | These functions are deprecated, please consider using new wxWindows 2.0 |
99f09bc1 VZ |
209 | functions instead of them (or, even better, std::string compatible variants). |
210 | ||
211 | \helpref{SubString}{wxstringsubstring}\\ | |
212 | \helpref{sprintf}{wxstringsprintf}\\ | |
213 | \helpref{CompareTo}{wxstringcompareto}\\ | |
214 | \helpref{Length}{wxstringlength}\\ | |
215 | \helpref{Freq}{wxstringfreq}\\ | |
216 | \helpref{LowerCase}{wxstringlowercase}\\ | |
217 | \helpref{UpperCase}{wxstringuppercase}\\ | |
218 | \helpref{Strip}{wxstringstrip}\\ | |
219 | \helpref{Index}{wxstringindex}\\ | |
220 | \helpref{Remove}{wxstringremove}\\ | |
221 | \helpref{First}{wxstringfirst}\\ | |
222 | \helpref{Last}{wxstringlast}\\ | |
223 | \helpref{Contains}{wxstringcontains}\\ | |
224 | \helpref{IsNull}{wxstringisnull}\\ | |
225 | \helpref{IsAscii}{wxstringisascii}\\ | |
226 | \helpref{IsNumber}{wxstringisnumber}\\ | |
227 | \helpref{IsWord}{wxstringisword} | |
228 | ||
ed93168b | 229 | \membersection{std::string compatibility functions}\label{wxstringat} |
99f09bc1 VZ |
230 | |
231 | The supported functions are only listed here, please see any STL reference for | |
232 | their documentation. | |
233 | ||
234 | \begin{verbatim} | |
235 | // take nLen chars starting at nPos | |
236 | wxString(const wxString& str, size_t nPos, size_t nLen); | |
237 | // take all characters from pStart to pEnd (poor man's iterators) | |
238 | wxString(const void *pStart, const void *pEnd); | |
239 | ||
240 | // lib.string.capacity | |
241 | // return the length of the string | |
242 | size_t size() const; | |
243 | // return the length of the string | |
244 | size_t length() const; | |
245 | // return the maximum size of the string | |
246 | size_t max_size() const; | |
247 | // resize the string, filling the space with c if c != 0 | |
248 | void resize(size_t nSize, char ch = '\0'); | |
249 | // delete the contents of the string | |
250 | void clear(); | |
251 | // returns true if the string is empty | |
252 | bool empty() const; | |
253 | ||
254 | // lib.string.access | |
255 | // return the character at position n | |
256 | char at(size_t n) const; | |
257 | // returns the writable character at position n | |
258 | char& at(size_t n); | |
259 | ||
260 | // lib.string.modifiers | |
261 | // append a string | |
262 | wxString& append(const wxString& str); | |
263 | // append elements str[pos], ..., str[pos+n] | |
264 | wxString& append(const wxString& str, size_t pos, size_t n); | |
265 | // append first n (or all if n == npos) characters of sz | |
266 | wxString& append(const char *sz, size_t n = npos); | |
267 | ||
268 | // append n copies of ch | |
269 | wxString& append(size_t n, char ch); | |
270 | ||
271 | // same as `this_string = str' | |
272 | wxString& assign(const wxString& str); | |
273 | // same as ` = str[pos..pos + n] | |
274 | wxString& assign(const wxString& str, size_t pos, size_t n); | |
275 | // same as `= first n (or all if n == npos) characters of sz' | |
276 | wxString& assign(const char *sz, size_t n = npos); | |
277 | // same as `= n copies of ch' | |
278 | wxString& assign(size_t n, char ch); | |
279 | ||
280 | // insert another string | |
281 | wxString& insert(size_t nPos, const wxString& str); | |
282 | // insert n chars of str starting at nStart (in str) | |
283 | wxString& insert(size_t nPos, const wxString& str, size_t nStart, size_t n); | |
284 | ||
285 | // insert first n (or all if n == npos) characters of sz | |
286 | wxString& insert(size_t nPos, const char *sz, size_t n = npos); | |
287 | // insert n copies of ch | |
288 | wxString& insert(size_t nPos, size_t n, char ch); | |
289 | ||
290 | // delete characters from nStart to nStart + nLen | |
291 | wxString& erase(size_t nStart = 0, size_t nLen = npos); | |
292 | ||
293 | // replaces the substring of length nLen starting at nStart | |
294 | wxString& replace(size_t nStart, size_t nLen, const char* sz); | |
295 | // replaces the substring with nCount copies of ch | |
296 | wxString& replace(size_t nStart, size_t nLen, size_t nCount, char ch); | |
297 | // replaces a substring with another substring | |
298 | wxString& replace(size_t nStart, size_t nLen, | |
299 | const wxString& str, size_t nStart2, size_t nLen2); | |
300 | // replaces the substring with first nCount chars of sz | |
301 | wxString& replace(size_t nStart, size_t nLen, | |
302 | const char* sz, size_t nCount); | |
303 | ||
304 | // swap two strings | |
305 | void swap(wxString& str); | |
306 | ||
307 | // All find() functions take the nStart argument which specifies the | |
308 | // position to start the search on, the default value is 0. All functions | |
309 | // return npos if there were no match. | |
310 | ||
311 | // find a substring | |
312 | size_t find(const wxString& str, size_t nStart = 0) const; | |
313 | ||
314 | // find first n characters of sz | |
315 | size_t find(const char* sz, size_t nStart = 0, size_t n = npos) const; | |
316 | ||
7335902d | 317 | // find the first occurrence of character ch after nStart |
99f09bc1 VZ |
318 | size_t find(char ch, size_t nStart = 0) const; |
319 | ||
320 | // rfind() family is exactly like find() but works right to left | |
321 | ||
322 | // as find, but from the end | |
323 | size_t rfind(const wxString& str, size_t nStart = npos) const; | |
324 | ||
325 | // as find, but from the end | |
326 | size_t rfind(const char* sz, size_t nStart = npos, | |
327 | size_t n = npos) const; | |
328 | // as find, but from the end | |
329 | size_t rfind(char ch, size_t nStart = npos) const; | |
330 | ||
7335902d | 331 | // find first/last occurrence of any character in the set |
99f09bc1 VZ |
332 | |
333 | // | |
334 | size_t find_first_of(const wxString& str, size_t nStart = 0) const; | |
335 | // | |
336 | size_t find_first_of(const char* sz, size_t nStart = 0) const; | |
337 | // same as find(char, size_t) | |
338 | size_t find_first_of(char c, size_t nStart = 0) const; | |
339 | // | |
340 | size_t find_last_of (const wxString& str, size_t nStart = npos) const; | |
341 | // | |
342 | size_t find_last_of (const char* s, size_t nStart = npos) const; | |
343 | // same as rfind(char, size_t) | |
344 | size_t find_last_of (char c, size_t nStart = npos) const; | |
345 | ||
7335902d | 346 | // find first/last occurrence of any character not in the set |
99f09bc1 VZ |
347 | |
348 | // | |
349 | size_t find_first_not_of(const wxString& str, size_t nStart = 0) const; | |
350 | // | |
351 | size_t find_first_not_of(const char* s, size_t nStart = 0) const; | |
352 | // | |
353 | size_t find_first_not_of(char ch, size_t nStart = 0) const; | |
354 | // | |
355 | size_t find_last_not_of(const wxString& str, size_t nStart=npos) const; | |
356 | // | |
357 | size_t find_last_not_of(const char* s, size_t nStart = npos) const; | |
358 | // | |
359 | size_t find_last_not_of(char ch, size_t nStart = npos) const; | |
360 | ||
361 | // All compare functions return a negative, zero or positive value | |
362 | // if the [sub]string is less, equal or greater than the compare() argument. | |
363 | ||
364 | // just like strcmp() | |
365 | int compare(const wxString& str) const; | |
366 | // comparison with a substring | |
367 | int compare(size_t nStart, size_t nLen, const wxString& str) const; | |
368 | // comparison of 2 substrings | |
369 | int compare(size_t nStart, size_t nLen, | |
370 | const wxString& str, size_t nStart2, size_t nLen2) const; | |
371 | // just like strcmp() | |
372 | int compare(const char* sz) const; | |
373 | // substring comparison with first nCount characters of sz | |
374 | int compare(size_t nStart, size_t nLen, | |
375 | const char* sz, size_t nCount = npos) const; | |
376 | ||
377 | // substring extraction | |
378 | wxString substr(size_t nStart = 0, size_t nLen = npos) const; | |
379 | \end{verbatim} | |
380 | ||
381 | %%%%% MEMBERS HERE %%%%% | |
382 | \helponly{\insertatlevel{2}{ | |
383 | ||
384 | \wxheading{Members} | |
385 | ||
386 | }} | |
a660d684 KB |
387 | |
388 | \membersection{wxString::wxString}\label{wxstringconstruct} | |
389 | ||
b3324be2 | 390 | \func{}{wxString}{\void} |
a660d684 | 391 | |
b3324be2 | 392 | Default constructor. |
a660d684 | 393 | |
b3324be2 | 394 | \func{}{wxString}{\param{const wxString\&}{ x}} |
a660d684 | 395 | |
b3324be2 | 396 | Copy constructor. |
a660d684 | 397 | |
b3324be2 | 398 | \func{}{wxString}{\param{char}{ ch}, \param{size\_t}{ n = 1}} |
a660d684 | 399 | |
b3324be2 | 400 | Constructs a string of {\it n} copies of character {\it ch}. |
a660d684 | 401 | |
99f09bc1 | 402 | \func{}{wxString}{\param{const char*}{ psz}, \param{size\_t}{ nLength = wxSTRING\_MAXLEN}} |
a660d684 | 403 | |
b3324be2 | 404 | Takes first {\it nLength} characters from the C string {\it psz}. |
f6bcfd97 BP |
405 | The default value of wxSTRING\_MAXLEN means to take all the string. |
406 | ||
407 | Note that this constructor may be used even if {\it psz} points to a buffer | |
408 | with binary data (i.e. containing {\tt NUL} characters) as long as you provide | |
409 | the correct value for {\it nLength}. However, the default form of it works | |
410 | only with strings without intermediate {\tt NUL}s because it uses | |
411 | {\tt strlen()} to calculate the effective length and it would not give correct | |
412 | results otherwise. | |
a660d684 | 413 | |
99f09bc1 | 414 | \func{}{wxString}{\param{const unsigned char*}{ psz}, \param{size\_t}{ nLength = wxSTRING\_MAXLEN}} |
a660d684 | 415 | |
b3324be2 | 416 | For compilers using unsigned char: takes first {\it nLength} characters from the C string {\it psz}. |
99f09bc1 | 417 | The default value of wxSTRING\_MAXLEN means take all the string. |
a660d684 | 418 | |
b3324be2 | 419 | \func{}{wxString}{\param{const wchar\_t*}{ psz}} |
a660d684 | 420 | |
b3324be2 | 421 | Constructs a string from the wide (UNICODE) string. |
a660d684 | 422 | |
b3324be2 | 423 | \membersection{wxString::\destruct{wxString}}\label{wxstringdestruct} |
a660d684 | 424 | |
b3324be2 | 425 | \func{}{\destruct{wxString}}{\void} |
a660d684 | 426 | |
b3324be2 | 427 | String destructor. Note that this is not virtual, so wxString must not be inherited from. |
a660d684 | 428 | |
99f09bc1 VZ |
429 | \membersection{wxString::Alloc}\label{wxstringalloc} |
430 | ||
431 | \func{void}{Alloc}{\param{size\_t}{ nLen}} | |
432 | ||
433 | Preallocate enough space for wxString to store {\it nLen} characters. This function | |
434 | may be used to increase speed when the string is constructed by repeated | |
435 | concatenation as in | |
436 | ||
437 | \begin{verbatim} | |
a660d684 | 438 | |
99f09bc1 VZ |
439 | // delete all vowels from the string |
440 | wxString DeleteAllVowels(const wxString& original) | |
441 | { | |
442 | wxString result; | |
a660d684 | 443 | |
99f09bc1 | 444 | size_t len = original.length(); |
a660d684 | 445 | |
99f09bc1 VZ |
446 | result.Alloc(len); |
447 | ||
448 | for ( size_t n = 0; n < len; n++ ) | |
449 | { | |
450 | if ( strchr("aeuio", tolower(original[n])) == NULL ) | |
451 | result += original[n]; | |
452 | } | |
453 | ||
454 | return result; | |
455 | } | |
456 | ||
457 | \end{verbatim} | |
458 | ||
459 | because it will avoid the need of reallocating string memory many times (in case | |
460 | of long strings). Note that it does not set the maximal length of a string - it | |
461 | will still expand if more than {\it nLen} characters are stored in it. Also, it | |
462 | does not truncate the existing string (use | |
463 | \helpref{Truncate()}{wxstringtruncate} for this) even if its current length is | |
464 | greater than {\it nLen} | |
465 | ||
466 | \membersection{wxString::Append}\label{wxstringappend} | |
b3324be2 JS |
467 | |
468 | \func{wxString\&}{Append}{\param{const char*}{ psz}} | |
a660d684 | 469 | |
b3324be2 | 470 | Concatenates {\it psz} to this string, returning a reference to it. |
a660d684 | 471 | |
b3324be2 | 472 | \func{wxString\&}{Append}{\param{char}{ ch}, \param{int}{ count = 1}} |
a660d684 | 473 | |
b3324be2 JS |
474 | Concatenates character {\it ch} to this string, {\it count} times, returning a reference |
475 | to it. | |
476 | ||
99f09bc1 | 477 | \membersection{wxString::AfterFirst}\label{wxstringafterfirst} |
b3324be2 | 478 | |
99f09bc1 | 479 | \constfunc{wxString}{AfterFirst}{\param{char}{ ch}} |
b3324be2 | 480 | |
7335902d | 481 | Gets all the characters after the first occurrence of {\it ch}. |
b3324be2 | 482 | Returns the empty string if {\it ch} is not found. |
a660d684 | 483 | |
99f09bc1 | 484 | \membersection{wxString::AfterLast}\label{wxstringafterlast} |
a660d684 | 485 | |
99f09bc1 VZ |
486 | \constfunc{wxString}{AfterLast}{\param{char}{ ch}} |
487 | ||
7335902d | 488 | Gets all the characters after the last occurrence of {\it ch}. |
99f09bc1 VZ |
489 | Returns the whole string if {\it ch} is not found. |
490 | ||
491 | \membersection{wxString::BeforeFirst}\label{wxstringbeforefirst} | |
492 | ||
493 | \constfunc{wxString}{BeforeFirst}{\param{char}{ ch}} | |
494 | ||
7335902d | 495 | Gets all characters before the first occurrence of {\it ch}. |
99f09bc1 VZ |
496 | Returns the whole string if {\it ch} is not found. |
497 | ||
498 | \membersection{wxString::BeforeLast}\label{wxstringbeforelast} | |
499 | ||
500 | \constfunc{wxString}{BeforeLast}{\param{char}{ ch}} | |
b3324be2 | 501 | |
7335902d | 502 | Gets all characters before the last occurrence of {\it ch}. |
99f09bc1 | 503 | Returns the empty string if {\it ch} is not found. |
a660d684 | 504 | |
ed93168b VZ |
505 | \membersection{wxString::c\_str}\label{wxstringcstr} |
506 | ||
507 | \constfunc{const char *}{c\_str}{\void} | |
508 | ||
509 | Returns a pointer to the string data. | |
510 | ||
511 | \membersection{wxString::Clear}\label{wxstringclear} | |
512 | ||
513 | \func{void}{Clear}{\void} | |
514 | ||
515 | Empties the string and frees memory occupied by it. | |
516 | ||
517 | See also: \helpref{Empty}{wxstringempty} | |
518 | ||
f7bd2698 JS |
519 | \membersection{wxString::Cmp}\label{wxstringcmp} |
520 | ||
521 | \constfunc{int}{Cmp}{\param{const char*}{ psz}} | |
522 | ||
523 | Case-sensitive comparison. | |
524 | ||
99f09bc1 | 525 | Returns a positive value if the string is greater than the argument, zero if |
f6bcfd97 | 526 | it is equal to it or a negative value if it is less than the argument (same semantics |
99f09bc1 | 527 | as the standard {\it strcmp()} function). |
f7bd2698 | 528 | |
99f09bc1 | 529 | See also \helpref{CmpNoCase}{wxstringcmpnocase}, \helpref{IsSameAs}{wxstringissameas}. |
f7bd2698 JS |
530 | |
531 | \membersection{wxString::CmpNoCase}\label{wxstringcmpnocase} | |
532 | ||
533 | \constfunc{int}{CmpNoCase}{\param{const char*}{ psz}} | |
534 | ||
535 | Case-insensitive comparison. | |
536 | ||
99f09bc1 | 537 | Returns a positive value if the string is greater than the argument, zero if |
f6bcfd97 | 538 | it is equal to it or a negative value if it is less than the argument (same semantics |
99f09bc1 | 539 | as the standard {\it strcmp()} function). |
f7bd2698 | 540 | |
99f09bc1 | 541 | See also \helpref{Cmp}{wxstringcmp}, \helpref{IsSameAs}{wxstringissameas}. |
f7bd2698 | 542 | |
99f09bc1 | 543 | \membersection{wxString::CompareTo}\label{wxstringcompareto} |
a660d684 KB |
544 | |
545 | \begin{verbatim} | |
546 | #define NO_POS ((int)(-1)) // undefined position | |
b3324be2 | 547 | enum caseCompare {exact, ignoreCase}; |
a660d684 | 548 | \end{verbatim} |
ed93168b | 549 | |
b3324be2 | 550 | \constfunc{int}{CompareTo}{\param{const char*}{ psz}, \param{caseCompare}{ cmp = exact}} |
a660d684 | 551 | |
b3324be2 | 552 | Case-sensitive comparison. Returns 0 if equal, 1 if greater or -1 if less. |
a660d684 | 553 | |
99f09bc1 | 554 | \membersection{wxString::Contains}\label{wxstringcontains} |
a660d684 | 555 | |
99f09bc1 | 556 | \constfunc{bool}{Contains}{\param{const wxString\&}{ str}} |
a660d684 | 557 | |
b3324be2 | 558 | Returns 1 if target appears anyhere in wxString; else 0. |
a660d684 | 559 | |
f7bd2698 | 560 | \membersection{wxString::Empty}\label{wxstringempty} |
a660d684 | 561 | |
f7bd2698 JS |
562 | \func{void}{Empty}{\void} |
563 | ||
ed93168b VZ |
564 | Makes the string empty, but doesn't free memory occupied by the string. |
565 | ||
566 | See also: \helpref{Clear()}{wxstringclear}. | |
f7bd2698 JS |
567 | |
568 | \membersection{wxString::Find}\label{wxstringfind} | |
569 | ||
570 | \constfunc{int}{Find}{\param{char}{ ch}, \param{bool}{ fromEnd = FALSE}} | |
571 | ||
572 | Searches for the given character. Returns the starting index, or -1 if not found. | |
573 | ||
574 | \constfunc{int}{Find}{\param{const char*}{ sz}} | |
575 | ||
576 | Searches for the given string. Returns the starting index, or -1 if not found. | |
a660d684 | 577 | |
b3324be2 | 578 | \membersection{wxString::First}\label{wxstringfirst} |
a660d684 | 579 | |
b3324be2 | 580 | \func{size\_t}{First}{\param{char}{ c}} |
a660d684 | 581 | |
b3324be2 | 582 | \constfunc{size\_t}{First}{\param{const char*}{ psz}} |
a660d684 | 583 | |
b3324be2 | 584 | \constfunc{size\_t}{First}{\param{const wxString\&}{ str}} |
a660d684 | 585 | |
b3324be2 | 586 | \constfunc{size\_t}{First}{\param{const char}{ ch}} |
a660d684 | 587 | |
f7bd2698 | 588 | Returns the first occurrence of the item. |
a660d684 | 589 | |
341e7d28 VZ |
590 | \membersection{wxString::Format}\label{wxstringformat} |
591 | ||
592 | \func{static wxString}{Format}{\param{const wxChar }{*format}, \param{}{...}} | |
593 | ||
594 | This static function returns the string containing the result of calling | |
595 | \helpref{Printf}{wxstringprintf} with the passed parameters on it. | |
596 | ||
597 | \wxheading{See also} | |
598 | ||
599 | \helpref{FormatV}{wxstringformatv}, \helpref{Printf}{wxstringprintf} | |
600 | ||
601 | \membersection{wxString::FormatV}\label{wxstringformatv} | |
602 | ||
603 | \func{static wxString}{Format}{\param{const wxChar }{*format}, \param{va\_list }{argptr}} | |
604 | ||
605 | This static function returns the string containing the result of calling | |
606 | \helpref{PrintfV}{wxstringprintfv} with the passed parameters on it. | |
607 | ||
608 | \wxheading{See also} | |
609 | ||
610 | \helpref{Format}{wxstringformat}, \helpref{PrintfV}{wxstringprintfv} | |
611 | ||
99f09bc1 VZ |
612 | \membersection{wxString::Freq}\label{wxstringfreq} |
613 | ||
f6bcfd97 | 614 | \constfunc{int}{Freq}{\param{char }{ch}} |
99f09bc1 | 615 | |
f6bcfd97 | 616 | Returns the number of occurrences of {\it ch} in the string. |
99f09bc1 | 617 | |
f7bd2698 | 618 | \membersection{wxString::GetChar}\label{wxstringgetchar} |
a660d684 | 619 | |
f7bd2698 | 620 | \constfunc{char}{GetChar}{\param{size\_t}{ n}} |
a660d684 | 621 | |
f7bd2698 | 622 | Returns the character at position {\it n} (read-only). |
a660d684 | 623 | |
99f09bc1 | 624 | \membersection{wxString::GetData}\label{wxstringgetdata} |
a660d684 | 625 | |
f7bd2698 | 626 | \constfunc{const char*}{GetData}{\void} |
a660d684 | 627 | |
f7bd2698 | 628 | wxWindows compatibility conversion. Returns a constant pointer to the data in the string. |
a660d684 | 629 | |
f7bd2698 | 630 | \membersection{wxString::GetWritableChar}\label{wxstringgetwritablechar} |
a660d684 | 631 | |
f7bd2698 | 632 | \func{char\&}{GetWritableChar}{\param{size\_t}{ n}} |
a660d684 | 633 | |
f7bd2698 | 634 | Returns a reference to the character at position {\it n}. |
a660d684 | 635 | |
f7bd2698 | 636 | \membersection{wxString::GetWriteBuf}\label{wxstringgetwritebuf} |
a660d684 | 637 | |
99f09bc1 | 638 | \func{char*}{GetWriteBuf}{\param{size\_t}{ len}} |
a660d684 | 639 | |
f7bd2698 | 640 | Returns a writable buffer of at least {\it len} bytes. |
a660d684 | 641 | |
f7bd2698 JS |
642 | Call \helpref{wxString::UngetWriteBuf}{wxstringungetwritebuf} as soon as possible |
643 | to put the string back into a reasonable state. | |
a660d684 | 644 | |
99f09bc1 | 645 | \membersection{wxString::Index}\label{wxstringindex} |
a660d684 | 646 | |
5ef056a3 | 647 | \constfunc{size\_t}{Index}{\param{char}{ ch}} |
a660d684 | 648 | |
f7bd2698 | 649 | Same as \helpref{wxString::Find}{wxstringfind}. |
a660d684 | 650 | |
f7bd2698 | 651 | \constfunc{size\_t}{Index}{\param{const char*}{ sz}} |
a660d684 | 652 | |
f7bd2698 | 653 | Same as \helpref{wxString::Find}{wxstringfind}. |
a660d684 | 654 | |
f7bd2698 | 655 | \constfunc{size\_t}{Index}{\param{const char*}{ sz}, \param{bool}{ caseSensitive = TRUE}, \param{bool}{ fromEnd = FALSE}} |
a660d684 | 656 | |
f7bd2698 | 657 | Search the element in the array, starting from either side. |
a660d684 | 658 | |
f7bd2698 | 659 | If {\it fromEnd} is TRUE, reverse search direction. |
a660d684 | 660 | |
f7bd2698 | 661 | If {\bf caseSensitive}, comparison is case sensitive (the default). |
a660d684 | 662 | |
2b5f62a0 | 663 | Returns the index of the first item matched, or wxNOT\_FOUND. |
a660d684 | 664 | |
8a2c6ef8 JS |
665 | % TODO |
666 | %\membersection{wxString::insert}\label{wxstringinsert} | |
667 | % Wrong! | |
99f09bc1 | 668 | %\func{void}{insert}{\param{const wxString\&}{ str}, \param{size\_t}{ index}} |
8a2c6ef8 JS |
669 | % |
670 | %Add new element at the given position. | |
671 | % | |
99f09bc1 | 672 | \membersection{wxString::IsAscii}\label{wxstringisascii} |
a660d684 | 673 | |
f7bd2698 | 674 | \constfunc{bool}{IsAscii}{\void} |
a660d684 | 675 | |
b59893f3 | 676 | Returns TRUE if the string contains only ASCII characters. |
a660d684 | 677 | |
f7bd2698 | 678 | \membersection{wxString::IsEmpty}\label{wxstringisempty} |
a660d684 | 679 | |
f7bd2698 | 680 | \constfunc{bool}{IsEmpty}{\void} |
a660d684 | 681 | |
b59893f3 | 682 | Returns TRUE if the string is empty. |
a660d684 | 683 | |
99f09bc1 | 684 | \membersection{wxString::IsNull}\label{wxstringisnull} |
a660d684 | 685 | |
f7bd2698 | 686 | \constfunc{bool}{IsNull}{\void} |
a660d684 | 687 | |
b59893f3 | 688 | Returns TRUE if the string is empty (same as \helpref{IsEmpty}{wxstringisempty}). |
a660d684 | 689 | |
99f09bc1 | 690 | \membersection{wxString::IsNumber}\label{wxstringisnumber} |
a660d684 | 691 | |
f7bd2698 JS |
692 | \constfunc{bool}{IsNumber}{\void} |
693 | ||
b59893f3 | 694 | Returns TRUE if the string is an integer (with possible sign). |
f7bd2698 JS |
695 | |
696 | \membersection{wxString::IsSameAs}\label{wxstringissameas} | |
697 | ||
698 | \constfunc{bool}{IsSameAs}{\param{const char*}{ psz}, \param{bool}{ caseSensitive = TRUE}} | |
699 | ||
700 | Test for string equality, case-sensitive (default) or not. | |
701 | ||
702 | caseSensitive is TRUE by default (case matters). | |
a660d684 | 703 | |
f7bd2698 JS |
704 | Returns TRUE if strings are equal, FALSE otherwise. |
705 | ||
f33fee2a VZ |
706 | See also \helpref{Cmp}{wxstringcmp}, \helpref{CmpNoCase}{wxstringcmpnocase}, \helpref{IsSameAs}{wxstringissameas2} |
707 | ||
708 | \membersection{wxString::IsSameAs}\label{wxstringissameas2} | |
709 | ||
710 | \constfunc{bool}{IsSameAs}{\param{char}{ c}, \param{bool}{ caseSensitive = TRUE}} | |
711 | ||
712 | Test whether the string is equal to the single character {\it c}. The test is | |
713 | case-sensitive if {\it caseSensitive} is TRUE (default) or not if it is FALSE. | |
714 | ||
715 | Returns TRUE if the string is equal to the character, FALSE otherwise. | |
716 | ||
717 | See also \helpref{Cmp}{wxstringcmp}, \helpref{CmpNoCase}{wxstringcmpnocase}, \helpref{IsSameAs}{wxstringissameas} | |
a660d684 | 718 | |
99f09bc1 | 719 | \membersection{wxString::IsWord}\label{wxstringisword} |
a660d684 | 720 | |
f7bd2698 | 721 | \constfunc{bool}{IsWord}{\void} |
a660d684 | 722 | |
f7bd2698 | 723 | Returns TRUE if the string is a word. TODO: what's the definition of a word? |
a660d684 | 724 | |
99f09bc1 | 725 | \membersection{wxString::Last}\label{wxstringlast} |
a660d684 | 726 | |
f7bd2698 | 727 | \constfunc{char}{Last}{\void} |
a660d684 | 728 | |
f7bd2698 | 729 | Returns the last character. |
a660d684 | 730 | |
f7bd2698 | 731 | \func{char\&}{Last}{\void} |
a660d684 | 732 | |
f7bd2698 | 733 | Returns a reference to the last character (writable). |
a660d684 | 734 | |
f7bd2698 JS |
735 | \membersection{wxString::Left}\label{wxstringleft} |
736 | ||
737 | \constfunc{wxString}{Left}{\param{size\_t}{ count}} | |
738 | ||
fefc4f15 | 739 | Returns the first {\it count} characters of the string. |
a660d684 | 740 | |
f7bd2698 | 741 | \membersection{wxString::Len}\label{wxstringlen} |
a660d684 | 742 | |
f7bd2698 JS |
743 | \constfunc{size\_t}{Len}{\void} |
744 | ||
745 | Returns the length of the string. | |
746 | ||
747 | \membersection{wxString::Length}\label{wxstringlength} | |
748 | ||
749 | \constfunc{size\_t}{Length}{\void} | |
750 | ||
751 | Returns the length of the string (same as Len). | |
a660d684 | 752 | |
99f09bc1 VZ |
753 | \membersection{wxString::Lower}\label{wxstringlower} |
754 | ||
755 | \constfunc{wxString}{Lower}{\void} | |
756 | ||
757 | Returns this string converted to the lower case. | |
758 | ||
759 | \membersection{wxString::LowerCase}\label{wxstringlowercase} | |
a660d684 | 760 | |
f7bd2698 JS |
761 | \func{void}{LowerCase}{\void} |
762 | ||
763 | Same as MakeLower. | |
764 | ||
765 | \membersection{wxString::MakeLower}\label{wxstringmakelower} | |
766 | ||
767 | \func{void}{MakeLower}{\void} | |
768 | ||
769 | Converts all characters to lower case. | |
770 | ||
771 | \membersection{wxString::MakeUpper}\label{wxstringmakeupper} | |
772 | ||
773 | \func{void}{MakeUpper}{\void} | |
774 | ||
775 | Converts all characters to upper case. | |
a660d684 | 776 | |
99f09bc1 | 777 | \membersection{wxString::Matches}\label{wxstringmatches} |
a660d684 | 778 | |
f7bd2698 JS |
779 | \constfunc{bool}{Matches}{\param{const char*}{ szMask}} |
780 | ||
781 | Returns TRUE if the string contents matches a mask containing '*' and '?'. | |
a660d684 | 782 | |
f7bd2698 | 783 | \membersection{wxString::Mid}\label{wxstringmid} |
a660d684 | 784 | |
99f09bc1 | 785 | \constfunc{wxString}{Mid}{\param{size\_t}{ first}, \param{size\_t}{ count = wxSTRING\_MAXLEN}} |
a660d684 | 786 | |
f7bd2698 JS |
787 | Returns a substring starting at {\it first}, with length {\it count}, or the rest of |
788 | the string if {\it count} is the default value. | |
789 | ||
790 | \membersection{wxString::Pad}\label{wxstringpad} | |
791 | ||
792 | \func{wxString\&}{Pad}{\param{size\_t}{ count}, \param{char}{ pad = ' '}, \param{bool}{ fromRight = TRUE}} | |
793 | ||
794 | Adds {\it count} copies of {\it pad} to the beginning, or to the end of the string (the default). | |
795 | ||
796 | Removes spaces from the left or from the right (default). | |
a660d684 | 797 | |
99f09bc1 | 798 | \membersection{wxString::Prepend}\label{wxstringprepend} |
a660d684 | 799 | |
f7bd2698 | 800 | \func{wxString\&}{Prepend}{\param{const wxString\&}{ str}} |
a660d684 | 801 | |
f7bd2698 | 802 | Prepends {\it str} to this string, returning a reference to this string. |
a660d684 | 803 | |
f7bd2698 | 804 | \membersection{wxString::Printf}\label{wxstringprintf} |
a660d684 | 805 | |
f7bd2698 JS |
806 | \func{int}{Printf}{\param{const char* }{pszFormat}, \param{}{...}} |
807 | ||
99f09bc1 VZ |
808 | Similar to the standard function {\it sprintf()}. Returns the number of |
809 | characters written, or an integer less than zero on error. | |
810 | ||
811 | {\bf NB:} This function will use a safe version of {\it vsprintf()} (usually called | |
812 | {\it vsnprintf()}) whenever available to always allocate the buffer of correct | |
813 | size. Unfortunately, this function is not available on all platforms and the | |
814 | dangerous {\it vsprintf()} will be used then which may lead to buffer overflows. | |
a660d684 | 815 | |
f7bd2698 JS |
816 | \membersection{wxString::PrintfV}\label{wxstringprintfv} |
817 | ||
818 | \func{int}{PrintfV}{\param{const char* }{pszFormat}, \param{va\_list}{ argPtr}} | |
819 | ||
820 | Similar to vprintf. Returns the number of characters written, or an integer less than zero | |
821 | on error. | |
a660d684 | 822 | |
99f09bc1 | 823 | \membersection{wxString::Remove}\label{wxstringremove} |
a660d684 | 824 | |
f7bd2698 JS |
825 | \func{wxString\&}{Remove}{\param{size\_t}{ pos}} |
826 | ||
827 | Same as Truncate. Removes the portion from {\it pos} to the end of the string. | |
828 | ||
829 | \func{wxString\&}{Remove}{\param{size\_t}{ pos}, \param{size\_t}{ len}} | |
830 | ||
42d14d4e | 831 | Removes the {\it len} characters from the string, starting at {\it pos}. |
f7bd2698 JS |
832 | |
833 | \membersection{wxString::RemoveLast}\label{wxstringremovelast} | |
a660d684 | 834 | |
f7bd2698 JS |
835 | \func{wxString\&}{RemoveLast}{\void} |
836 | ||
837 | Removes the last character. | |
a660d684 | 838 | |
99f09bc1 | 839 | \membersection{wxString::Replace}\label{wxstringreplace} |
a660d684 | 840 | |
99f09bc1 | 841 | \func{size\_t}{Replace}{\param{const char*}{ szOld}, \param{const char*}{ szNew}, \param{bool}{ replaceAll = TRUE}} |
f7bd2698 | 842 | |
7335902d | 843 | Replace first (or all) occurrences of substring with another one. |
f7bd2698 | 844 | |
7335902d | 845 | {\it replaceAll}: global replace (default), or only the first occurrence. |
f7bd2698 JS |
846 | |
847 | Returns the number of replacements made. | |
848 | ||
849 | \membersection{wxString::Right}\label{wxstringright} | |
850 | ||
851 | \constfunc{wxString}{Right}{\param{size\_t}{ count}} | |
a660d684 | 852 | |
f7bd2698 | 853 | Returns the last {\it count} characters. |
a660d684 | 854 | |
f7bd2698 | 855 | \membersection{wxString::SetChar}\label{wxstringsetchar} |
a660d684 | 856 | |
f7bd2698 JS |
857 | \func{void}{SetChar}{\param{size\_t}{ n}, \param{char}{ch}} |
858 | ||
859 | Sets the character at position {\it n}. | |
860 | ||
861 | \membersection{wxString::Shrink}\label{wxstringshrink} | |
862 | ||
863 | \func{void}{Shrink}{\void} | |
864 | ||
99f09bc1 VZ |
865 | Minimizes the string's memory. This can be useful after a call to |
866 | \helpref{Alloc()}{wxstringalloc} if too much memory were preallocated. | |
a660d684 KB |
867 | |
868 | \membersection{wxString::sprintf}\label{wxstringsprintf} | |
a660d684 | 869 | |
f7bd2698 | 870 | \func{void}{sprintf}{\param{const char* }{ fmt}} |
a660d684 | 871 | |
f7bd2698 | 872 | The same as Printf. |
a660d684 | 873 | |
f6bcfd97 BP |
874 | \membersection{wxString::StartsWith}\label{wxstringstartswith} |
875 | ||
876 | \constfunc{bool}{StartsWith}{\param{const wxChar }{*prefix}, \param{wxString }{*rest = NULL}} | |
877 | ||
878 | This function can be used to test if the string starts with the specified | |
879 | {\it prefix}. If it does, the function will return {\tt TRUE} and put the rest | |
880 | of the string (i.e. after the prefix) into {\it rest} string if it is not | |
881 | {\tt NULL}. Otherwise, the function returns {\tt FALSE} and doesn't modify the | |
882 | {\it rest}. | |
883 | ||
99f09bc1 | 884 | \membersection{wxString::Strip}\label{wxstringstrip} |
a660d684 KB |
885 | |
886 | \begin{verbatim} | |
f7bd2698 | 887 | enum stripType {leading = 0x1, trailing = 0x2, both = 0x3}; |
a660d684 KB |
888 | \end{verbatim} |
889 | ||
f7bd2698 | 890 | \constfunc{wxString}{Strip}{\param{stripType}{ s = trailing}} |
a660d684 | 891 | |
f7bd2698 JS |
892 | Strip characters at the front and/or end. The same as Trim except that it |
893 | doesn't change this string. | |
a660d684 | 894 | |
99f09bc1 VZ |
895 | \membersection{wxString::SubString}\label{wxstringsubstring} |
896 | ||
f6bcfd97 | 897 | \constfunc{wxString}{SubString}{\param{size\_t}{ from}, \param{size\_t}{ to}} |
99f09bc1 | 898 | |
b855ef77 VZ |
899 | Deprecated, use \helpref{Mid}{wxstringmid} instead (but note that parameters |
900 | have different meaning). | |
901 | ||
902 | Returns the part of the string between the indices {\it from} and {\it to} | |
903 | inclusive. | |
99f09bc1 | 904 | |
cd0b1709 VZ |
905 | \membersection{wxString::ToDouble}\label{wxstringtodouble} |
906 | ||
f6bcfd97 | 907 | \constfunc{bool}{ToDouble}{\param{double}{ *val}} |
cd0b1709 VZ |
908 | |
909 | Attempts to convert the string to a floating point number. Returns TRUE on | |
f6bcfd97 | 910 | success (the number is stored in the location pointed to by {\it val}) or FALSE |
cd0b1709 VZ |
911 | if the string does not represent such number. |
912 | ||
f6bcfd97 BP |
913 | \wxheading{See also} |
914 | ||
915 | \helpref{wxString::ToLong}{wxstringtolong},\\ | |
916 | \helpref{wxString::ToULong}{wxstringtoulong} | |
917 | ||
cd0b1709 VZ |
918 | \membersection{wxString::ToLong}\label{wxstringtolong} |
919 | ||
538f35cc | 920 | \constfunc{bool}{ToLong}{\param{long}{ *val}, \param{int }{base = $10$}} |
cd0b1709 | 921 | |
4eb438cf VZ |
922 | Attempts to convert the string to a signed integer in base {\it base}. Returns |
923 | {\tt TRUE} on success in which case the number is stored in the location | |
924 | pointed to by {\it val} or {\tt FALSE} if the string does not represent a | |
925 | valid number in the given base. | |
926 | ||
538f35cc VZ |
927 | The value of {\it base} must be comprised between $2$ and $36$, inclusive, or |
928 | be a special value $0$ which means that the usual rules of {\tt C} numbers are | |
929 | applied: if the number starts with {\tt 0x} it is considered to be in base | |
930 | $16$, if it starts with {\tt 0} - in base $8$ and in base $10$ otherwise. Note | |
931 | that you may not want to specify the base $0$ if you are parsing the numbers | |
932 | which may have leading zeroes as they can yield unexpected (to the user not | |
933 | familiar with C) results. | |
cd0b1709 | 934 | |
f6bcfd97 BP |
935 | \wxheading{See also} |
936 | ||
937 | \helpref{wxString::ToDouble}{wxstringtodouble},\\ | |
938 | \helpref{wxString::ToULong}{wxstringtoulong} | |
939 | ||
cd0b1709 VZ |
940 | \membersection{wxString::ToULong}\label{wxstringtoulong} |
941 | ||
538f35cc | 942 | \constfunc{bool}{ToULong}{\param{unsigned long}{ *val}, \param{int }{base = $10$}} |
4eb438cf VZ |
943 | |
944 | Attempts to convert the string to a ansigned integer in base {\it base}. | |
945 | Returns {\tt TRUE} on success in which case the number is stored in the | |
946 | location pointed to by {\it val} or {\tt FALSE} if the string does not | |
947 | represent a valid number in the given base. | |
cd0b1709 | 948 | |
ec64d632 VZ |
949 | See \helpref{wxString::ToLong}{wxstringtolong} for the more detailed |
950 | description of the {\it base} parameter. | |
cd0b1709 | 951 | |
f6bcfd97 BP |
952 | \wxheading{See also} |
953 | ||
954 | \helpref{wxString::ToDouble}{wxstringtodouble},\\ | |
955 | \helpref{wxString::ToLong}{wxstringtolong} | |
956 | ||
f7bd2698 | 957 | \membersection{wxString::Trim}\label{wxstringtrim} |
a660d684 | 958 | |
f7bd2698 | 959 | \func{wxString\&}{Trim}{\param{bool}{ fromRight = TRUE}} |
a660d684 | 960 | |
f7bd2698 | 961 | Removes spaces from the left or from the right (default). |
a660d684 | 962 | |
f7bd2698 | 963 | \membersection{wxString::Truncate}\label{wxstringtruncate} |
a660d684 | 964 | |
f7bd2698 | 965 | \func{wxString\&}{Truncate}{\param{size\_t}{ len}} |
a660d684 | 966 | |
f7bd2698 | 967 | Truncate the string to the given length. |
a660d684 | 968 | |
f7bd2698 JS |
969 | \membersection{wxString::UngetWriteBuf}\label{wxstringungetwritebuf} |
970 | ||
971 | \func{void}{UngetWriteBuf}{\void} | |
972 | ||
973 | Puts the string back into a reasonable state, after | |
974 | \rtfsp\helpref{wxString::GetWriteBuf}{wxstringgetwritebuf} was called. | |
a660d684 | 975 | |
99f09bc1 VZ |
976 | \membersection{wxString::Upper}\label{wxstringupper} |
977 | ||
978 | \constfunc{wxString}{Upper}{\void} | |
979 | ||
980 | Returns this string converted to upper case. | |
981 | ||
982 | \membersection{wxString::UpperCase}\label{wxstringuppercase} | |
a660d684 | 983 | |
f7bd2698 JS |
984 | \func{void}{UpperCase}{\void} |
985 | ||
986 | The same as MakeUpper. | |
a660d684 | 987 | |
99f09bc1 VZ |
988 | \membersection{wxString::operator!}\label{wxstringoperatornot} |
989 | ||
990 | \constfunc{bool}{operator!}{\void} | |
991 | ||
992 | Empty string is FALSE, so !string will only return TRUE if the string is empty. | |
993 | This allows the tests for NULLness of a {\it const char *} pointer and emptyness | |
994 | of the string to look the same in the code and makes it easier to port old code | |
995 | to wxString. | |
996 | ||
997 | See also \helpref{IsEmpty()}{wxstringisempty}. | |
998 | ||
a660d684 KB |
999 | \membersection{wxString::operator $=$}\label{wxstringoperatorassign} |
1000 | ||
f7bd2698 JS |
1001 | \func{wxString\&}{operator $=$}{\param{const wxString\&}{ str}} |
1002 | ||
1003 | \func{wxString\&}{operator $=$}{\param{const char*}{ psz}} | |
1004 | ||
1005 | \func{wxString\&}{operator $=$}{\param{char}{ c}} | |
1006 | ||
1007 | \func{wxString\&}{operator $=$}{\param{const unsigned char*}{ psz}} | |
1008 | ||
1009 | \func{wxString\&}{operator $=$}{\param{const wchar\_t*}{ pwz}} | |
a660d684 | 1010 | |
99f09bc1 VZ |
1011 | Assignment: the effect of each operation is the same as for the corresponding |
1012 | constructor (see \helpref{wxString constructors}{wxstringconstruct}). | |
5de76427 | 1013 | |
f6bcfd97 | 1014 | \membersection{wxString::operator $+$}\label{wxstringoperatorplus} |
5de76427 | 1015 | |
99f09bc1 VZ |
1016 | Concatenation: all these operators return a new strign equal to the sum of the |
1017 | operands. | |
5de76427 JS |
1018 | |
1019 | \func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}} | |
1020 | ||
1021 | \func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{const char*}{ y}} | |
1022 | ||
1023 | \func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{char}{ y}} | |
1024 | ||
1025 | \func{wxString}{operator $+$}{\param{const char*}{ x}, \param{const wxString\&}{ y}} | |
1026 | ||
99f09bc1 | 1027 | \membersection{wxString::operator $+=$}\label{wxstringplusequal} |
a660d684 | 1028 | |
f7bd2698 JS |
1029 | \func{void}{operator $+=$}{\param{const wxString\&}{ str}} |
1030 | ||
1031 | \func{void}{operator $+=$}{\param{const char*}{ psz}} | |
1032 | ||
1033 | \func{void}{operator $+=$}{\param{char}{ c}} | |
a660d684 | 1034 | |
99f09bc1 | 1035 | Concatenation in place: the argument is appended to the string. |
a660d684 KB |
1036 | |
1037 | \membersection{wxString::operator []}\label{wxstringoperatorbracket} | |
1038 | ||
f7bd2698 JS |
1039 | \func{char\&}{operator []}{\param{size\_t}{ i}} |
1040 | ||
1041 | \func{char}{operator []}{\param{size\_t}{ i}} | |
1042 | ||
1043 | \func{char}{operator []}{\param{int}{ i}} | |
a660d684 KB |
1044 | |
1045 | Element extraction. | |
1046 | ||
1047 | \membersection{wxString::operator ()}\label{wxstringoperatorparenth} | |
1048 | ||
f7bd2698 JS |
1049 | \func{wxString}{operator ()}{\param{size\_t}{ start}, \param{size\_t}{ len}} |
1050 | ||
1051 | Same as Mid (substring extraction). | |
a660d684 KB |
1052 | |
1053 | \membersection{wxString::operator \cinsert}\label{wxstringoperatorout} | |
f7bd2698 | 1054 | |
037267e1 | 1055 | \func{wxString\&}{operator \cinsert}{\param{const wxString\&}{ str}} |
f7bd2698 | 1056 | |
037267e1 | 1057 | \func{wxString\&}{operator \cinsert}{\param{const char*}{ psz}} |
f7bd2698 | 1058 | |
037267e1 | 1059 | \func{wxString\&}{operator \cinsert}{\param{char }{ch}} |
f7bd2698 JS |
1060 | |
1061 | Same as $+=$. | |
a660d684 | 1062 | |
99f09bc1 VZ |
1063 | \func{wxString\&}{operator \cinsert}{\param{int}{ i}} |
1064 | ||
1065 | \func{wxString\&}{operator \cinsert}{\param{float}{ f}} | |
1066 | ||
1067 | \func{wxString\&}{operator \cinsert}{\param{double}{ d}} | |
1068 | ||
1069 | These functions work as C++ stream insertion operators: they insert the given | |
1070 | value into the string. Precision or format cannot be set using them, you can use | |
1071 | \helpref{Printf}{wxstringprintf} for this. | |
1072 | ||
a660d684 | 1073 | \membersection{wxString::operator \cextract}\label{wxstringoperatorin} |
a660d684 | 1074 | |
f7bd2698 | 1075 | \func{friend istream\&}{operator \cextract}{\param{istream\&}{ is}, \param{wxString\&}{ str}} |
a660d684 | 1076 | |
f7bd2698 | 1077 | Extraction from a stream. |
a660d684 | 1078 | |
f7bd2698 | 1079 | \membersection{wxString::operator const char*}\label{wxstringoperatorconstcharpt} |
a660d684 | 1080 | |
f7bd2698 | 1081 | \constfunc{}{operator const char*}{\void} |
a660d684 | 1082 | |
f7bd2698 | 1083 | Implicit conversion to a C string. |
a660d684 | 1084 | |
99f09bc1 | 1085 | \membersection{Comparison operators}\label{wxstringcomparison} |
a660d684 | 1086 | |
f7bd2698 | 1087 | \func{bool}{operator $==$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}} |
a660d684 | 1088 | |
f7bd2698 | 1089 | \func{bool}{operator $==$}{\param{const wxString\&}{ x}, \param{const char*}{ t}} |
a660d684 | 1090 | |
f7bd2698 | 1091 | \func{bool}{operator $!=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}} |
a660d684 | 1092 | |
f7bd2698 | 1093 | \func{bool}{operator $!=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}} |
a660d684 | 1094 | |
f7bd2698 | 1095 | \func{bool}{operator $>$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}} |
a660d684 | 1096 | |
f7bd2698 | 1097 | \func{bool}{operator $>$}{\param{const wxString\&}{ x}, \param{const char*}{ t}} |
a660d684 | 1098 | |
f7bd2698 | 1099 | \func{bool}{operator $>=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}} |
a660d684 | 1100 | |
f7bd2698 | 1101 | \func{bool}{operator $>=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}} |
a660d684 | 1102 | |
f7bd2698 | 1103 | \func{bool}{operator $<$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}} |
a660d684 | 1104 | |
f7bd2698 | 1105 | \func{bool}{operator $<$}{\param{const wxString\&}{ x}, \param{const char*}{ t}} |
a660d684 | 1106 | |
f7bd2698 | 1107 | \func{bool}{operator $<=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}} |
a660d684 | 1108 | |
f7bd2698 | 1109 | \func{bool}{operator $<=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}} |
a660d684 | 1110 | |
f7bd2698 | 1111 | \wxheading{Remarks} |
a660d684 | 1112 | |
f7bd2698 | 1113 | These comparisons are case-sensitive. |
a660d684 | 1114 | |
1d218550 VZ |
1115 | |
1116 | \section{\class{wxStringBuffer}}\label{wxstringbuffer} | |
1117 | ||
1118 | This tiny class allows to conveniently access the \helpref{wxString}{wxstring} | |
1119 | internal buffer as a writable pointer without any risk to forget to restore | |
1120 | the string to the usable state later. | |
1121 | ||
1122 | For example, assuming you have a low-level OS function called | |
1123 | {\tt GetMeaningOfLifeAsString(char *)} returning the value in the provided | |
1124 | buffer (which must be writable, of course) you might call it like this: | |
1125 | ||
1126 | \begin{verbatim} | |
1127 | wxString theAnswer; | |
1128 | GetMeaningOfLifeAsString(wxStringBuffer(theAnswer, 1024)); | |
1129 | if ( theAnswer != "42" ) | |
1130 | { | |
1131 | wxLogError("Something is very wrong!"); | |
1132 | } | |
1133 | \end{verbatim} | |
1134 | ||
1135 | \wxheading{Derived from} | |
1136 | ||
1137 | None | |
1138 | ||
1139 | \wxheading{Include files} | |
1140 | ||
1141 | <wx/string.h> | |
1142 | ||
1143 | \latexignore{\rtfignore{\wxheading{Members}}} | |
1144 | ||
1145 | \membersection{wxStringBuffer::wxStringBuffer} | |
1146 | ||
1147 | \func{}{wxStringBuffer}{\param{const wxString\& }{str}, \param{size\_t }{len}} | |
1148 | ||
1149 | Constructs a writable string buffer object associated with the given string | |
2edb0bde | 1150 | and containing enough space for at least {\it len} characters. Basically, this |
1d218550 VZ |
1151 | is equivalent to calling \helpref{GetWriteBuf}{wxstringgetwritebuf} and |
1152 | saving the result. | |
1153 | ||
1154 | \membersection{wxStringBuffer::\destruct{wxStringBuffer}} | |
1155 | ||
1156 | \func{}{\destruct{wxStringBuffer}}{\void} | |
1157 | ||
1158 | Restores the string passed to the constructor to the usable state by calling | |
1159 | \helpref{UngetWriteBuf}{wxstringungetwritebuf} on it. | |
1160 | ||
1161 | \membersection{wxStringBuffer::operator wxChar *} | |
1162 | ||
1163 | \constfunc{wxChar *}{operator wxChar *}{\void} | |
1164 | ||
1165 | Returns the writable pointer to a buffer of the size at least equal to the | |
1166 | length specified in the constructor. | |
1167 | ||
1168 |