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
}
21 \overview{Overview
}{wxstringoverview
}
23 \latexignore{\rtfignore{\wxheading{Function groups
}}}
25 \membersection{Constructors and assignment operators
}
27 A strign may be constructed either from a C string, (some number of copies of)
28 a single character or a wide (UNICODE) string. For all constructors (except the
29 default which creates an empty string) there is also a corresponding assignment
32 \helpref{wxString
}{wxstringconstruct
}\\
33 \helpref{operator $=$
}{wxstringoperatorassign
}\\
34 \helpref{\destruct{wxString
}}{wxstringdestruct
}
36 \membersection{String length
}
38 These functions return the string length and check whether the string is empty
41 \helpref{Len
}{wxstringlen
}\\
42 \helpref{IsEmpty
}{wxstringisempty
}\\
43 \helpref{operator!
}{wxstringoperatornot
}\\
44 \helpref{Empty
}{wxstringempty
}\\
45 \helpref{Clear
}{wxstringclear
}
47 \membersection{Character access
}
49 Many functions in this section take a character index in the string. As with C
50 strings and/or arrays, the indices start from $
0$, so the first character of a
51 string is string
[$
0$
]. Attempt to access a character beyond the end of the
52 string (which may be even $
0$ if the string is empty) will provocate an assert
53 failure in
\helpref{debug build
}{debuggingoverview
}, but no checks are done in
56 This section also contains both implicit and explicit conversions to C style
57 strings. Although implicit conversion is quite convenient, it is advised to use
58 explicit
\helpref{c
\_str()
}{wxstringcstr
} method for the sake of clarity. Also
59 see
\helpref{overiview
}{wxstringadvices
} for the cases where it is necessary to
62 \helpref{GetChar
}{wxstringgetchar
}\\
63 \helpref{GetWritableChar
}{wxstringgetwritablechar
}\\
64 \helpref{SetChar
}{wxstringsetchar
}\\
65 \helpref{Last
}{wxstringlast
}\\
66 \helpref{operator
[]}{wxstringoperatorbracket
}\\
67 \helpref{c
\_str}{wxstringcstr
}\\
68 \helpref{operator const char*
}{wxstringoperatorconstcharpt
}
70 \membersection{Concatenation
}
72 Anything may be concatenated (appended to) with a string. However, you can't
73 append something to a C string (including literal constants), so to do this it
74 should be converted to a wxString first.
76 \helpref{operator
\cinsert}{wxstringoperatorout
}\\
77 \helpref{operator $+=$
}{wxstringplusequal
}\\
78 \helpref{operator $+$
}{wxstringoperatorplus
}\\
79 \helpref{Append
}{wxstringappend
}\\
80 \helpref{Prepend
}{wxstringprepend
}
82 \membersection{Comparison
}
84 The default comparison function
\helpref{Cmp
}{wxstringcmp
} is case-sensitive and
85 so is the default version of
\helpref{IsSameAs
}{wxstringissameas
}. For case
86 insensitive comparisons you should use
\helpref{CmpNoCase
}{wxstringcmpnocase
} or
87 give a second parameter to IsSameAs. This last function is may be more
88 convenient if only equality of the strings matters because it returns a boolean
89 true value if the strings are the same and not
0 (which is usually FALSE in C)
92 \helpref{Matches
}{wxstringmatches
} is a poor man's regular expression matcher:
93 it only understands '*' and '?' metacharacters in the sense of DOS command line
96 \helpref{Cmp
}{wxstringcmp
}\\
97 \helpref{CmpNoCase
}{wxstringcmpnocase
}\\
98 \helpref{IsSameAs
}{wxstringissameas
}\\
99 \helpref{Matches
}{wxstringmatches
}
101 \membersection{Substring extraction
}
103 These functions allow to extract substring from this string. All of them don't
104 modify the original string and return a new string containing the extracted
107 \helpref{Mid
}{wxstringmid
}\\
108 \helpref{operator()
}{wxstringoperatorparenth
}\\
109 \helpref{Left
}{wxstringleft
}\\
110 \helpref{Right
}{wxstringright
}\\
111 \helpref{BeforeFirst
}{wxstringbeforefirst
}\\
112 \helpref{BeforeLast
}{wxstringbeforelast
}\\
113 \helpref{AfterFirst
}{wxstringafterfirst
}\\
114 \helpref{AfterLast
}{wxstringafterlast
}
116 \membersection{Case conversion
}
118 The MakeXXX() variants modify the string in place, while the other functions
119 return a new string which containts the original text converted to the upper or
120 lower case and leave the original string unchanged.
122 \helpref{MakeUpper
}{wxstringmakeupper
}\\
123 \helpref{Upper
}{wxstringupper
}\\
124 \helpref{MakeLower
}{wxstringmakelower
}\\
125 \helpref{Lower
}{wxstringlower
}
127 \membersection{Searching and replacing
}
129 These functions replace the standard
{\it strchr()
} and
{\it strstr()
}
132 \helpref{Find
}{wxstringfind
}\\
133 \helpref{Replace
}{wxstringreplace
}
135 \membersection{Writing values into the string
}
137 Both formatted versions (
\helpref{Printf
}{wxstringprintf
}) and stream-like
138 insertion operators exist (for basic types only).
140 \helpref{Printf
}{wxstringprintf
}\\
141 \helpref{PrintfV
}{wxstringprintfv
}\\
142 \helpref{operator
\cinsert}{wxstringoperatorout
}
144 \membersection{Memory management
}
146 These are "advanced" functions and they will be needed quite rarily.
147 \helpref{Alloc
}{wxstringalloc
} and
\helpref{Shrink
}{wxstringshrink
} are only
148 interesting for optimization purposes.
149 \helpref{GetWriteBuf
}{wxstringgetwritebuf
} may be very useful when working with
150 some external API which requires the caller to provide a writable buffer, but
151 extreme care should be taken when using it: before performing any other
152 operation on the string
\helpref{UngetWriteBuf
}{wxstringungetwritebuf
} {\bf
155 \helpref{Alloc
}{wxstringalloc
}\\
156 \helpref{Shrink
}{wxstringshrink
}\\
157 \helpref{GetWriteBuf
}{wxstringgetwritebuf
}\\
158 \helpref{UngetWriteBuf
}{wxstringungetwritebuf
}
160 \membersection{Miscellaneous
}
162 Other string functions.
164 \helpref{Trim
}{wxstringtrim
}\\
165 \helpref{Pad
}{wxstringpad
}\\
166 \helpref{Truncate
}{wxstringtruncate
}
168 \membersection{wxWindows
1.xx compatiblity functions
}
170 These functiosn are deprecated, please consider using new wxWindows
2.0
171 functions instead of them (or, even better, std::string compatible variants).
173 \helpref{SubString
}{wxstringsubstring
}\\
174 \helpref{sprintf
}{wxstringsprintf
}\\
175 \helpref{CompareTo
}{wxstringcompareto
}\\
176 \helpref{Length
}{wxstringlength
}\\
177 \helpref{Freq
}{wxstringfreq
}\\
178 \helpref{LowerCase
}{wxstringlowercase
}\\
179 \helpref{UpperCase
}{wxstringuppercase
}\\
180 \helpref{Strip
}{wxstringstrip
}\\
181 \helpref{Index
}{wxstringindex
}\\
182 \helpref{Remove
}{wxstringremove
}\\
183 \helpref{First
}{wxstringfirst
}\\
184 \helpref{Last
}{wxstringlast
}\\
185 \helpref{Contains
}{wxstringcontains
}\\
186 \helpref{IsNull
}{wxstringisnull
}\\
187 \helpref{IsAscii
}{wxstringisascii
}\\
188 \helpref{IsNumber
}{wxstringisnumber
}\\
189 \helpref{IsWord
}{wxstringisword
}
191 \membersection{std::string compatibility functions
}
193 The supported functions are only listed here, please see any STL reference for
197 // take nLen chars starting at nPos
198 wxString(const wxString& str, size_t nPos, size_t nLen);
199 // take all characters from pStart to pEnd (poor man's iterators)
200 wxString(const void *pStart, const void *pEnd);
202 // lib.string.capacity
203 // return the length of the string
205 // return the length of the string
206 size_t length() const;
207 // return the maximum size of the string
208 size_t max_size() const;
209 // resize the string, filling the space with c if c !=
0
210 void resize(size_t nSize, char ch = '
\0');
211 // delete the contents of the string
213 // returns true if the string is empty
217 // return the character at position n
218 char at(size_t n) const;
219 // returns the writable character at position n
222 // lib.string.modifiers
224 wxString& append(const wxString& str);
225 // append elements str
[pos
], ..., str
[pos+n
]
226 wxString& append(const wxString& str, size_t pos, size_t n);
227 // append first n (or all if n == npos) characters of sz
228 wxString& append(const char *sz, size_t n = npos);
230 // append n copies of ch
231 wxString& append(size_t n, char ch);
233 // same as `this_string = str'
234 wxString& assign(const wxString& str);
235 // same as ` = str
[pos..pos + n
]
236 wxString& assign(const wxString& str, size_t pos, size_t n);
237 // same as `= first n (or all if n == npos) characters of sz'
238 wxString& assign(const char *sz, size_t n = npos);
239 // same as `= n copies of ch'
240 wxString& assign(size_t n, char ch);
242 // insert another string
243 wxString& insert(size_t nPos, const wxString& str);
244 // insert n chars of str starting at nStart (in str)
245 wxString& insert(size_t nPos, const wxString& str, size_t nStart, size_t n);
247 // insert first n (or all if n == npos) characters of sz
248 wxString& insert(size_t nPos, const char *sz, size_t n = npos);
249 // insert n copies of ch
250 wxString& insert(size_t nPos, size_t n, char ch);
252 // delete characters from nStart to nStart + nLen
253 wxString& erase(size_t nStart =
0, size_t nLen = npos);
255 // replaces the substring of length nLen starting at nStart
256 wxString& replace(size_t nStart, size_t nLen, const char* sz);
257 // replaces the substring with nCount copies of ch
258 wxString& replace(size_t nStart, size_t nLen, size_t nCount, char ch);
259 // replaces a substring with another substring
260 wxString& replace(size_t nStart, size_t nLen,
261 const wxString& str, size_t nStart2, size_t nLen2);
262 // replaces the substring with first nCount chars of sz
263 wxString& replace(size_t nStart, size_t nLen,
264 const char* sz, size_t nCount);
267 void swap(wxString& str);
269 // All find() functions take the nStart argument which specifies the
270 // position to start the search on, the default value is
0. All functions
271 // return npos if there were no match.
274 size_t find(const wxString& str, size_t nStart =
0) const;
276 // find first n characters of sz
277 size_t find(const char* sz, size_t nStart =
0, size_t n = npos) const;
279 // find the first occurence of character ch after nStart
280 size_t find(char ch, size_t nStart =
0) const;
282 // rfind() family is exactly like find() but works right to left
284 // as find, but from the end
285 size_t rfind(const wxString& str, size_t nStart = npos) const;
287 // as find, but from the end
288 size_t rfind(const char* sz, size_t nStart = npos,
289 size_t n = npos) const;
290 // as find, but from the end
291 size_t rfind(char ch, size_t nStart = npos) const;
293 // find first/last occurence of any character in the set
296 size_t find_first_of(const wxString& str, size_t nStart =
0) const;
298 size_t find_first_of(const char* sz, size_t nStart =
0) const;
299 // same as find(char, size_t)
300 size_t find_first_of(char c, size_t nStart =
0) const;
302 size_t find_last_of (const wxString& str, size_t nStart = npos) const;
304 size_t find_last_of (const char* s, size_t nStart = npos) const;
305 // same as rfind(char, size_t)
306 size_t find_last_of (char c, size_t nStart = npos) const;
308 // find first/last occurence of any character not in the set
311 size_t find_first_not_of(const wxString& str, size_t nStart =
0) const;
313 size_t find_first_not_of(const char* s, size_t nStart =
0) const;
315 size_t find_first_not_of(char ch, size_t nStart =
0) const;
317 size_t find_last_not_of(const wxString& str, size_t nStart=npos) const;
319 size_t find_last_not_of(const char* s, size_t nStart = npos) const;
321 size_t find_last_not_of(char ch, size_t nStart = npos) const;
323 // All compare functions return a negative, zero or positive value
324 // if the
[sub
]string is less, equal or greater than the compare() argument.
326 // just like strcmp()
327 int compare(const wxString& str) const;
328 // comparison with a substring
329 int compare(size_t nStart, size_t nLen, const wxString& str) const;
330 // comparison of
2 substrings
331 int compare(size_t nStart, size_t nLen,
332 const wxString& str, size_t nStart2, size_t nLen2) const;
333 // just like strcmp()
334 int compare(const char* sz) const;
335 // substring comparison with first nCount characters of sz
336 int compare(size_t nStart, size_t nLen,
337 const char* sz, size_t nCount = npos) const;
339 // substring extraction
340 wxString substr(size_t nStart =
0, size_t nLen = npos) const;
343 %%%%% MEMBERS HERE %%%%%
344 \helponly{\insertatlevel{2}{
350 \membersection{wxString::wxString
}\label{wxstringconstruct
}
352 \func{}{wxString
}{\void}
356 \func{}{wxString
}{\param{const wxString\&
}{ x
}}
360 \func{}{wxString
}{\param{char
}{ ch
},
\param{size
\_t}{ n =
1}}
362 Constructs a string of
{\it n
} copies of character
{\it ch
}.
364 \func{}{wxString
}{\param{const char*
}{ psz
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
366 Takes first
{\it nLength
} characters from the C string
{\it psz
}.
367 The default value of wxSTRING
\_MAXLEN means take all the string.
369 \func{}{wxString
}{\param{const unsigned char*
}{ psz
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
371 For compilers using unsigned char: takes first
{\it nLength
} characters from the C string
{\it psz
}.
372 The default value of wxSTRING
\_MAXLEN means take all the string.
374 \func{}{wxString
}{\param{const wchar
\_t*
}{ psz
}}
376 Constructs a string from the wide (UNICODE) string.
378 \membersection{wxString::
\destruct{wxString
}}\label{wxstringdestruct
}
380 \func{}{\destruct{wxString
}}{\void}
382 String destructor. Note that this is not virtual, so wxString must not be inherited from.
384 \membersection{wxString::Alloc
}\label{wxstringalloc
}
386 \func{void
}{Alloc
}{\param{size
\_t}{ nLen
}}
388 Preallocate enough space for wxString to store
{\it nLen
} characters. This function
389 may be used to increase speed when the string is constructed by repeated
394 // delete all vowels from the string
395 wxString DeleteAllVowels(const wxString& original)
399 size_t len = original.length();
403 for ( size_t n =
0; n < len; n++ )
405 if ( strchr("aeuio", tolower(original
[n
])) == NULL )
406 result += original
[n
];
414 because it will avoid the need of reallocating string memory many times (in case
415 of long strings). Note that it does not set the maximal length of a string - it
416 will still expand if more than
{\it nLen
} characters are stored in it. Also, it
417 does not truncate the existing string (use
418 \helpref{Truncate()
}{wxstringtruncate
} for this) even if its current length is
419 greater than
{\it nLen
}
421 \membersection{wxString::Append
}\label{wxstringappend
}
423 \func{wxString\&
}{Append
}{\param{const char*
}{ psz
}}
425 Concatenates
{\it psz
} to this string, returning a reference to it.
427 \func{wxString\&
}{Append
}{\param{char
}{ ch
},
\param{int
}{ count =
1}}
429 Concatenates character
{\it ch
} to this string,
{\it count
} times, returning a reference
432 \membersection{wxString::AfterFirst
}\label{wxstringafterfirst
}
434 \constfunc{wxString
}{AfterFirst
}{\param{char
}{ ch
}}
436 Gets all the characters after the first occurence of
{\it ch
}.
437 Returns the empty string if
{\it ch
} is not found.
439 \membersection{wxString::AfterLast
}\label{wxstringafterlast
}
441 \constfunc{wxString
}{AfterLast
}{\param{char
}{ ch
}}
443 Gets all the characters after the last occurence of
{\it ch
}.
444 Returns the whole string if
{\it ch
} is not found.
446 \membersection{wxString::BeforeFirst
}\label{wxstringbeforefirst
}
448 \constfunc{wxString
}{BeforeFirst
}{\param{char
}{ ch
}}
450 Gets all characters before the first occurence of
{\it ch
}.
451 Returns the whole string if
{\it ch
} is not found.
453 \membersection{wxString::BeforeLast
}\label{wxstringbeforelast
}
455 \constfunc{wxString
}{BeforeLast
}{\param{char
}{ ch
}}
457 Gets all characters before the last occurence of
{\it ch
}.
458 Returns the empty string if
{\it ch
} is not found.
460 \membersection{wxString::Cmp
}\label{wxstringcmp
}
462 \constfunc{int
}{Cmp
}{\param{const char*
}{ psz
}}
464 Case-sensitive comparison.
466 Returns a positive value if the string is greater than the argument, zero if
467 it si equal to it or negative value if it is less than argument (same semantics
468 as the standard
{\it strcmp()
} function).
470 See also
\helpref{CmpNoCase
}{wxstringcmpnocase
},
\helpref{IsSameAs
}{wxstringissameas
}.
472 \membersection{wxString::CmpNoCase
}\label{wxstringcmpnocase
}
474 \constfunc{int
}{CmpNoCase
}{\param{const char*
}{ psz
}}
476 Case-insensitive comparison.
478 Returns a positive value if the string is greater than the argument, zero if
479 it si equal to it or negative value if it is less than argument (same semantics
480 as the standard
{\it strcmp()
} function).
482 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{IsSameAs
}{wxstringissameas
}.
484 \membersection{wxString::CompareTo
}\label{wxstringcompareto
}
487 #define NO_POS ((int)(-
1)) // undefined position
488 enum caseCompare
{exact, ignoreCase
};
491 \constfunc{int
}{CompareTo
}{\param{const char*
}{ psz
},
\param{caseCompare
}{ cmp = exact
}}
493 Case-sensitive comparison. Returns
0 if equal,
1 if greater or -
1 if less.
495 \membersection{wxString::Contains
}\label{wxstringcontains
}
497 \constfunc{bool
}{Contains
}{\param{const wxString\&
}{ str
}}
499 Returns
1 if target appears anyhere in wxString; else
0.
501 \membersection{wxString::Empty
}\label{wxstringempty
}
503 \func{void
}{Empty
}{\void}
505 Reinitializes the string and frees the data.
507 \membersection{wxString::Find
}\label{wxstringfind
}
509 \constfunc{int
}{Find
}{\param{char
}{ ch
},
\param{bool
}{ fromEnd = FALSE
}}
511 Searches for the given character. Returns the starting index, or -
1 if not found.
513 \constfunc{int
}{Find
}{\param{const char*
}{ sz
}}
515 Searches for the given string. Returns the starting index, or -
1 if not found.
517 \membersection{wxString::First
}\label{wxstringfirst
}
519 \func{size
\_t}{First
}{\param{char
}{ c
}}
521 \constfunc{size
\_t}{First
}{\param{const char*
}{ psz
}}
523 \constfunc{size
\_t}{First
}{\param{const wxString\&
}{ str
}}
525 \constfunc{size
\_t}{First
}{\param{const char
}{ ch
}}
527 Returns the first occurrence of the item.
529 \membersection{wxString::Freq
}\label{wxstringfreq
}
531 \constfunc{int
}{Frec
}{\param{char
}{ch
}}
533 Returns the number of occurences of
{it ch
} in the string.
535 \membersection{wxString::GetChar
}\label{wxstringgetchar
}
537 \constfunc{char
}{GetChar
}{\param{size
\_t}{ n
}}
539 Returns the character at position
{\it n
} (read-only).
541 \membersection{wxString::GetData
}\label{wxstringgetdata
}
543 \constfunc{const char*
}{GetData
}{\void}
545 wxWindows compatibility conversion. Returns a constant pointer to the data in the string.
547 \membersection{wxString::GetWritableChar
}\label{wxstringgetwritablechar
}
549 \func{char\&
}{GetWritableChar
}{\param{size
\_t}{ n
}}
551 Returns a reference to the character at position
{\it n
}.
553 \membersection{wxString::GetWriteBuf
}\label{wxstringgetwritebuf
}
555 \func{char*
}{GetWriteBuf
}{\param{size
\_t}{ len
}}
557 Returns a writable buffer of at least
{\it len
} bytes.
559 Call
\helpref{wxString::UngetWriteBuf
}{wxstringungetwritebuf
} as soon as possible
560 to put the string back into a reasonable state.
562 \membersection{wxString::Index
}\label{wxstringindex
}
564 \constfunc{size
\_t}{Index
}{\param{char
}{ ch
},
\param{int
}{ startpos =
0}}
566 Same as
\helpref{wxString::Find
}{wxstringfind
}.
568 \constfunc{size
\_t}{Index
}{\param{const char*
}{ sz
}}
570 Same as
\helpref{wxString::Find
}{wxstringfind
}.
572 \constfunc{size
\_t}{Index
}{\param{const char*
}{ sz
},
\param{bool
}{ caseSensitive = TRUE
},
\param{bool
}{ fromEnd = FALSE
}}
574 Search the element in the array, starting from either side.
576 If
{\it fromEnd
} is TRUE, reverse search direction.
578 If
{\bf caseSensitive
}, comparison is case sensitive (the default).
580 Returns the index of the first item matched, or NOT
\_FOUND.
583 %\membersection{wxString::insert}\label{wxstringinsert}
585 %\func{void}{insert}{\param{const wxString\&}{ str}, \param{size\_t}{ index}}
587 %Add new element at the given position.
589 \membersection{wxString::IsAscii
}\label{wxstringisascii
}
591 \constfunc{bool
}{IsAscii
}{\void}
593 Returns TRUE if the string is ASCII.
595 \membersection{wxString::IsEmpty
}\label{wxstringisempty
}
597 \constfunc{bool
}{IsEmpty
}{\void}
599 Returns TRUE if the string is NULL.
601 \membersection{wxString::IsNull
}\label{wxstringisnull
}
603 \constfunc{bool
}{IsNull
}{\void}
605 Returns TRUE if the string is NULL (same as IsEmpty).
607 \membersection{wxString::IsNumber
}\label{wxstringisnumber
}
609 \constfunc{bool
}{IsNumber
}{\void}
611 Returns TRUE if the string is a number.
613 \membersection{wxString::IsSameAs
}\label{wxstringissameas
}
615 \constfunc{bool
}{IsSameAs
}{\param{const char*
}{ psz
},
\param{bool
}{ caseSensitive = TRUE
}}
617 Test for string equality, case-sensitive (default) or not.
619 caseSensitive is TRUE by default (case matters).
621 Returns TRUE if strings are equal, FALSE otherwise.
623 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{CmpNoCase
}{wxstringcmpnocase
}.
625 \membersection{wxString::IsWord
}\label{wxstringisword
}
627 \constfunc{bool
}{IsWord
}{\void}
629 Returns TRUE if the string is a word. TODO: what's the definition of a word?
631 \membersection{wxString::Last
}\label{wxstringlast
}
633 \constfunc{char
}{Last
}{\void}
635 Returns the last character.
637 \func{char\&
}{Last
}{\void}
639 Returns a reference to the last character (writable).
641 \membersection{wxString::Left
}\label{wxstringleft
}
643 \constfunc{wxString
}{Left
}{\param{size
\_t}{ count
}}
645 Returns the first
{\it count
} characters.
647 \constfunc{wxString
}{Left
}{\param{char
}{ ch
}}
649 Returns all characters before the first occurence of
{\it ch
}.
650 Returns the whole string if
{\it ch
} is not found.
652 \membersection{wxString::Len
}\label{wxstringlen
}
654 \constfunc{size
\_t}{Len
}{\void}
656 Returns the length of the string.
658 \membersection{wxString::Length
}\label{wxstringlength
}
660 \constfunc{size
\_t}{Length
}{\void}
662 Returns the length of the string (same as Len).
664 \membersection{wxString::Lower
}\label{wxstringlower
}
666 \constfunc{wxString
}{Lower
}{\void}
668 Returns this string converted to the lower case.
670 \membersection{wxString::LowerCase
}\label{wxstringlowercase
}
672 \func{void
}{LowerCase
}{\void}
676 \membersection{wxString::MakeLower
}\label{wxstringmakelower
}
678 \func{void
}{MakeLower
}{\void}
680 Converts all characters to lower case.
682 \membersection{wxString::MakeUpper
}\label{wxstringmakeupper
}
684 \func{void
}{MakeUpper
}{\void}
686 Converts all characters to upper case.
688 \membersection{wxString::Matches
}\label{wxstringmatches
}
690 \constfunc{bool
}{Matches
}{\param{const char*
}{ szMask
}}
692 Returns TRUE if the string contents matches a mask containing '*' and '?'.
694 \membersection{wxString::Mid
}\label{wxstringmid
}
696 \constfunc{wxString
}{Mid
}{\param{size
\_t}{ first
},
\param{size
\_t}{ count = wxSTRING
\_MAXLEN}}
698 Returns a substring starting at
{\it first
}, with length
{\it count
}, or the rest of
699 the string if
{\it count
} is the default value.
701 \membersection{wxString::Pad
}\label{wxstringpad
}
703 \func{wxString\&
}{Pad
}{\param{size
\_t}{ count
},
\param{char
}{ pad = ' '
},
\param{bool
}{ fromRight = TRUE
}}
705 Adds
{\it count
} copies of
{\it pad
} to the beginning, or to the end of the string (the default).
707 Removes spaces from the left or from the right (default).
709 \membersection{wxString::Prepend
}\label{wxstringprepend
}
711 \func{wxString\&
}{Prepend
}{\param{const wxString\&
}{ str
}}
713 Prepends
{\it str
} to this string, returning a reference to this string.
715 \membersection{wxString::Printf
}\label{wxstringprintf
}
717 \func{int
}{Printf
}{\param{const char*
}{pszFormat
},
\param{}{...
}}
719 Similar to the standard function
{\it sprintf()
}. Returns the number of
720 characters written, or an integer less than zero on error.
722 {\bf NB:
} This function will use a safe version of
{\it vsprintf()
} (usually called
723 {\it vsnprintf()
}) whenever available to always allocate the buffer of correct
724 size. Unfortunately, this function is not available on all platforms and the
725 dangerous
{\it vsprintf()
} will be used then which may lead to buffer overflows.
727 \membersection{wxString::PrintfV
}\label{wxstringprintfv
}
729 \func{int
}{PrintfV
}{\param{const char*
}{pszFormat
},
\param{va
\_list}{ argPtr
}}
731 Similar to vprintf. Returns the number of characters written, or an integer less than zero
734 \membersection{wxString::Remove
}\label{wxstringremove
}
736 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
}}
738 Same as Truncate. Removes the portion from
{\it pos
} to the end of the string.
740 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
},
\param{size
\_t}{ len
}}
742 Removes the last
{\it len
} characters from the string, starting at
{\it pos
}.
744 \membersection{wxString::RemoveLast
}\label{wxstringremovelast
}
746 \func{wxString\&
}{RemoveLast
}{\void}
748 Removes the last character.
750 \membersection{wxString::Replace
}\label{wxstringreplace
}
752 \func{size
\_t}{Replace
}{\param{const char*
}{ szOld
},
\param{const char*
}{ szNew
},
\param{bool
}{ replaceAll = TRUE
}}
754 Replace first (or all) occurences of substring with another one.
756 {\it replaceAll
}: global replace (default), or only the first occurence.
758 Returns the number of replacements made.
760 \membersection{wxString::Right
}\label{wxstringright
}
762 \constfunc{wxString
}{Right
}{\param{size
\_t}{ count
}}
764 Returns the last
{\it count
} characters.
766 \constfunc{wxString
}{Right
}{\param{char
}{ ch
}}
768 Returns all characters after the last occurence of
{\it ch
}.
769 Returns the whole string if
{\it ch
} is not found.
771 \membersection{wxString::SetChar
}\label{wxstringsetchar
}
773 \func{void
}{SetChar
}{\param{size
\_t}{ n
},
\param{char
}{ch
}}
775 Sets the character at position
{\it n
}.
777 \membersection{wxString::Shrink
}\label{wxstringshrink
}
779 \func{void
}{Shrink
}{\void}
781 Minimizes the string's memory. This can be useful after a call to
782 \helpref{Alloc()
}{wxstringalloc
} if too much memory were preallocated.
784 \membersection{wxString::sprintf
}\label{wxstringsprintf
}
786 \func{void
}{sprintf
}{\param{const char*
}{ fmt
}}
790 \membersection{wxString::Strip
}\label{wxstringstrip
}
793 enum stripType
{leading =
0x1, trailing =
0x2, both =
0x3};
796 \constfunc{wxString
}{Strip
}{\param{stripType
}{ s = trailing
}}
798 Strip characters at the front and/or end. The same as Trim except that it
799 doesn't change this string.
801 \membersection{wxString::SubString
}\label{wxstringsubstring
}
803 \constfunc{wxString
}{SubString
}{\param{size
\_t}{ to
},
\param{size
\_t}{ from
}}
805 Same as
\helpref{Mid
}{wxstringmid
}.
807 \membersection{wxString::Trim
}\label{wxstringtrim
}
809 \func{wxString\&
}{Trim
}{\param{bool
}{ fromRight = TRUE
}}
811 Removes spaces from the left or from the right (default).
813 \membersection{wxString::Truncate
}\label{wxstringtruncate
}
815 \func{wxString\&
}{Truncate
}{\param{size
\_t}{ len
}}
817 Truncate the string to the given length.
819 \membersection{wxString::UngetWriteBuf
}\label{wxstringungetwritebuf
}
821 \func{void
}{UngetWriteBuf
}{\void}
823 Puts the string back into a reasonable state, after
824 \rtfsp\helpref{wxString::GetWriteBuf
}{wxstringgetwritebuf
} was called.
826 \membersection{wxString::Upper
}\label{wxstringupper
}
828 \constfunc{wxString
}{Upper
}{\void}
830 Returns this string converted to upper case.
832 \membersection{wxString::UpperCase
}\label{wxstringuppercase
}
834 \func{void
}{UpperCase
}{\void}
836 The same as MakeUpper.
838 \membersection{wxString::operator!
}\label{wxstringoperatornot
}
840 \constfunc{bool
}{operator!
}{\void}
842 Empty string is FALSE, so !string will only return TRUE if the string is empty.
843 This allows the tests for NULLness of a
{\it const char *
} pointer and emptyness
844 of the string to look the same in the code and makes it easier to port old code
847 See also
\helpref{IsEmpty()
}{wxstringisempty
}.
849 \membersection{wxString::operator $=$
}\label{wxstringoperatorassign
}
851 \func{wxString\&
}{operator $=$
}{\param{const wxString\&
}{ str
}}
853 \func{wxString\&
}{operator $=$
}{\param{const char*
}{ psz
}}
855 \func{wxString\&
}{operator $=$
}{\param{char
}{ c
}}
857 \func{wxString\&
}{operator $=$
}{\param{const unsigned char*
}{ psz
}}
859 \func{wxString\&
}{operator $=$
}{\param{const wchar
\_t*
}{ pwz
}}
861 Assignment: the effect of each operation is the same as for the corresponding
862 constructor (see
\helpref{wxString constructors
}{wxstringconstruct
}).
864 \membersection{operator wxString::$+$
}\label{wxstringoperatorplus
}
866 Concatenation: all these operators return a new strign equal to the sum of the
869 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
871 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ y
}}
873 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{char
}{ y
}}
875 \func{wxString
}{operator $+$
}{\param{const char*
}{ x
},
\param{const wxString\&
}{ y
}}
877 \membersection{wxString::operator $+=$
}\label{wxstringplusequal
}
879 \func{void
}{operator $+=$
}{\param{const wxString\&
}{ str
}}
881 \func{void
}{operator $+=$
}{\param{const char*
}{ psz
}}
883 \func{void
}{operator $+=$
}{\param{char
}{ c
}}
885 Concatenation in place: the argument is appended to the string.
887 \membersection{wxString::operator
[]}\label{wxstringoperatorbracket
}
889 \func{char\&
}{operator
[]}{\param{size
\_t}{ i
}}
891 \func{char
}{operator
[]}{\param{size
\_t}{ i
}}
893 \func{char
}{operator
[]}{\param{int
}{ i
}}
897 \membersection{wxString::operator ()
}\label{wxstringoperatorparenth
}
899 \func{wxString
}{operator ()
}{\param{size
\_t}{ start
},
\param{size
\_t}{ len
}}
901 Same as Mid (substring extraction).
903 \membersection{wxString::operator
\cinsert}\label{wxstringoperatorout
}
905 \func{wxString\&
}{operator
\cinsert}{\param{const wxString\&
}{ str
}}
907 \func{wxString\&
}{operator
\cinsert}{\param{const char*
}{ psz
}}
909 \func{wxString\&
}{operator
\cinsert}{\param{char
}{ch
}}
913 \func{wxString\&
}{operator
\cinsert}{\param{int
}{ i
}}
915 \func{wxString\&
}{operator
\cinsert}{\param{float
}{ f
}}
917 \func{wxString\&
}{operator
\cinsert}{\param{double
}{ d
}}
919 These functions work as C++ stream insertion operators: they insert the given
920 value into the string. Precision or format cannot be set using them, you can use
921 \helpref{Printf
}{wxstringprintf
} for this.
923 \membersection{wxString::operator
\cextract}\label{wxstringoperatorin
}
925 \func{friend istream\&
}{operator
\cextract}{\param{istream\&
}{ is
},
\param{wxString\&
}{ str
}}
927 Extraction from a stream.
929 \membersection{wxString::operator const char*
}\label{wxstringoperatorconstcharpt
}
931 \constfunc{}{operator const char*
}{\void}
933 Implicit conversion to a C string.
935 \membersection{Comparison operators
}\label{wxstringcomparison
}
937 \func{bool
}{operator $==$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
939 \func{bool
}{operator $==$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
941 \func{bool
}{operator $!=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
943 \func{bool
}{operator $!=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
945 \func{bool
}{operator $>$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
947 \func{bool
}{operator $>$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
949 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
951 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
953 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
955 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
957 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
959 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
963 These comparisons are case-sensitive.