1 \section{\class{wxString
}}\label{wxstring
}
3 wxString is a class representing a character string. Please see the
4 \helpref{wxString overview
}{wxstringoverview
} for more information about it. As explained
5 there, wxString implements about
90\% of methods of the std::string class (iterators
6 are not supported, nor all methods which use them).
7 These standard functions are not documented in this manual so please see the STL documentation.
8 The behaviour of all these functions is identical to the behaviour described
11 \wxheading{Derived from
}
15 \wxheading{Include files
}
19 \wxheading{Predefined objects
}
27 \overview{Overview
}{wxstringoverview
}
29 \latexignore{\rtfignore{\wxheading{Function groups
}}}
31 \membersection{Constructors and assignment operators
}
33 A strign may be constructed either from a C string, (some number of copies of)
34 a single character or a wide (UNICODE) string. For all constructors (except the
35 default which creates an empty string) there is also a corresponding assignment
38 \helpref{wxString
}{wxstringconstruct
}\\
39 \helpref{operator $=$
}{wxstringoperatorassign
}\\
40 \helpref{\destruct{wxString
}}{wxstringdestruct
}
42 \membersection{String length
}
44 These functions return the string length and check whether the string is empty
47 \helpref{Len
}{wxstringlen
}\\
48 \helpref{IsEmpty
}{wxstringisempty
}\\
49 \helpref{operator!
}{wxstringoperatornot
}\\
50 \helpref{Empty
}{wxstringempty
}\\
51 \helpref{Clear
}{wxstringclear
}
53 \membersection{Character access
}
55 Many functions in this section take a character index in the string. As with C
56 strings and/or arrays, the indices start from $
0$, so the first character of a
57 string is string
[$
0$
]. Attempt to access a character beyond the end of the
58 string (which may be even $
0$ if the string is empty) will provocate an assert
59 failure in
\helpref{debug build
}{debuggingoverview
}, but no checks are done in
62 This section also contains both implicit and explicit conversions to C style
63 strings. Although implicit conversion is quite convenient, it is advised to use
64 explicit
\helpref{c
\_str()
}{wxstringcstr
} method for the sake of clarity. Also
65 see
\helpref{overview
}{wxstringadvices
} for the cases where it is necessary to
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
}
76 \membersection{Concatenation
}
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.
82 \helpref{operator
\cinsert}{wxstringoperatorout
}\\
83 \helpref{operator $+=$
}{wxstringplusequal
}\\
84 \helpref{operator $+$
}{wxstringoperatorplus
}\\
85 \helpref{Append
}{wxstringappend
}\\
86 \helpref{Prepend
}{wxstringprepend
}
88 \membersection{Comparison
}
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)
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
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
104 doing direct string comparaison as you would also have to precalculate the
105 length of the prefix then.
107 \helpref{Cmp
}{wxstringcmp
}\\
108 \helpref{CmpNoCase
}{wxstringcmpnocase
}\\
109 \helpref{IsSameAs
}{wxstringissameas
}\\
110 \helpref{Matches
}{wxstringmatches
}\\
111 \helpref{StartsWith
}{wxstringstartswith
}
113 \membersection{Substring extraction
}
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
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
}\\
126 \helpref{AfterLast
}{wxstringafterlast
}\\
127 \helpref{StartsWith
}{wxstringstartswith
}
129 \membersection{Case conversion
}
131 The MakeXXX() variants modify the string in place, while the other functions
132 return a new string which containts the original text converted to the upper or
133 lower case and leave the original string unchanged.
135 \helpref{MakeUpper
}{wxstringmakeupper
}\\
136 \helpref{Upper
}{wxstringupper
}\\
137 \helpref{MakeLower
}{wxstringmakelower
}\\
138 \helpref{Lower
}{wxstringlower
}
140 \membersection{Searching and replacing
}
142 These functions replace the standard
{\it strchr()
} and
{\it strstr()
}
145 \helpref{Find
}{wxstringfind
}\\
146 \helpref{Replace
}{wxstringreplace
}
148 \membersection{Conversion to numbers
}
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.
155 \helpref{ToLong
}{wxstringtolong
}\\
156 \helpref{ToULong
}{wxstringtoulong
}\\
157 \helpref{ToDouble
}{wxstringtodouble
}
159 \membersection{Writing values into the string
}
161 Both formatted versions (
\helpref{Printf
}{wxstringprintf
}) and stream-like
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:
167 // the following
2 snippets are equivalent
170 s += wxString::Format("
%d", n);
173 s.Printf("...
%d", n);
176 \helpref{Format
}{wxstringformat
}\\
177 \helpref{FormatV
}{wxstringformatv
}\\
178 \helpref{Printf
}{wxstringprintf
}\\
179 \helpref{PrintfV
}{wxstringprintfv
}\\
180 \helpref{operator
\cinsert}{wxstringoperatorout
}
182 \membersection{Memory management
}
184 These are "advanced" functions and they will be needed quite rarily.
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
193 \helpref{Alloc
}{wxstringalloc
}\\
194 \helpref{Shrink
}{wxstringshrink
}\\
195 \helpref{GetWriteBuf
}{wxstringgetwritebuf
}\\
196 \helpref{UngetWriteBuf
}{wxstringungetwritebuf
}
198 \membersection{Miscellaneous
}
200 Other string functions.
202 \helpref{Trim
}{wxstringtrim
}\\
203 \helpref{Pad
}{wxstringpad
}\\
204 \helpref{Truncate
}{wxstringtruncate
}
206 \membersection{wxWindows
1.xx compatibility functions
}
208 These functions are deprecated, please consider using new wxWindows
2.0
209 functions instead of them (or, even better, std::string compatible variants).
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
}
229 \membersection{std::string compatibility functions
}\label{wxstringat
}
231 The supported functions are only listed here, please see any STL reference for
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);
240 // lib.string.capacity
241 // return the length of the string
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
251 // returns true if the string is empty
255 // return the character at position n
256 char at(size_t n) const;
257 // returns the writable character at position n
260 // lib.string.modifiers
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);
268 // append n copies of ch
269 wxString& append(size_t n, char ch);
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);
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);
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);
290 // delete characters from nStart to nStart + nLen
291 wxString& erase(size_t nStart =
0, size_t nLen = npos);
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);
305 void swap(wxString& str);
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.
312 size_t find(const wxString& str, size_t nStart =
0) const;
314 // find first n characters of sz
315 size_t find(const char* sz, size_t nStart =
0, size_t n = npos) const;
317 // find the first occurrence of character ch after nStart
318 size_t find(char ch, size_t nStart =
0) const;
320 // rfind() family is exactly like find() but works right to left
322 // as find, but from the end
323 size_t rfind(const wxString& str, size_t nStart = npos) const;
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;
331 // find first/last occurrence of any character in the set
334 size_t find_first_of(const wxString& str, size_t nStart =
0) const;
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;
340 size_t find_last_of (const wxString& str, size_t nStart = npos) const;
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;
346 // find first/last occurrence of any character not in the set
349 size_t find_first_not_of(const wxString& str, size_t nStart =
0) const;
351 size_t find_first_not_of(const char* s, size_t nStart =
0) const;
353 size_t find_first_not_of(char ch, size_t nStart =
0) const;
355 size_t find_last_not_of(const wxString& str, size_t nStart=npos) const;
357 size_t find_last_not_of(const char* s, size_t nStart = npos) const;
359 size_t find_last_not_of(char ch, size_t nStart = npos) const;
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.
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;
377 // substring extraction
378 wxString substr(size_t nStart =
0, size_t nLen = npos) const;
381 %%%%% MEMBERS HERE %%%%%
382 \helponly{\insertatlevel{2}{
388 \membersection{wxString::wxString
}\label{wxstringconstruct
}
390 \func{}{wxString
}{\void}
394 \func{}{wxString
}{\param{const wxString\&
}{ x
}}
398 \func{}{wxString
}{\param{char
}{ ch
},
\param{size
\_t}{ n =
1}}
400 Constructs a string of
{\it n
} copies of character
{\it ch
}.
402 \func{}{wxString
}{\param{const char*
}{ psz
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
404 Takes first
{\it nLength
} characters from the C string
{\it psz
}.
405 The default value of wxSTRING
\_MAXLEN means to take all the string.
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
414 \func{}{wxString
}{\param{const unsigned char*
}{ psz
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
416 For compilers using unsigned char: takes first
{\it nLength
} characters from the C string
{\it psz
}.
417 The default value of wxSTRING
\_MAXLEN means take all the string.
419 \func{}{wxString
}{\param{const wchar
\_t*
}{ psz
}}
421 Constructs a string from the wide (UNICODE) string.
423 \membersection{wxString::
\destruct{wxString
}}\label{wxstringdestruct
}
425 \func{}{\destruct{wxString
}}{\void}
427 String destructor. Note that this is not virtual, so wxString must not be inherited from.
429 \membersection{wxString::Alloc
}\label{wxstringalloc
}
431 \func{void
}{Alloc
}{\param{size
\_t}{ nLen
}}
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
439 // delete all vowels from the string
440 wxString DeleteAllVowels(const wxString& original)
444 size_t len = original.length();
448 for ( size_t n =
0; n < len; n++ )
450 if ( strchr("aeuio", tolower(original
[n
])) == NULL )
451 result += original
[n
];
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
}
466 \membersection{wxString::Append
}\label{wxstringappend
}
468 \func{wxString\&
}{Append
}{\param{const char*
}{ psz
}}
470 Concatenates
{\it psz
} to this string, returning a reference to it.
472 \func{wxString\&
}{Append
}{\param{char
}{ ch
},
\param{int
}{ count =
1}}
474 Concatenates character
{\it ch
} to this string,
{\it count
} times, returning a reference
477 \membersection{wxString::AfterFirst
}\label{wxstringafterfirst
}
479 \constfunc{wxString
}{AfterFirst
}{\param{char
}{ ch
}}
481 Gets all the characters after the first occurrence of
{\it ch
}.
482 Returns the empty string if
{\it ch
} is not found.
484 \membersection{wxString::AfterLast
}\label{wxstringafterlast
}
486 \constfunc{wxString
}{AfterLast
}{\param{char
}{ ch
}}
488 Gets all the characters after the last occurrence of
{\it ch
}.
489 Returns the whole string if
{\it ch
} is not found.
491 \membersection{wxString::BeforeFirst
}\label{wxstringbeforefirst
}
493 \constfunc{wxString
}{BeforeFirst
}{\param{char
}{ ch
}}
495 Gets all characters before the first occurrence of
{\it ch
}.
496 Returns the whole string if
{\it ch
} is not found.
498 \membersection{wxString::BeforeLast
}\label{wxstringbeforelast
}
500 \constfunc{wxString
}{BeforeLast
}{\param{char
}{ ch
}}
502 Gets all characters before the last occurrence of
{\it ch
}.
503 Returns the empty string if
{\it ch
} is not found.
505 \membersection{wxString::c
\_str}\label{wxstringcstr
}
507 \constfunc{const char *
}{c
\_str}{\void}
509 Returns a pointer to the string data.
511 \membersection{wxString::Clear
}\label{wxstringclear
}
513 \func{void
}{Clear
}{\void}
515 Empties the string and frees memory occupied by it.
517 See also:
\helpref{Empty
}{wxstringempty
}
519 \membersection{wxString::Cmp
}\label{wxstringcmp
}
521 \constfunc{int
}{Cmp
}{\param{const char*
}{ psz
}}
523 Case-sensitive comparison.
525 Returns a positive value if the string is greater than the argument, zero if
526 it is equal to it or a negative value if it is less than the argument (same semantics
527 as the standard
{\it strcmp()
} function).
529 See also
\helpref{CmpNoCase
}{wxstringcmpnocase
},
\helpref{IsSameAs
}{wxstringissameas
}.
531 \membersection{wxString::CmpNoCase
}\label{wxstringcmpnocase
}
533 \constfunc{int
}{CmpNoCase
}{\param{const char*
}{ psz
}}
535 Case-insensitive comparison.
537 Returns a positive value if the string is greater than the argument, zero if
538 it is equal to it or a negative value if it is less than the argument (same semantics
539 as the standard
{\it strcmp()
} function).
541 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{IsSameAs
}{wxstringissameas
}.
543 \membersection{wxString::CompareTo
}\label{wxstringcompareto
}
546 #define NO_POS ((int)(-
1)) // undefined position
547 enum caseCompare
{exact, ignoreCase
};
550 \constfunc{int
}{CompareTo
}{\param{const char*
}{ psz
},
\param{caseCompare
}{ cmp = exact
}}
552 Case-sensitive comparison. Returns
0 if equal,
1 if greater or -
1 if less.
554 \membersection{wxString::Contains
}\label{wxstringcontains
}
556 \constfunc{bool
}{Contains
}{\param{const wxString\&
}{ str
}}
558 Returns
1 if target appears anyhere in wxString; else
0.
560 \membersection{wxString::Empty
}\label{wxstringempty
}
562 \func{void
}{Empty
}{\void}
564 Makes the string empty, but doesn't free memory occupied by the string.
566 See also:
\helpref{Clear()
}{wxstringclear
}.
568 \membersection{wxString::Find
}\label{wxstringfind
}
570 \constfunc{int
}{Find
}{\param{char
}{ ch
},
\param{bool
}{ fromEnd = FALSE
}}
572 Searches for the given character. Returns the starting index, or -
1 if not found.
574 \constfunc{int
}{Find
}{\param{const char*
}{ sz
}}
576 Searches for the given string. Returns the starting index, or -
1 if not found.
578 \membersection{wxString::First
}\label{wxstringfirst
}
580 \func{size
\_t}{First
}{\param{char
}{ c
}}
582 \constfunc{size
\_t}{First
}{\param{const char*
}{ psz
}}
584 \constfunc{size
\_t}{First
}{\param{const wxString\&
}{ str
}}
586 \constfunc{size
\_t}{First
}{\param{const char
}{ ch
}}
588 Returns the first occurrence of the item.
590 \membersection{wxString::Format
}\label{wxstringformat
}
592 \func{static wxString
}{Format
}{\param{const wxChar
}{*format
},
\param{}{...
}}
594 This static function returns the string containing the result of calling
595 \helpref{Printf
}{wxstringprintf
} with the passed parameters on it.
599 \helpref{FormatV
}{wxstringformatv
},
\helpref{Printf
}{wxstringprintf
}
601 \membersection{wxString::FormatV
}\label{wxstringformatv
}
603 \func{static wxString
}{Format
}{\param{const wxChar
}{*format
},
\param{va
\_list }{argptr
}}
605 This static function returns the string containing the result of calling
606 \helpref{PrintfV
}{wxstringprintfv
} with the passed parameters on it.
610 \helpref{Format
}{wxstringformat
},
\helpref{PrintfV
}{wxstringprintfv
}
612 \membersection{wxString::Freq
}\label{wxstringfreq
}
614 \constfunc{int
}{Freq
}{\param{char
}{ch
}}
616 Returns the number of occurrences of
{\it ch
} in the string.
618 \membersection{wxString::GetChar
}\label{wxstringgetchar
}
620 \constfunc{char
}{GetChar
}{\param{size
\_t}{ n
}}
622 Returns the character at position
{\it n
} (read-only).
624 \membersection{wxString::GetData
}\label{wxstringgetdata
}
626 \constfunc{const char*
}{GetData
}{\void}
628 wxWindows compatibility conversion. Returns a constant pointer to the data in the string.
630 \membersection{wxString::GetWritableChar
}\label{wxstringgetwritablechar
}
632 \func{char\&
}{GetWritableChar
}{\param{size
\_t}{ n
}}
634 Returns a reference to the character at position
{\it n
}.
636 \membersection{wxString::GetWriteBuf
}\label{wxstringgetwritebuf
}
638 \func{char*
}{GetWriteBuf
}{\param{size
\_t}{ len
}}
640 Returns a writable buffer of at least
{\it len
} bytes.
642 Call
\helpref{wxString::UngetWriteBuf
}{wxstringungetwritebuf
} as soon as possible
643 to put the string back into a reasonable state.
645 \membersection{wxString::Index
}\label{wxstringindex
}
647 \constfunc{size
\_t}{Index
}{\param{char
}{ ch
},
\param{int
}{ startpos =
0}}
649 Same as
\helpref{wxString::Find
}{wxstringfind
}.
651 \constfunc{size
\_t}{Index
}{\param{const char*
}{ sz
}}
653 Same as
\helpref{wxString::Find
}{wxstringfind
}.
655 \constfunc{size
\_t}{Index
}{\param{const char*
}{ sz
},
\param{bool
}{ caseSensitive = TRUE
},
\param{bool
}{ fromEnd = FALSE
}}
657 Search the element in the array, starting from either side.
659 If
{\it fromEnd
} is TRUE, reverse search direction.
661 If
{\bf caseSensitive
}, comparison is case sensitive (the default).
663 Returns the index of the first item matched, or NOT
\_FOUND.
666 %\membersection{wxString::insert}\label{wxstringinsert}
668 %\func{void}{insert}{\param{const wxString\&}{ str}, \param{size\_t}{ index}}
670 %Add new element at the given position.
672 \membersection{wxString::IsAscii
}\label{wxstringisascii
}
674 \constfunc{bool
}{IsAscii
}{\void}
676 Returns TRUE if the string is ASCII.
678 \membersection{wxString::IsEmpty
}\label{wxstringisempty
}
680 \constfunc{bool
}{IsEmpty
}{\void}
682 Returns TRUE if the string is NULL.
684 \membersection{wxString::IsNull
}\label{wxstringisnull
}
686 \constfunc{bool
}{IsNull
}{\void}
688 Returns TRUE if the string is NULL (same as IsEmpty).
690 \membersection{wxString::IsNumber
}\label{wxstringisnumber
}
692 \constfunc{bool
}{IsNumber
}{\void}
694 Returns TRUE if the string is a positive or negative integer. Will return FALSE for decimals.
696 \membersection{wxString::IsSameAs
}\label{wxstringissameas
}
698 \constfunc{bool
}{IsSameAs
}{\param{const char*
}{ psz
},
\param{bool
}{ caseSensitive = TRUE
}}
700 Test for string equality, case-sensitive (default) or not.
702 caseSensitive is TRUE by default (case matters).
704 Returns TRUE if strings are equal, FALSE otherwise.
706 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{CmpNoCase
}{wxstringcmpnocase
},
\helpref{IsSameAs
}{wxstringissameas2
}
708 \membersection{wxString::IsSameAs
}\label{wxstringissameas2
}
710 \constfunc{bool
}{IsSameAs
}{\param{char
}{ c
},
\param{bool
}{ caseSensitive = TRUE
}}
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.
715 Returns TRUE if the string is equal to the character, FALSE otherwise.
717 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{CmpNoCase
}{wxstringcmpnocase
},
\helpref{IsSameAs
}{wxstringissameas
}
719 \membersection{wxString::IsWord
}\label{wxstringisword
}
721 \constfunc{bool
}{IsWord
}{\void}
723 Returns TRUE if the string is a word. TODO: what's the definition of a word?
725 \membersection{wxString::Last
}\label{wxstringlast
}
727 \constfunc{char
}{Last
}{\void}
729 Returns the last character.
731 \func{char\&
}{Last
}{\void}
733 Returns a reference to the last character (writable).
735 \membersection{wxString::Left
}\label{wxstringleft
}
737 \constfunc{wxString
}{Left
}{\param{size
\_t}{ count
}}
739 Returns the first
{\it count
} characters.
741 \constfunc{wxString
}{Left
}{\param{char
}{ ch
}}
743 Returns all characters before the first occurrence of
{\it ch
}.
744 Returns the whole string if
{\it ch
} is not found.
746 \membersection{wxString::Len
}\label{wxstringlen
}
748 \constfunc{size
\_t}{Len
}{\void}
750 Returns the length of the string.
752 \membersection{wxString::Length
}\label{wxstringlength
}
754 \constfunc{size
\_t}{Length
}{\void}
756 Returns the length of the string (same as Len).
758 \membersection{wxString::Lower
}\label{wxstringlower
}
760 \constfunc{wxString
}{Lower
}{\void}
762 Returns this string converted to the lower case.
764 \membersection{wxString::LowerCase
}\label{wxstringlowercase
}
766 \func{void
}{LowerCase
}{\void}
770 \membersection{wxString::MakeLower
}\label{wxstringmakelower
}
772 \func{void
}{MakeLower
}{\void}
774 Converts all characters to lower case.
776 \membersection{wxString::MakeUpper
}\label{wxstringmakeupper
}
778 \func{void
}{MakeUpper
}{\void}
780 Converts all characters to upper case.
782 \membersection{wxString::Matches
}\label{wxstringmatches
}
784 \constfunc{bool
}{Matches
}{\param{const char*
}{ szMask
}}
786 Returns TRUE if the string contents matches a mask containing '*' and '?'.
788 \membersection{wxString::Mid
}\label{wxstringmid
}
790 \constfunc{wxString
}{Mid
}{\param{size
\_t}{ first
},
\param{size
\_t}{ count = wxSTRING
\_MAXLEN}}
792 Returns a substring starting at
{\it first
}, with length
{\it count
}, or the rest of
793 the string if
{\it count
} is the default value.
795 \membersection{wxString::Pad
}\label{wxstringpad
}
797 \func{wxString\&
}{Pad
}{\param{size
\_t}{ count
},
\param{char
}{ pad = ' '
},
\param{bool
}{ fromRight = TRUE
}}
799 Adds
{\it count
} copies of
{\it pad
} to the beginning, or to the end of the string (the default).
801 Removes spaces from the left or from the right (default).
803 \membersection{wxString::Prepend
}\label{wxstringprepend
}
805 \func{wxString\&
}{Prepend
}{\param{const wxString\&
}{ str
}}
807 Prepends
{\it str
} to this string, returning a reference to this string.
809 \membersection{wxString::Printf
}\label{wxstringprintf
}
811 \func{int
}{Printf
}{\param{const char*
}{pszFormat
},
\param{}{...
}}
813 Similar to the standard function
{\it sprintf()
}. Returns the number of
814 characters written, or an integer less than zero on error.
816 {\bf NB:
} This function will use a safe version of
{\it vsprintf()
} (usually called
817 {\it vsnprintf()
}) whenever available to always allocate the buffer of correct
818 size. Unfortunately, this function is not available on all platforms and the
819 dangerous
{\it vsprintf()
} will be used then which may lead to buffer overflows.
821 \membersection{wxString::PrintfV
}\label{wxstringprintfv
}
823 \func{int
}{PrintfV
}{\param{const char*
}{pszFormat
},
\param{va
\_list}{ argPtr
}}
825 Similar to vprintf. Returns the number of characters written, or an integer less than zero
828 \membersection{wxString::Remove
}\label{wxstringremove
}
830 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
}}
832 Same as Truncate. Removes the portion from
{\it pos
} to the end of the string.
834 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
},
\param{size
\_t}{ len
}}
836 Removes the
{\it len
} characters from the string, starting at
{\it pos
}.
838 \membersection{wxString::RemoveLast
}\label{wxstringremovelast
}
840 \func{wxString\&
}{RemoveLast
}{\void}
842 Removes the last character.
844 \membersection{wxString::Replace
}\label{wxstringreplace
}
846 \func{size
\_t}{Replace
}{\param{const char*
}{ szOld
},
\param{const char*
}{ szNew
},
\param{bool
}{ replaceAll = TRUE
}}
848 Replace first (or all) occurrences of substring with another one.
850 {\it replaceAll
}: global replace (default), or only the first occurrence.
852 Returns the number of replacements made.
854 \membersection{wxString::Right
}\label{wxstringright
}
856 \constfunc{wxString
}{Right
}{\param{size
\_t}{ count
}}
858 Returns the last
{\it count
} characters.
860 \membersection{wxString::SetChar
}\label{wxstringsetchar
}
862 \func{void
}{SetChar
}{\param{size
\_t}{ n
},
\param{char
}{ch
}}
864 Sets the character at position
{\it n
}.
866 \membersection{wxString::Shrink
}\label{wxstringshrink
}
868 \func{void
}{Shrink
}{\void}
870 Minimizes the string's memory. This can be useful after a call to
871 \helpref{Alloc()
}{wxstringalloc
} if too much memory were preallocated.
873 \membersection{wxString::sprintf
}\label{wxstringsprintf
}
875 \func{void
}{sprintf
}{\param{const char*
}{ fmt
}}
879 \membersection{wxString::StartsWith
}\label{wxstringstartswith
}
881 \constfunc{bool
}{StartsWith
}{\param{const wxChar
}{*prefix
},
\param{wxString
}{*rest = NULL
}}
883 This function can be used to test if the string starts with the specified
884 {\it prefix
}. If it does, the function will return
{\tt TRUE
} and put the rest
885 of the string (i.e. after the prefix) into
{\it rest
} string if it is not
886 {\tt NULL
}. Otherwise, the function returns
{\tt FALSE
} and doesn't modify the
889 \membersection{wxString::Strip
}\label{wxstringstrip
}
892 enum stripType
{leading =
0x1, trailing =
0x2, both =
0x3};
895 \constfunc{wxString
}{Strip
}{\param{stripType
}{ s = trailing
}}
897 Strip characters at the front and/or end. The same as Trim except that it
898 doesn't change this string.
900 \membersection{wxString::SubString
}\label{wxstringsubstring
}
902 \constfunc{wxString
}{SubString
}{\param{size
\_t}{ from
},
\param{size
\_t}{ to
}}
904 Deprecated, use
\helpref{Mid
}{wxstringmid
} instead (but note that parameters
905 have different meaning).
907 Returns the part of the string between the indices
{\it from
} and
{\it to
}
910 \membersection{wxString::ToDouble
}\label{wxstringtodouble
}
912 \constfunc{bool
}{ToDouble
}{\param{double
}{ *val
}}
914 Attempts to convert the string to a floating point number. Returns TRUE on
915 success (the number is stored in the location pointed to by
{\it val
}) or FALSE
916 if the string does not represent such number.
920 \helpref{wxString::ToLong
}{wxstringtolong
},\\
921 \helpref{wxString::ToULong
}{wxstringtoulong
}
923 \membersection{wxString::ToLong
}\label{wxstringtolong
}
925 \constfunc{bool
}{ToLong
}{\param{long
}{ *val
}}
927 Attempts to convert the string to a signed integer. Returns TRUE on success
928 (the number is stored in the location pointed to by
{\it val
}) or FALSE if the
929 string does not represent such number.
933 \helpref{wxString::ToDouble
}{wxstringtodouble
},\\
934 \helpref{wxString::ToULong
}{wxstringtoulong
}
936 \membersection{wxString::ToULong
}\label{wxstringtoulong
}
938 \constfunc{bool
}{ToULong
}{\param{unsigned long
}{ *val
}}
940 Attempts to convert the string to an unsigned integer. Returns TRUE on success
941 (the number is stored in the location pointed to by
{\it val
}) or FALSE if the
942 string does not represent such number.
946 \helpref{wxString::ToDouble
}{wxstringtodouble
},\\
947 \helpref{wxString::ToLong
}{wxstringtolong
}
949 \membersection{wxString::Trim
}\label{wxstringtrim
}
951 \func{wxString\&
}{Trim
}{\param{bool
}{ fromRight = TRUE
}}
953 Removes spaces from the left or from the right (default).
955 \membersection{wxString::Truncate
}\label{wxstringtruncate
}
957 \func{wxString\&
}{Truncate
}{\param{size
\_t}{ len
}}
959 Truncate the string to the given length.
961 \membersection{wxString::UngetWriteBuf
}\label{wxstringungetwritebuf
}
963 \func{void
}{UngetWriteBuf
}{\void}
965 Puts the string back into a reasonable state, after
966 \rtfsp\helpref{wxString::GetWriteBuf
}{wxstringgetwritebuf
} was called.
968 \membersection{wxString::Upper
}\label{wxstringupper
}
970 \constfunc{wxString
}{Upper
}{\void}
972 Returns this string converted to upper case.
974 \membersection{wxString::UpperCase
}\label{wxstringuppercase
}
976 \func{void
}{UpperCase
}{\void}
978 The same as MakeUpper.
980 \membersection{wxString::operator!
}\label{wxstringoperatornot
}
982 \constfunc{bool
}{operator!
}{\void}
984 Empty string is FALSE, so !string will only return TRUE if the string is empty.
985 This allows the tests for NULLness of a
{\it const char *
} pointer and emptyness
986 of the string to look the same in the code and makes it easier to port old code
989 See also
\helpref{IsEmpty()
}{wxstringisempty
}.
991 \membersection{wxString::operator $=$
}\label{wxstringoperatorassign
}
993 \func{wxString\&
}{operator $=$
}{\param{const wxString\&
}{ str
}}
995 \func{wxString\&
}{operator $=$
}{\param{const char*
}{ psz
}}
997 \func{wxString\&
}{operator $=$
}{\param{char
}{ c
}}
999 \func{wxString\&
}{operator $=$
}{\param{const unsigned char*
}{ psz
}}
1001 \func{wxString\&
}{operator $=$
}{\param{const wchar
\_t*
}{ pwz
}}
1003 Assignment: the effect of each operation is the same as for the corresponding
1004 constructor (see
\helpref{wxString constructors
}{wxstringconstruct
}).
1006 \membersection{wxString::operator $+$
}\label{wxstringoperatorplus
}
1008 Concatenation: all these operators return a new strign equal to the sum of the
1011 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1013 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ y
}}
1015 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{char
}{ y
}}
1017 \func{wxString
}{operator $+$
}{\param{const char*
}{ x
},
\param{const wxString\&
}{ y
}}
1019 \membersection{wxString::operator $+=$
}\label{wxstringplusequal
}
1021 \func{void
}{operator $+=$
}{\param{const wxString\&
}{ str
}}
1023 \func{void
}{operator $+=$
}{\param{const char*
}{ psz
}}
1025 \func{void
}{operator $+=$
}{\param{char
}{ c
}}
1027 Concatenation in place: the argument is appended to the string.
1029 \membersection{wxString::operator
[]}\label{wxstringoperatorbracket
}
1031 \func{char\&
}{operator
[]}{\param{size
\_t}{ i
}}
1033 \func{char
}{operator
[]}{\param{size
\_t}{ i
}}
1035 \func{char
}{operator
[]}{\param{int
}{ i
}}
1039 \membersection{wxString::operator ()
}\label{wxstringoperatorparenth
}
1041 \func{wxString
}{operator ()
}{\param{size
\_t}{ start
},
\param{size
\_t}{ len
}}
1043 Same as Mid (substring extraction).
1045 \membersection{wxString::operator
\cinsert}\label{wxstringoperatorout
}
1047 \func{wxString\&
}{operator
\cinsert}{\param{const wxString\&
}{ str
}}
1049 \func{wxString\&
}{operator
\cinsert}{\param{const char*
}{ psz
}}
1051 \func{wxString\&
}{operator
\cinsert}{\param{char
}{ch
}}
1055 \func{wxString\&
}{operator
\cinsert}{\param{int
}{ i
}}
1057 \func{wxString\&
}{operator
\cinsert}{\param{float
}{ f
}}
1059 \func{wxString\&
}{operator
\cinsert}{\param{double
}{ d
}}
1061 These functions work as C++ stream insertion operators: they insert the given
1062 value into the string. Precision or format cannot be set using them, you can use
1063 \helpref{Printf
}{wxstringprintf
} for this.
1065 \membersection{wxString::operator
\cextract}\label{wxstringoperatorin
}
1067 \func{friend istream\&
}{operator
\cextract}{\param{istream\&
}{ is
},
\param{wxString\&
}{ str
}}
1069 Extraction from a stream.
1071 \membersection{wxString::operator const char*
}\label{wxstringoperatorconstcharpt
}
1073 \constfunc{}{operator const char*
}{\void}
1075 Implicit conversion to a C string.
1077 \membersection{Comparison operators
}\label{wxstringcomparison
}
1079 \func{bool
}{operator $==$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1081 \func{bool
}{operator $==$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1083 \func{bool
}{operator $!=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1085 \func{bool
}{operator $!=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1087 \func{bool
}{operator $>$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1089 \func{bool
}{operator $>$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1091 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1093 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1095 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1097 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1099 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1101 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1105 These comparisons are case-sensitive.