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{overview
}{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
}\label{wxstringat
}
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::c
\_str}\label{wxstringcstr
}
462 \constfunc{const char *
}{c
\_str}{\void}
464 Returns a pointer to the string data.
466 \membersection{wxString::Clear
}\label{wxstringclear
}
468 \func{void
}{Clear
}{\void}
470 Empties the string and frees memory occupied by it.
472 See also:
\helpref{Empty
}{wxstringempty
}
474 \membersection{wxString::Cmp
}\label{wxstringcmp
}
476 \constfunc{int
}{Cmp
}{\param{const char*
}{ psz
}}
478 Case-sensitive comparison.
480 Returns a positive value if the string is greater than the argument, zero if
481 it si equal to it or negative value if it is less than argument (same semantics
482 as the standard
{\it strcmp()
} function).
484 See also
\helpref{CmpNoCase
}{wxstringcmpnocase
},
\helpref{IsSameAs
}{wxstringissameas
}.
486 \membersection{wxString::CmpNoCase
}\label{wxstringcmpnocase
}
488 \constfunc{int
}{CmpNoCase
}{\param{const char*
}{ psz
}}
490 Case-insensitive comparison.
492 Returns a positive value if the string is greater than the argument, zero if
493 it si equal to it or negative value if it is less than argument (same semantics
494 as the standard
{\it strcmp()
} function).
496 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{IsSameAs
}{wxstringissameas
}.
498 \membersection{wxString::CompareTo
}\label{wxstringcompareto
}
501 #define NO_POS ((int)(-
1)) // undefined position
502 enum caseCompare
{exact, ignoreCase
};
505 \constfunc{int
}{CompareTo
}{\param{const char*
}{ psz
},
\param{caseCompare
}{ cmp = exact
}}
507 Case-sensitive comparison. Returns
0 if equal,
1 if greater or -
1 if less.
509 \membersection{wxString::Contains
}\label{wxstringcontains
}
511 \constfunc{bool
}{Contains
}{\param{const wxString\&
}{ str
}}
513 Returns
1 if target appears anyhere in wxString; else
0.
515 \membersection{wxString::Empty
}\label{wxstringempty
}
517 \func{void
}{Empty
}{\void}
519 Makes the string empty, but doesn't free memory occupied by the string.
521 See also:
\helpref{Clear()
}{wxstringclear
}.
523 \membersection{wxString::Find
}\label{wxstringfind
}
525 \constfunc{int
}{Find
}{\param{char
}{ ch
},
\param{bool
}{ fromEnd = FALSE
}}
527 Searches for the given character. Returns the starting index, or -
1 if not found.
529 \constfunc{int
}{Find
}{\param{const char*
}{ sz
}}
531 Searches for the given string. Returns the starting index, or -
1 if not found.
533 \membersection{wxString::First
}\label{wxstringfirst
}
535 \func{size
\_t}{First
}{\param{char
}{ c
}}
537 \constfunc{size
\_t}{First
}{\param{const char*
}{ psz
}}
539 \constfunc{size
\_t}{First
}{\param{const wxString\&
}{ str
}}
541 \constfunc{size
\_t}{First
}{\param{const char
}{ ch
}}
543 Returns the first occurrence of the item.
545 \membersection{wxString::Freq
}\label{wxstringfreq
}
547 \constfunc{int
}{Frec
}{\param{char
}{ch
}}
549 Returns the number of occurences of
{it ch
} in the string.
551 \membersection{wxString::GetChar
}\label{wxstringgetchar
}
553 \constfunc{char
}{GetChar
}{\param{size
\_t}{ n
}}
555 Returns the character at position
{\it n
} (read-only).
557 \membersection{wxString::GetData
}\label{wxstringgetdata
}
559 \constfunc{const char*
}{GetData
}{\void}
561 wxWindows compatibility conversion. Returns a constant pointer to the data in the string.
563 \membersection{wxString::GetWritableChar
}\label{wxstringgetwritablechar
}
565 \func{char\&
}{GetWritableChar
}{\param{size
\_t}{ n
}}
567 Returns a reference to the character at position
{\it n
}.
569 \membersection{wxString::GetWriteBuf
}\label{wxstringgetwritebuf
}
571 \func{char*
}{GetWriteBuf
}{\param{size
\_t}{ len
}}
573 Returns a writable buffer of at least
{\it len
} bytes.
575 Call
\helpref{wxString::UngetWriteBuf
}{wxstringungetwritebuf
} as soon as possible
576 to put the string back into a reasonable state.
578 \membersection{wxString::Index
}\label{wxstringindex
}
580 \constfunc{size
\_t}{Index
}{\param{char
}{ ch
},
\param{int
}{ startpos =
0}}
582 Same as
\helpref{wxString::Find
}{wxstringfind
}.
584 \constfunc{size
\_t}{Index
}{\param{const char*
}{ sz
}}
586 Same as
\helpref{wxString::Find
}{wxstringfind
}.
588 \constfunc{size
\_t}{Index
}{\param{const char*
}{ sz
},
\param{bool
}{ caseSensitive = TRUE
},
\param{bool
}{ fromEnd = FALSE
}}
590 Search the element in the array, starting from either side.
592 If
{\it fromEnd
} is TRUE, reverse search direction.
594 If
{\bf caseSensitive
}, comparison is case sensitive (the default).
596 Returns the index of the first item matched, or NOT
\_FOUND.
599 %\membersection{wxString::insert}\label{wxstringinsert}
601 %\func{void}{insert}{\param{const wxString\&}{ str}, \param{size\_t}{ index}}
603 %Add new element at the given position.
605 \membersection{wxString::IsAscii
}\label{wxstringisascii
}
607 \constfunc{bool
}{IsAscii
}{\void}
609 Returns TRUE if the string is ASCII.
611 \membersection{wxString::IsEmpty
}\label{wxstringisempty
}
613 \constfunc{bool
}{IsEmpty
}{\void}
615 Returns TRUE if the string is NULL.
617 \membersection{wxString::IsNull
}\label{wxstringisnull
}
619 \constfunc{bool
}{IsNull
}{\void}
621 Returns TRUE if the string is NULL (same as IsEmpty).
623 \membersection{wxString::IsNumber
}\label{wxstringisnumber
}
625 \constfunc{bool
}{IsNumber
}{\void}
627 Returns TRUE if the string is a number.
629 \membersection{wxString::IsSameAs
}\label{wxstringissameas
}
631 \constfunc{bool
}{IsSameAs
}{\param{const char*
}{ psz
},
\param{bool
}{ caseSensitive = TRUE
}}
633 Test for string equality, case-sensitive (default) or not.
635 caseSensitive is TRUE by default (case matters).
637 Returns TRUE if strings are equal, FALSE otherwise.
639 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{CmpNoCase
}{wxstringcmpnocase
}.
641 \membersection{wxString::IsWord
}\label{wxstringisword
}
643 \constfunc{bool
}{IsWord
}{\void}
645 Returns TRUE if the string is a word. TODO: what's the definition of a word?
647 \membersection{wxString::Last
}\label{wxstringlast
}
649 \constfunc{char
}{Last
}{\void}
651 Returns the last character.
653 \func{char\&
}{Last
}{\void}
655 Returns a reference to the last character (writable).
657 \membersection{wxString::Left
}\label{wxstringleft
}
659 \constfunc{wxString
}{Left
}{\param{size
\_t}{ count
}}
661 Returns the first
{\it count
} characters.
663 \constfunc{wxString
}{Left
}{\param{char
}{ ch
}}
665 Returns all characters before the first occurence of
{\it ch
}.
666 Returns the whole string if
{\it ch
} is not found.
668 \membersection{wxString::Len
}\label{wxstringlen
}
670 \constfunc{size
\_t}{Len
}{\void}
672 Returns the length of the string.
674 \membersection{wxString::Length
}\label{wxstringlength
}
676 \constfunc{size
\_t}{Length
}{\void}
678 Returns the length of the string (same as Len).
680 \membersection{wxString::Lower
}\label{wxstringlower
}
682 \constfunc{wxString
}{Lower
}{\void}
684 Returns this string converted to the lower case.
686 \membersection{wxString::LowerCase
}\label{wxstringlowercase
}
688 \func{void
}{LowerCase
}{\void}
692 \membersection{wxString::MakeLower
}\label{wxstringmakelower
}
694 \func{void
}{MakeLower
}{\void}
696 Converts all characters to lower case.
698 \membersection{wxString::MakeUpper
}\label{wxstringmakeupper
}
700 \func{void
}{MakeUpper
}{\void}
702 Converts all characters to upper case.
704 \membersection{wxString::Matches
}\label{wxstringmatches
}
706 \constfunc{bool
}{Matches
}{\param{const char*
}{ szMask
}}
708 Returns TRUE if the string contents matches a mask containing '*' and '?'.
710 \membersection{wxString::Mid
}\label{wxstringmid
}
712 \constfunc{wxString
}{Mid
}{\param{size
\_t}{ first
},
\param{size
\_t}{ count = wxSTRING
\_MAXLEN}}
714 Returns a substring starting at
{\it first
}, with length
{\it count
}, or the rest of
715 the string if
{\it count
} is the default value.
717 \membersection{wxString::Pad
}\label{wxstringpad
}
719 \func{wxString\&
}{Pad
}{\param{size
\_t}{ count
},
\param{char
}{ pad = ' '
},
\param{bool
}{ fromRight = TRUE
}}
721 Adds
{\it count
} copies of
{\it pad
} to the beginning, or to the end of the string (the default).
723 Removes spaces from the left or from the right (default).
725 \membersection{wxString::Prepend
}\label{wxstringprepend
}
727 \func{wxString\&
}{Prepend
}{\param{const wxString\&
}{ str
}}
729 Prepends
{\it str
} to this string, returning a reference to this string.
731 \membersection{wxString::Printf
}\label{wxstringprintf
}
733 \func{int
}{Printf
}{\param{const char*
}{pszFormat
},
\param{}{...
}}
735 Similar to the standard function
{\it sprintf()
}. Returns the number of
736 characters written, or an integer less than zero on error.
738 {\bf NB:
} This function will use a safe version of
{\it vsprintf()
} (usually called
739 {\it vsnprintf()
}) whenever available to always allocate the buffer of correct
740 size. Unfortunately, this function is not available on all platforms and the
741 dangerous
{\it vsprintf()
} will be used then which may lead to buffer overflows.
743 \membersection{wxString::PrintfV
}\label{wxstringprintfv
}
745 \func{int
}{PrintfV
}{\param{const char*
}{pszFormat
},
\param{va
\_list}{ argPtr
}}
747 Similar to vprintf. Returns the number of characters written, or an integer less than zero
750 \membersection{wxString::Remove
}\label{wxstringremove
}
752 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
}}
754 Same as Truncate. Removes the portion from
{\it pos
} to the end of the string.
756 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
},
\param{size
\_t}{ len
}}
758 Removes the last
{\it len
} characters from the string, starting at
{\it pos
}.
760 \membersection{wxString::RemoveLast
}\label{wxstringremovelast
}
762 \func{wxString\&
}{RemoveLast
}{\void}
764 Removes the last character.
766 \membersection{wxString::Replace
}\label{wxstringreplace
}
768 \func{size
\_t}{Replace
}{\param{const char*
}{ szOld
},
\param{const char*
}{ szNew
},
\param{bool
}{ replaceAll = TRUE
}}
770 Replace first (or all) occurences of substring with another one.
772 {\it replaceAll
}: global replace (default), or only the first occurence.
774 Returns the number of replacements made.
776 \membersection{wxString::Right
}\label{wxstringright
}
778 \constfunc{wxString
}{Right
}{\param{size
\_t}{ count
}}
780 Returns the last
{\it count
} characters.
782 \constfunc{wxString
}{Right
}{\param{char
}{ ch
}}
784 Returns all characters after the last occurence of
{\it ch
}.
785 Returns the whole string if
{\it ch
} is not found.
787 \membersection{wxString::SetChar
}\label{wxstringsetchar
}
789 \func{void
}{SetChar
}{\param{size
\_t}{ n
},
\param{char
}{ch
}}
791 Sets the character at position
{\it n
}.
793 \membersection{wxString::Shrink
}\label{wxstringshrink
}
795 \func{void
}{Shrink
}{\void}
797 Minimizes the string's memory. This can be useful after a call to
798 \helpref{Alloc()
}{wxstringalloc
} if too much memory were preallocated.
800 \membersection{wxString::sprintf
}\label{wxstringsprintf
}
802 \func{void
}{sprintf
}{\param{const char*
}{ fmt
}}
806 \membersection{wxString::Strip
}\label{wxstringstrip
}
809 enum stripType
{leading =
0x1, trailing =
0x2, both =
0x3};
812 \constfunc{wxString
}{Strip
}{\param{stripType
}{ s = trailing
}}
814 Strip characters at the front and/or end. The same as Trim except that it
815 doesn't change this string.
817 \membersection{wxString::SubString
}\label{wxstringsubstring
}
819 \constfunc{wxString
}{SubString
}{\param{size
\_t}{ to
},
\param{size
\_t}{ from
}}
821 Same as
\helpref{Mid
}{wxstringmid
}.
823 \membersection{wxString::Trim
}\label{wxstringtrim
}
825 \func{wxString\&
}{Trim
}{\param{bool
}{ fromRight = TRUE
}}
827 Removes spaces from the left or from the right (default).
829 \membersection{wxString::Truncate
}\label{wxstringtruncate
}
831 \func{wxString\&
}{Truncate
}{\param{size
\_t}{ len
}}
833 Truncate the string to the given length.
835 \membersection{wxString::UngetWriteBuf
}\label{wxstringungetwritebuf
}
837 \func{void
}{UngetWriteBuf
}{\void}
839 Puts the string back into a reasonable state, after
840 \rtfsp\helpref{wxString::GetWriteBuf
}{wxstringgetwritebuf
} was called.
842 \membersection{wxString::Upper
}\label{wxstringupper
}
844 \constfunc{wxString
}{Upper
}{\void}
846 Returns this string converted to upper case.
848 \membersection{wxString::UpperCase
}\label{wxstringuppercase
}
850 \func{void
}{UpperCase
}{\void}
852 The same as MakeUpper.
854 \membersection{wxString::operator!
}\label{wxstringoperatornot
}
856 \constfunc{bool
}{operator!
}{\void}
858 Empty string is FALSE, so !string will only return TRUE if the string is empty.
859 This allows the tests for NULLness of a
{\it const char *
} pointer and emptyness
860 of the string to look the same in the code and makes it easier to port old code
863 See also
\helpref{IsEmpty()
}{wxstringisempty
}.
865 \membersection{wxString::operator $=$
}\label{wxstringoperatorassign
}
867 \func{wxString\&
}{operator $=$
}{\param{const wxString\&
}{ str
}}
869 \func{wxString\&
}{operator $=$
}{\param{const char*
}{ psz
}}
871 \func{wxString\&
}{operator $=$
}{\param{char
}{ c
}}
873 \func{wxString\&
}{operator $=$
}{\param{const unsigned char*
}{ psz
}}
875 \func{wxString\&
}{operator $=$
}{\param{const wchar
\_t*
}{ pwz
}}
877 Assignment: the effect of each operation is the same as for the corresponding
878 constructor (see
\helpref{wxString constructors
}{wxstringconstruct
}).
880 \membersection{operator wxString::$+$
}\label{wxstringoperatorplus
}
882 Concatenation: all these operators return a new strign equal to the sum of the
885 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
887 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ y
}}
889 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{char
}{ y
}}
891 \func{wxString
}{operator $+$
}{\param{const char*
}{ x
},
\param{const wxString\&
}{ y
}}
893 \membersection{wxString::operator $+=$
}\label{wxstringplusequal
}
895 \func{void
}{operator $+=$
}{\param{const wxString\&
}{ str
}}
897 \func{void
}{operator $+=$
}{\param{const char*
}{ psz
}}
899 \func{void
}{operator $+=$
}{\param{char
}{ c
}}
901 Concatenation in place: the argument is appended to the string.
903 \membersection{wxString::operator
[]}\label{wxstringoperatorbracket
}
905 \func{char\&
}{operator
[]}{\param{size
\_t}{ i
}}
907 \func{char
}{operator
[]}{\param{size
\_t}{ i
}}
909 \func{char
}{operator
[]}{\param{int
}{ i
}}
913 \membersection{wxString::operator ()
}\label{wxstringoperatorparenth
}
915 \func{wxString
}{operator ()
}{\param{size
\_t}{ start
},
\param{size
\_t}{ len
}}
917 Same as Mid (substring extraction).
919 \membersection{wxString::operator
\cinsert}\label{wxstringoperatorout
}
921 \func{wxString\&
}{operator
\cinsert}{\param{const wxString\&
}{ str
}}
923 \func{wxString\&
}{operator
\cinsert}{\param{const char*
}{ psz
}}
925 \func{wxString\&
}{operator
\cinsert}{\param{char
}{ch
}}
929 \func{wxString\&
}{operator
\cinsert}{\param{int
}{ i
}}
931 \func{wxString\&
}{operator
\cinsert}{\param{float
}{ f
}}
933 \func{wxString\&
}{operator
\cinsert}{\param{double
}{ d
}}
935 These functions work as C++ stream insertion operators: they insert the given
936 value into the string. Precision or format cannot be set using them, you can use
937 \helpref{Printf
}{wxstringprintf
} for this.
939 \membersection{wxString::operator
\cextract}\label{wxstringoperatorin
}
941 \func{friend istream\&
}{operator
\cextract}{\param{istream\&
}{ is
},
\param{wxString\&
}{ str
}}
943 Extraction from a stream.
945 \membersection{wxString::operator const char*
}\label{wxstringoperatorconstcharpt
}
947 \constfunc{}{operator const char*
}{\void}
949 Implicit conversion to a C string.
951 \membersection{Comparison operators
}\label{wxstringcomparison
}
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
}}
961 \func{bool
}{operator $>$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
963 \func{bool
}{operator $>$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
965 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
967 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
969 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
971 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
973 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
975 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
979 These comparisons are case-sensitive.