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{Cmp
}{wxstringcmp
}\\
103 \helpref{CmpNoCase
}{wxstringcmpnocase
}\\
104 \helpref{IsSameAs
}{wxstringissameas
}\\
105 \helpref{Matches
}{wxstringmatches
}
107 \membersection{Substring extraction
}
109 These functions allow to extract substring from this string. All of them don't
110 modify the original string and return a new string containing the extracted
113 \helpref{Mid
}{wxstringmid
}\\
114 \helpref{operator()
}{wxstringoperatorparenth
}\\
115 \helpref{Left
}{wxstringleft
}\\
116 \helpref{Right
}{wxstringright
}\\
117 \helpref{BeforeFirst
}{wxstringbeforefirst
}\\
118 \helpref{BeforeLast
}{wxstringbeforelast
}\\
119 \helpref{AfterFirst
}{wxstringafterfirst
}\\
120 \helpref{AfterLast
}{wxstringafterlast
}
122 \membersection{Case conversion
}
124 The MakeXXX() variants modify the string in place, while the other functions
125 return a new string which containts the original text converted to the upper or
126 lower case and leave the original string unchanged.
128 \helpref{MakeUpper
}{wxstringmakeupper
}\\
129 \helpref{Upper
}{wxstringupper
}\\
130 \helpref{MakeLower
}{wxstringmakelower
}\\
131 \helpref{Lower
}{wxstringlower
}
133 \membersection{Searching and replacing
}
135 These functions replace the standard
{\it strchr()
} and
{\it strstr()
}
138 \helpref{Find
}{wxstringfind
}\\
139 \helpref{Replace
}{wxstringreplace
}
141 \membersection{Conversion to numbers
}
143 The string provides functions for conversion to signed and unsigned integer and
144 floating point numbers. All three functions take a pointer to the variable to
145 put the numeric value in and return TRUE if the
{\bf entire
} string could be
146 converted to a number.
148 \helpref{ToLong
}{wxstringtolong
}\\
149 \helpref{ToULong
}{wxstringtoulong
}\\
150 \helpref{ToDouble
}{wxstringtodouble
}
152 \membersection{Writing values into the string
}
154 Both formatted versions (
\helpref{Printf
}{wxstringprintf
}) and stream-like
155 insertion operators exist (for basic types only).
157 \helpref{Printf
}{wxstringprintf
}\\
158 \helpref{PrintfV
}{wxstringprintfv
}\\
159 \helpref{operator
\cinsert}{wxstringoperatorout
}
161 \membersection{Memory management
}
163 These are "advanced" functions and they will be needed quite rarily.
164 \helpref{Alloc
}{wxstringalloc
} and
\helpref{Shrink
}{wxstringshrink
} are only
165 interesting for optimization purposes.
166 \helpref{GetWriteBuf
}{wxstringgetwritebuf
} may be very useful when working with
167 some external API which requires the caller to provide a writable buffer, but
168 extreme care should be taken when using it: before performing any other
169 operation on the string
\helpref{UngetWriteBuf
}{wxstringungetwritebuf
} {\bf
172 \helpref{Alloc
}{wxstringalloc
}\\
173 \helpref{Shrink
}{wxstringshrink
}\\
174 \helpref{GetWriteBuf
}{wxstringgetwritebuf
}\\
175 \helpref{UngetWriteBuf
}{wxstringungetwritebuf
}
177 \membersection{Miscellaneous
}
179 Other string functions.
181 \helpref{Trim
}{wxstringtrim
}\\
182 \helpref{Pad
}{wxstringpad
}\\
183 \helpref{Truncate
}{wxstringtruncate
}
185 \membersection{wxWindows
1.xx compatiblity functions
}
187 These functiosn are deprecated, please consider using new wxWindows
2.0
188 functions instead of them (or, even better, std::string compatible variants).
190 \helpref{SubString
}{wxstringsubstring
}\\
191 \helpref{sprintf
}{wxstringsprintf
}\\
192 \helpref{CompareTo
}{wxstringcompareto
}\\
193 \helpref{Length
}{wxstringlength
}\\
194 \helpref{Freq
}{wxstringfreq
}\\
195 \helpref{LowerCase
}{wxstringlowercase
}\\
196 \helpref{UpperCase
}{wxstringuppercase
}\\
197 \helpref{Strip
}{wxstringstrip
}\\
198 \helpref{Index
}{wxstringindex
}\\
199 \helpref{Remove
}{wxstringremove
}\\
200 \helpref{First
}{wxstringfirst
}\\
201 \helpref{Last
}{wxstringlast
}\\
202 \helpref{Contains
}{wxstringcontains
}\\
203 \helpref{IsNull
}{wxstringisnull
}\\
204 \helpref{IsAscii
}{wxstringisascii
}\\
205 \helpref{IsNumber
}{wxstringisnumber
}\\
206 \helpref{IsWord
}{wxstringisword
}
208 \membersection{std::string compatibility functions
}\label{wxstringat
}
210 The supported functions are only listed here, please see any STL reference for
214 // take nLen chars starting at nPos
215 wxString(const wxString& str, size_t nPos, size_t nLen);
216 // take all characters from pStart to pEnd (poor man's iterators)
217 wxString(const void *pStart, const void *pEnd);
219 // lib.string.capacity
220 // return the length of the string
222 // return the length of the string
223 size_t length() const;
224 // return the maximum size of the string
225 size_t max_size() const;
226 // resize the string, filling the space with c if c !=
0
227 void resize(size_t nSize, char ch = '
\0');
228 // delete the contents of the string
230 // returns true if the string is empty
234 // return the character at position n
235 char at(size_t n) const;
236 // returns the writable character at position n
239 // lib.string.modifiers
241 wxString& append(const wxString& str);
242 // append elements str
[pos
], ..., str
[pos+n
]
243 wxString& append(const wxString& str, size_t pos, size_t n);
244 // append first n (or all if n == npos) characters of sz
245 wxString& append(const char *sz, size_t n = npos);
247 // append n copies of ch
248 wxString& append(size_t n, char ch);
250 // same as `this_string = str'
251 wxString& assign(const wxString& str);
252 // same as ` = str
[pos..pos + n
]
253 wxString& assign(const wxString& str, size_t pos, size_t n);
254 // same as `= first n (or all if n == npos) characters of sz'
255 wxString& assign(const char *sz, size_t n = npos);
256 // same as `= n copies of ch'
257 wxString& assign(size_t n, char ch);
259 // insert another string
260 wxString& insert(size_t nPos, const wxString& str);
261 // insert n chars of str starting at nStart (in str)
262 wxString& insert(size_t nPos, const wxString& str, size_t nStart, size_t n);
264 // insert first n (or all if n == npos) characters of sz
265 wxString& insert(size_t nPos, const char *sz, size_t n = npos);
266 // insert n copies of ch
267 wxString& insert(size_t nPos, size_t n, char ch);
269 // delete characters from nStart to nStart + nLen
270 wxString& erase(size_t nStart =
0, size_t nLen = npos);
272 // replaces the substring of length nLen starting at nStart
273 wxString& replace(size_t nStart, size_t nLen, const char* sz);
274 // replaces the substring with nCount copies of ch
275 wxString& replace(size_t nStart, size_t nLen, size_t nCount, char ch);
276 // replaces a substring with another substring
277 wxString& replace(size_t nStart, size_t nLen,
278 const wxString& str, size_t nStart2, size_t nLen2);
279 // replaces the substring with first nCount chars of sz
280 wxString& replace(size_t nStart, size_t nLen,
281 const char* sz, size_t nCount);
284 void swap(wxString& str);
286 // All find() functions take the nStart argument which specifies the
287 // position to start the search on, the default value is
0. All functions
288 // return npos if there were no match.
291 size_t find(const wxString& str, size_t nStart =
0) const;
293 // find first n characters of sz
294 size_t find(const char* sz, size_t nStart =
0, size_t n = npos) const;
296 // find the first occurence of character ch after nStart
297 size_t find(char ch, size_t nStart =
0) const;
299 // rfind() family is exactly like find() but works right to left
301 // as find, but from the end
302 size_t rfind(const wxString& str, size_t nStart = npos) const;
304 // as find, but from the end
305 size_t rfind(const char* sz, size_t nStart = npos,
306 size_t n = npos) const;
307 // as find, but from the end
308 size_t rfind(char ch, size_t nStart = npos) const;
310 // find first/last occurence of any character in the set
313 size_t find_first_of(const wxString& str, size_t nStart =
0) const;
315 size_t find_first_of(const char* sz, size_t nStart =
0) const;
316 // same as find(char, size_t)
317 size_t find_first_of(char c, size_t nStart =
0) const;
319 size_t find_last_of (const wxString& str, size_t nStart = npos) const;
321 size_t find_last_of (const char* s, size_t nStart = npos) const;
322 // same as rfind(char, size_t)
323 size_t find_last_of (char c, size_t nStart = npos) const;
325 // find first/last occurence of any character not in the set
328 size_t find_first_not_of(const wxString& str, size_t nStart =
0) const;
330 size_t find_first_not_of(const char* s, size_t nStart =
0) const;
332 size_t find_first_not_of(char ch, size_t nStart =
0) const;
334 size_t find_last_not_of(const wxString& str, size_t nStart=npos) const;
336 size_t find_last_not_of(const char* s, size_t nStart = npos) const;
338 size_t find_last_not_of(char ch, size_t nStart = npos) const;
340 // All compare functions return a negative, zero or positive value
341 // if the
[sub
]string is less, equal or greater than the compare() argument.
343 // just like strcmp()
344 int compare(const wxString& str) const;
345 // comparison with a substring
346 int compare(size_t nStart, size_t nLen, const wxString& str) const;
347 // comparison of
2 substrings
348 int compare(size_t nStart, size_t nLen,
349 const wxString& str, size_t nStart2, size_t nLen2) const;
350 // just like strcmp()
351 int compare(const char* sz) const;
352 // substring comparison with first nCount characters of sz
353 int compare(size_t nStart, size_t nLen,
354 const char* sz, size_t nCount = npos) const;
356 // substring extraction
357 wxString substr(size_t nStart =
0, size_t nLen = npos) const;
360 %%%%% MEMBERS HERE %%%%%
361 \helponly{\insertatlevel{2}{
367 \membersection{wxString::wxString
}\label{wxstringconstruct
}
369 \func{}{wxString
}{\void}
373 \func{}{wxString
}{\param{const wxString\&
}{ x
}}
377 \func{}{wxString
}{\param{char
}{ ch
},
\param{size
\_t}{ n =
1}}
379 Constructs a string of
{\it n
} copies of character
{\it ch
}.
381 \func{}{wxString
}{\param{const char*
}{ psz
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
383 Takes first
{\it nLength
} characters from the C string
{\it psz
}.
384 The default value of wxSTRING
\_MAXLEN means take all the string.
386 \func{}{wxString
}{\param{const unsigned char*
}{ psz
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
388 For compilers using unsigned char: takes first
{\it nLength
} characters from the C string
{\it psz
}.
389 The default value of wxSTRING
\_MAXLEN means take all the string.
391 \func{}{wxString
}{\param{const wchar
\_t*
}{ psz
}}
393 Constructs a string from the wide (UNICODE) string.
395 \membersection{wxString::
\destruct{wxString
}}\label{wxstringdestruct
}
397 \func{}{\destruct{wxString
}}{\void}
399 String destructor. Note that this is not virtual, so wxString must not be inherited from.
401 \membersection{wxString::Alloc
}\label{wxstringalloc
}
403 \func{void
}{Alloc
}{\param{size
\_t}{ nLen
}}
405 Preallocate enough space for wxString to store
{\it nLen
} characters. This function
406 may be used to increase speed when the string is constructed by repeated
411 // delete all vowels from the string
412 wxString DeleteAllVowels(const wxString& original)
416 size_t len = original.length();
420 for ( size_t n =
0; n < len; n++ )
422 if ( strchr("aeuio", tolower(original
[n
])) == NULL )
423 result += original
[n
];
431 because it will avoid the need of reallocating string memory many times (in case
432 of long strings). Note that it does not set the maximal length of a string - it
433 will still expand if more than
{\it nLen
} characters are stored in it. Also, it
434 does not truncate the existing string (use
435 \helpref{Truncate()
}{wxstringtruncate
} for this) even if its current length is
436 greater than
{\it nLen
}
438 \membersection{wxString::Append
}\label{wxstringappend
}
440 \func{wxString\&
}{Append
}{\param{const char*
}{ psz
}}
442 Concatenates
{\it psz
} to this string, returning a reference to it.
444 \func{wxString\&
}{Append
}{\param{char
}{ ch
},
\param{int
}{ count =
1}}
446 Concatenates character
{\it ch
} to this string,
{\it count
} times, returning a reference
449 \membersection{wxString::AfterFirst
}\label{wxstringafterfirst
}
451 \constfunc{wxString
}{AfterFirst
}{\param{char
}{ ch
}}
453 Gets all the characters after the first occurence of
{\it ch
}.
454 Returns the empty string if
{\it ch
} is not found.
456 \membersection{wxString::AfterLast
}\label{wxstringafterlast
}
458 \constfunc{wxString
}{AfterLast
}{\param{char
}{ ch
}}
460 Gets all the characters after the last occurence of
{\it ch
}.
461 Returns the whole string if
{\it ch
} is not found.
463 \membersection{wxString::BeforeFirst
}\label{wxstringbeforefirst
}
465 \constfunc{wxString
}{BeforeFirst
}{\param{char
}{ ch
}}
467 Gets all characters before the first occurence of
{\it ch
}.
468 Returns the whole string if
{\it ch
} is not found.
470 \membersection{wxString::BeforeLast
}\label{wxstringbeforelast
}
472 \constfunc{wxString
}{BeforeLast
}{\param{char
}{ ch
}}
474 Gets all characters before the last occurence of
{\it ch
}.
475 Returns the empty string if
{\it ch
} is not found.
477 \membersection{wxString::c
\_str}\label{wxstringcstr
}
479 \constfunc{const char *
}{c
\_str}{\void}
481 Returns a pointer to the string data.
483 \membersection{wxString::Clear
}\label{wxstringclear
}
485 \func{void
}{Clear
}{\void}
487 Empties the string and frees memory occupied by it.
489 See also:
\helpref{Empty
}{wxstringempty
}
491 \membersection{wxString::Cmp
}\label{wxstringcmp
}
493 \constfunc{int
}{Cmp
}{\param{const char*
}{ psz
}}
495 Case-sensitive comparison.
497 Returns a positive value if the string is greater than the argument, zero if
498 it si equal to it or negative value if it is less than argument (same semantics
499 as the standard
{\it strcmp()
} function).
501 See also
\helpref{CmpNoCase
}{wxstringcmpnocase
},
\helpref{IsSameAs
}{wxstringissameas
}.
503 \membersection{wxString::CmpNoCase
}\label{wxstringcmpnocase
}
505 \constfunc{int
}{CmpNoCase
}{\param{const char*
}{ psz
}}
507 Case-insensitive comparison.
509 Returns a positive value if the string is greater than the argument, zero if
510 it si equal to it or negative value if it is less than argument (same semantics
511 as the standard
{\it strcmp()
} function).
513 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{IsSameAs
}{wxstringissameas
}.
515 \membersection{wxString::CompareTo
}\label{wxstringcompareto
}
518 #define NO_POS ((int)(-
1)) // undefined position
519 enum caseCompare
{exact, ignoreCase
};
522 \constfunc{int
}{CompareTo
}{\param{const char*
}{ psz
},
\param{caseCompare
}{ cmp = exact
}}
524 Case-sensitive comparison. Returns
0 if equal,
1 if greater or -
1 if less.
526 \membersection{wxString::Contains
}\label{wxstringcontains
}
528 \constfunc{bool
}{Contains
}{\param{const wxString\&
}{ str
}}
530 Returns
1 if target appears anyhere in wxString; else
0.
532 \membersection{wxString::Empty
}\label{wxstringempty
}
534 \func{void
}{Empty
}{\void}
536 Makes the string empty, but doesn't free memory occupied by the string.
538 See also:
\helpref{Clear()
}{wxstringclear
}.
540 \membersection{wxString::Find
}\label{wxstringfind
}
542 \constfunc{int
}{Find
}{\param{char
}{ ch
},
\param{bool
}{ fromEnd = FALSE
}}
544 Searches for the given character. Returns the starting index, or -
1 if not found.
546 \constfunc{int
}{Find
}{\param{const char*
}{ sz
}}
548 Searches for the given string. Returns the starting index, or -
1 if not found.
550 \membersection{wxString::First
}\label{wxstringfirst
}
552 \func{size
\_t}{First
}{\param{char
}{ c
}}
554 \constfunc{size
\_t}{First
}{\param{const char*
}{ psz
}}
556 \constfunc{size
\_t}{First
}{\param{const wxString\&
}{ str
}}
558 \constfunc{size
\_t}{First
}{\param{const char
}{ ch
}}
560 Returns the first occurrence of the item.
562 \membersection{wxString::Freq
}\label{wxstringfreq
}
564 \constfunc{int
}{Frec
}{\param{char
}{ch
}}
566 Returns the number of occurences of
{it ch
} in the string.
568 \membersection{wxString::GetChar
}\label{wxstringgetchar
}
570 \constfunc{char
}{GetChar
}{\param{size
\_t}{ n
}}
572 Returns the character at position
{\it n
} (read-only).
574 \membersection{wxString::GetData
}\label{wxstringgetdata
}
576 \constfunc{const char*
}{GetData
}{\void}
578 wxWindows compatibility conversion. Returns a constant pointer to the data in the string.
580 \membersection{wxString::GetWritableChar
}\label{wxstringgetwritablechar
}
582 \func{char\&
}{GetWritableChar
}{\param{size
\_t}{ n
}}
584 Returns a reference to the character at position
{\it n
}.
586 \membersection{wxString::GetWriteBuf
}\label{wxstringgetwritebuf
}
588 \func{char*
}{GetWriteBuf
}{\param{size
\_t}{ len
}}
590 Returns a writable buffer of at least
{\it len
} bytes.
592 Call
\helpref{wxString::UngetWriteBuf
}{wxstringungetwritebuf
} as soon as possible
593 to put the string back into a reasonable state.
595 \membersection{wxString::Index
}\label{wxstringindex
}
597 \constfunc{size
\_t}{Index
}{\param{char
}{ ch
},
\param{int
}{ startpos =
0}}
599 Same as
\helpref{wxString::Find
}{wxstringfind
}.
601 \constfunc{size
\_t}{Index
}{\param{const char*
}{ sz
}}
603 Same as
\helpref{wxString::Find
}{wxstringfind
}.
605 \constfunc{size
\_t}{Index
}{\param{const char*
}{ sz
},
\param{bool
}{ caseSensitive = TRUE
},
\param{bool
}{ fromEnd = FALSE
}}
607 Search the element in the array, starting from either side.
609 If
{\it fromEnd
} is TRUE, reverse search direction.
611 If
{\bf caseSensitive
}, comparison is case sensitive (the default).
613 Returns the index of the first item matched, or NOT
\_FOUND.
616 %\membersection{wxString::insert}\label{wxstringinsert}
618 %\func{void}{insert}{\param{const wxString\&}{ str}, \param{size\_t}{ index}}
620 %Add new element at the given position.
622 \membersection{wxString::IsAscii
}\label{wxstringisascii
}
624 \constfunc{bool
}{IsAscii
}{\void}
626 Returns TRUE if the string is ASCII.
628 \membersection{wxString::IsEmpty
}\label{wxstringisempty
}
630 \constfunc{bool
}{IsEmpty
}{\void}
632 Returns TRUE if the string is NULL.
634 \membersection{wxString::IsNull
}\label{wxstringisnull
}
636 \constfunc{bool
}{IsNull
}{\void}
638 Returns TRUE if the string is NULL (same as IsEmpty).
640 \membersection{wxString::IsNumber
}\label{wxstringisnumber
}
642 \constfunc{bool
}{IsNumber
}{\void}
644 Returns TRUE if the string is a number.
646 \membersection{wxString::IsSameAs
}\label{wxstringissameas
}
648 \constfunc{bool
}{IsSameAs
}{\param{const char*
}{ psz
},
\param{bool
}{ caseSensitive = TRUE
}}
650 Test for string equality, case-sensitive (default) or not.
652 caseSensitive is TRUE by default (case matters).
654 Returns TRUE if strings are equal, FALSE otherwise.
656 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{CmpNoCase
}{wxstringcmpnocase
},
\helpref{IsSameAs
}{wxstringissameas2
}
658 \membersection{wxString::IsSameAs
}\label{wxstringissameas2
}
660 \constfunc{bool
}{IsSameAs
}{\param{char
}{ c
},
\param{bool
}{ caseSensitive = TRUE
}}
662 Test whether the string is equal to the single character
{\it c
}. The test is
663 case-sensitive if
{\it caseSensitive
} is TRUE (default) or not if it is FALSE.
665 Returns TRUE if the string is equal to the character, FALSE otherwise.
667 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{CmpNoCase
}{wxstringcmpnocase
},
\helpref{IsSameAs
}{wxstringissameas
}
669 \membersection{wxString::IsWord
}\label{wxstringisword
}
671 \constfunc{bool
}{IsWord
}{\void}
673 Returns TRUE if the string is a word. TODO: what's the definition of a word?
675 \membersection{wxString::Last
}\label{wxstringlast
}
677 \constfunc{char
}{Last
}{\void}
679 Returns the last character.
681 \func{char\&
}{Last
}{\void}
683 Returns a reference to the last character (writable).
685 \membersection{wxString::Left
}\label{wxstringleft
}
687 \constfunc{wxString
}{Left
}{\param{size
\_t}{ count
}}
689 Returns the first
{\it count
} characters.
691 \constfunc{wxString
}{Left
}{\param{char
}{ ch
}}
693 Returns all characters before the first occurence of
{\it ch
}.
694 Returns the whole string if
{\it ch
} is not found.
696 \membersection{wxString::Len
}\label{wxstringlen
}
698 \constfunc{size
\_t}{Len
}{\void}
700 Returns the length of the string.
702 \membersection{wxString::Length
}\label{wxstringlength
}
704 \constfunc{size
\_t}{Length
}{\void}
706 Returns the length of the string (same as Len).
708 \membersection{wxString::Lower
}\label{wxstringlower
}
710 \constfunc{wxString
}{Lower
}{\void}
712 Returns this string converted to the lower case.
714 \membersection{wxString::LowerCase
}\label{wxstringlowercase
}
716 \func{void
}{LowerCase
}{\void}
720 \membersection{wxString::MakeLower
}\label{wxstringmakelower
}
722 \func{void
}{MakeLower
}{\void}
724 Converts all characters to lower case.
726 \membersection{wxString::MakeUpper
}\label{wxstringmakeupper
}
728 \func{void
}{MakeUpper
}{\void}
730 Converts all characters to upper case.
732 \membersection{wxString::Matches
}\label{wxstringmatches
}
734 \constfunc{bool
}{Matches
}{\param{const char*
}{ szMask
}}
736 Returns TRUE if the string contents matches a mask containing '*' and '?'.
738 \membersection{wxString::Mid
}\label{wxstringmid
}
740 \constfunc{wxString
}{Mid
}{\param{size
\_t}{ first
},
\param{size
\_t}{ count = wxSTRING
\_MAXLEN}}
742 Returns a substring starting at
{\it first
}, with length
{\it count
}, or the rest of
743 the string if
{\it count
} is the default value.
745 \membersection{wxString::Pad
}\label{wxstringpad
}
747 \func{wxString\&
}{Pad
}{\param{size
\_t}{ count
},
\param{char
}{ pad = ' '
},
\param{bool
}{ fromRight = TRUE
}}
749 Adds
{\it count
} copies of
{\it pad
} to the beginning, or to the end of the string (the default).
751 Removes spaces from the left or from the right (default).
753 \membersection{wxString::Prepend
}\label{wxstringprepend
}
755 \func{wxString\&
}{Prepend
}{\param{const wxString\&
}{ str
}}
757 Prepends
{\it str
} to this string, returning a reference to this string.
759 \membersection{wxString::Printf
}\label{wxstringprintf
}
761 \func{int
}{Printf
}{\param{const char*
}{pszFormat
},
\param{}{...
}}
763 Similar to the standard function
{\it sprintf()
}. Returns the number of
764 characters written, or an integer less than zero on error.
766 {\bf NB:
} This function will use a safe version of
{\it vsprintf()
} (usually called
767 {\it vsnprintf()
}) whenever available to always allocate the buffer of correct
768 size. Unfortunately, this function is not available on all platforms and the
769 dangerous
{\it vsprintf()
} will be used then which may lead to buffer overflows.
771 \membersection{wxString::PrintfV
}\label{wxstringprintfv
}
773 \func{int
}{PrintfV
}{\param{const char*
}{pszFormat
},
\param{va
\_list}{ argPtr
}}
775 Similar to vprintf. Returns the number of characters written, or an integer less than zero
778 \membersection{wxString::Remove
}\label{wxstringremove
}
780 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
}}
782 Same as Truncate. Removes the portion from
{\it pos
} to the end of the string.
784 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
},
\param{size
\_t}{ len
}}
786 Removes the last
{\it len
} characters from the string, starting at
{\it pos
}.
788 \membersection{wxString::RemoveLast
}\label{wxstringremovelast
}
790 \func{wxString\&
}{RemoveLast
}{\void}
792 Removes the last character.
794 \membersection{wxString::Replace
}\label{wxstringreplace
}
796 \func{size
\_t}{Replace
}{\param{const char*
}{ szOld
},
\param{const char*
}{ szNew
},
\param{bool
}{ replaceAll = TRUE
}}
798 Replace first (or all) occurences of substring with another one.
800 {\it replaceAll
}: global replace (default), or only the first occurence.
802 Returns the number of replacements made.
804 \membersection{wxString::Right
}\label{wxstringright
}
806 \constfunc{wxString
}{Right
}{\param{size
\_t}{ count
}}
808 Returns the last
{\it count
} characters.
810 \membersection{wxString::SetChar
}\label{wxstringsetchar
}
812 \func{void
}{SetChar
}{\param{size
\_t}{ n
},
\param{char
}{ch
}}
814 Sets the character at position
{\it n
}.
816 \membersection{wxString::Shrink
}\label{wxstringshrink
}
818 \func{void
}{Shrink
}{\void}
820 Minimizes the string's memory. This can be useful after a call to
821 \helpref{Alloc()
}{wxstringalloc
} if too much memory were preallocated.
823 \membersection{wxString::sprintf
}\label{wxstringsprintf
}
825 \func{void
}{sprintf
}{\param{const char*
}{ fmt
}}
829 \membersection{wxString::Strip
}\label{wxstringstrip
}
832 enum stripType
{leading =
0x1, trailing =
0x2, both =
0x3};
835 \constfunc{wxString
}{Strip
}{\param{stripType
}{ s = trailing
}}
837 Strip characters at the front and/or end. The same as Trim except that it
838 doesn't change this string.
840 \membersection{wxString::SubString
}\label{wxstringsubstring
}
842 \constfunc{wxString
}{SubString
}{\param{size
\_t}{ to
},
\param{size
\_t}{ from
}}
844 Same as
\helpref{Mid
}{wxstringmid
}.
846 \membersection{wxString::ToDouble
}\label{wxstringtodouble
}
848 \cosntfunc{bool
}{To
}{\param{double
}{ *val
}}
850 Attempts to convert the string to a floating point number. Returns TRUE on
851 suceess (the number is stored in the location pointed to by
{\it val
}) or FALSE
852 if the string does not represent such number.
854 \membersection{wxString::ToLong
}\label{wxstringtolong
}
856 \cosntfunc{bool
}{To
}{\param{long
}{ *val
}}
858 Attempts to convert the string to a signed integer. Returns TRUE on suceess
859 (the number is stored in the location pointed to by
{\it val
}) or FALSE if the
860 string does not represent such number.
862 \membersection{wxString::ToULong
}\label{wxstringtoulong
}
864 \cosntfunc{bool
}{To
}{\param{unsigned long
}{ *val
}}
866 Attempts to convert the string to an unsigned integer. Returns TRUE on suceess
867 (the number is stored in the location pointed to by
{\it val
}) or FALSE if the
868 string does not represent such number.
870 \membersection{wxString::Trim
}\label{wxstringtrim
}
872 \func{wxString\&
}{Trim
}{\param{bool
}{ fromRight = TRUE
}}
874 Removes spaces from the left or from the right (default).
876 \membersection{wxString::Truncate
}\label{wxstringtruncate
}
878 \func{wxString\&
}{Truncate
}{\param{size
\_t}{ len
}}
880 Truncate the string to the given length.
882 \membersection{wxString::UngetWriteBuf
}\label{wxstringungetwritebuf
}
884 \func{void
}{UngetWriteBuf
}{\void}
886 Puts the string back into a reasonable state, after
887 \rtfsp\helpref{wxString::GetWriteBuf
}{wxstringgetwritebuf
} was called.
889 \membersection{wxString::Upper
}\label{wxstringupper
}
891 \constfunc{wxString
}{Upper
}{\void}
893 Returns this string converted to upper case.
895 \membersection{wxString::UpperCase
}\label{wxstringuppercase
}
897 \func{void
}{UpperCase
}{\void}
899 The same as MakeUpper.
901 \membersection{wxString::operator!
}\label{wxstringoperatornot
}
903 \constfunc{bool
}{operator!
}{\void}
905 Empty string is FALSE, so !string will only return TRUE if the string is empty.
906 This allows the tests for NULLness of a
{\it const char *
} pointer and emptyness
907 of the string to look the same in the code and makes it easier to port old code
910 See also
\helpref{IsEmpty()
}{wxstringisempty
}.
912 \membersection{wxString::operator $=$
}\label{wxstringoperatorassign
}
914 \func{wxString\&
}{operator $=$
}{\param{const wxString\&
}{ str
}}
916 \func{wxString\&
}{operator $=$
}{\param{const char*
}{ psz
}}
918 \func{wxString\&
}{operator $=$
}{\param{char
}{ c
}}
920 \func{wxString\&
}{operator $=$
}{\param{const unsigned char*
}{ psz
}}
922 \func{wxString\&
}{operator $=$
}{\param{const wchar
\_t*
}{ pwz
}}
924 Assignment: the effect of each operation is the same as for the corresponding
925 constructor (see
\helpref{wxString constructors
}{wxstringconstruct
}).
927 \membersection{operator wxString::$+$
}\label{wxstringoperatorplus
}
929 Concatenation: all these operators return a new strign equal to the sum of the
932 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
934 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ y
}}
936 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{char
}{ y
}}
938 \func{wxString
}{operator $+$
}{\param{const char*
}{ x
},
\param{const wxString\&
}{ y
}}
940 \membersection{wxString::operator $+=$
}\label{wxstringplusequal
}
942 \func{void
}{operator $+=$
}{\param{const wxString\&
}{ str
}}
944 \func{void
}{operator $+=$
}{\param{const char*
}{ psz
}}
946 \func{void
}{operator $+=$
}{\param{char
}{ c
}}
948 Concatenation in place: the argument is appended to the string.
950 \membersection{wxString::operator
[]}\label{wxstringoperatorbracket
}
952 \func{char\&
}{operator
[]}{\param{size
\_t}{ i
}}
954 \func{char
}{operator
[]}{\param{size
\_t}{ i
}}
956 \func{char
}{operator
[]}{\param{int
}{ i
}}
960 \membersection{wxString::operator ()
}\label{wxstringoperatorparenth
}
962 \func{wxString
}{operator ()
}{\param{size
\_t}{ start
},
\param{size
\_t}{ len
}}
964 Same as Mid (substring extraction).
966 \membersection{wxString::operator
\cinsert}\label{wxstringoperatorout
}
968 \func{wxString\&
}{operator
\cinsert}{\param{const wxString\&
}{ str
}}
970 \func{wxString\&
}{operator
\cinsert}{\param{const char*
}{ psz
}}
972 \func{wxString\&
}{operator
\cinsert}{\param{char
}{ch
}}
976 \func{wxString\&
}{operator
\cinsert}{\param{int
}{ i
}}
978 \func{wxString\&
}{operator
\cinsert}{\param{float
}{ f
}}
980 \func{wxString\&
}{operator
\cinsert}{\param{double
}{ d
}}
982 These functions work as C++ stream insertion operators: they insert the given
983 value into the string. Precision or format cannot be set using them, you can use
984 \helpref{Printf
}{wxstringprintf
} for this.
986 \membersection{wxString::operator
\cextract}\label{wxstringoperatorin
}
988 \func{friend istream\&
}{operator
\cextract}{\param{istream\&
}{ is
},
\param{wxString\&
}{ str
}}
990 Extraction from a stream.
992 \membersection{wxString::operator const char*
}\label{wxstringoperatorconstcharpt
}
994 \constfunc{}{operator const char*
}{\void}
996 Implicit conversion to a C string.
998 \membersection{Comparison operators
}\label{wxstringcomparison
}
1000 \func{bool
}{operator $==$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1002 \func{bool
}{operator $==$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1004 \func{bool
}{operator $!=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1006 \func{bool
}{operator $!=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1008 \func{bool
}{operator $>$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1010 \func{bool
}{operator $>$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1012 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1014 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1016 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1018 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1020 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1022 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1026 These comparisons are case-sensitive.