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{Writing values into the string
}
143 Both formatted versions (
\helpref{Printf
}{wxstringprintf
}) and stream-like
144 insertion operators exist (for basic types only).
146 \helpref{Printf
}{wxstringprintf
}\\
147 \helpref{PrintfV
}{wxstringprintfv
}\\
148 \helpref{operator
\cinsert}{wxstringoperatorout
}
150 \membersection{Memory management
}
152 These are "advanced" functions and they will be needed quite rarily.
153 \helpref{Alloc
}{wxstringalloc
} and
\helpref{Shrink
}{wxstringshrink
} are only
154 interesting for optimization purposes.
155 \helpref{GetWriteBuf
}{wxstringgetwritebuf
} may be very useful when working with
156 some external API which requires the caller to provide a writable buffer, but
157 extreme care should be taken when using it: before performing any other
158 operation on the string
\helpref{UngetWriteBuf
}{wxstringungetwritebuf
} {\bf
161 \helpref{Alloc
}{wxstringalloc
}\\
162 \helpref{Shrink
}{wxstringshrink
}\\
163 \helpref{GetWriteBuf
}{wxstringgetwritebuf
}\\
164 \helpref{UngetWriteBuf
}{wxstringungetwritebuf
}
166 \membersection{Miscellaneous
}
168 Other string functions.
170 \helpref{Trim
}{wxstringtrim
}\\
171 \helpref{Pad
}{wxstringpad
}\\
172 \helpref{Truncate
}{wxstringtruncate
}
174 \membersection{wxWindows
1.xx compatiblity functions
}
176 These functiosn are deprecated, please consider using new wxWindows
2.0
177 functions instead of them (or, even better, std::string compatible variants).
179 \helpref{SubString
}{wxstringsubstring
}\\
180 \helpref{sprintf
}{wxstringsprintf
}\\
181 \helpref{CompareTo
}{wxstringcompareto
}\\
182 \helpref{Length
}{wxstringlength
}\\
183 \helpref{Freq
}{wxstringfreq
}\\
184 \helpref{LowerCase
}{wxstringlowercase
}\\
185 \helpref{UpperCase
}{wxstringuppercase
}\\
186 \helpref{Strip
}{wxstringstrip
}\\
187 \helpref{Index
}{wxstringindex
}\\
188 \helpref{Remove
}{wxstringremove
}\\
189 \helpref{First
}{wxstringfirst
}\\
190 \helpref{Last
}{wxstringlast
}\\
191 \helpref{Contains
}{wxstringcontains
}\\
192 \helpref{IsNull
}{wxstringisnull
}\\
193 \helpref{IsAscii
}{wxstringisascii
}\\
194 \helpref{IsNumber
}{wxstringisnumber
}\\
195 \helpref{IsWord
}{wxstringisword
}
197 \membersection{std::string compatibility functions
}\label{wxstringat
}
199 The supported functions are only listed here, please see any STL reference for
203 // take nLen chars starting at nPos
204 wxString(const wxString& str, size_t nPos, size_t nLen);
205 // take all characters from pStart to pEnd (poor man's iterators)
206 wxString(const void *pStart, const void *pEnd);
208 // lib.string.capacity
209 // return the length of the string
211 // return the length of the string
212 size_t length() const;
213 // return the maximum size of the string
214 size_t max_size() const;
215 // resize the string, filling the space with c if c !=
0
216 void resize(size_t nSize, char ch = '
\0');
217 // delete the contents of the string
219 // returns true if the string is empty
223 // return the character at position n
224 char at(size_t n) const;
225 // returns the writable character at position n
228 // lib.string.modifiers
230 wxString& append(const wxString& str);
231 // append elements str
[pos
], ..., str
[pos+n
]
232 wxString& append(const wxString& str, size_t pos, size_t n);
233 // append first n (or all if n == npos) characters of sz
234 wxString& append(const char *sz, size_t n = npos);
236 // append n copies of ch
237 wxString& append(size_t n, char ch);
239 // same as `this_string = str'
240 wxString& assign(const wxString& str);
241 // same as ` = str
[pos..pos + n
]
242 wxString& assign(const wxString& str, size_t pos, size_t n);
243 // same as `= first n (or all if n == npos) characters of sz'
244 wxString& assign(const char *sz, size_t n = npos);
245 // same as `= n copies of ch'
246 wxString& assign(size_t n, char ch);
248 // insert another string
249 wxString& insert(size_t nPos, const wxString& str);
250 // insert n chars of str starting at nStart (in str)
251 wxString& insert(size_t nPos, const wxString& str, size_t nStart, size_t n);
253 // insert first n (or all if n == npos) characters of sz
254 wxString& insert(size_t nPos, const char *sz, size_t n = npos);
255 // insert n copies of ch
256 wxString& insert(size_t nPos, size_t n, char ch);
258 // delete characters from nStart to nStart + nLen
259 wxString& erase(size_t nStart =
0, size_t nLen = npos);
261 // replaces the substring of length nLen starting at nStart
262 wxString& replace(size_t nStart, size_t nLen, const char* sz);
263 // replaces the substring with nCount copies of ch
264 wxString& replace(size_t nStart, size_t nLen, size_t nCount, char ch);
265 // replaces a substring with another substring
266 wxString& replace(size_t nStart, size_t nLen,
267 const wxString& str, size_t nStart2, size_t nLen2);
268 // replaces the substring with first nCount chars of sz
269 wxString& replace(size_t nStart, size_t nLen,
270 const char* sz, size_t nCount);
273 void swap(wxString& str);
275 // All find() functions take the nStart argument which specifies the
276 // position to start the search on, the default value is
0. All functions
277 // return npos if there were no match.
280 size_t find(const wxString& str, size_t nStart =
0) const;
282 // find first n characters of sz
283 size_t find(const char* sz, size_t nStart =
0, size_t n = npos) const;
285 // find the first occurence of character ch after nStart
286 size_t find(char ch, size_t nStart =
0) const;
288 // rfind() family is exactly like find() but works right to left
290 // as find, but from the end
291 size_t rfind(const wxString& str, size_t nStart = npos) const;
293 // as find, but from the end
294 size_t rfind(const char* sz, size_t nStart = npos,
295 size_t n = npos) const;
296 // as find, but from the end
297 size_t rfind(char ch, size_t nStart = npos) const;
299 // find first/last occurence of any character in the set
302 size_t find_first_of(const wxString& str, size_t nStart =
0) const;
304 size_t find_first_of(const char* sz, size_t nStart =
0) const;
305 // same as find(char, size_t)
306 size_t find_first_of(char c, size_t nStart =
0) const;
308 size_t find_last_of (const wxString& str, size_t nStart = npos) const;
310 size_t find_last_of (const char* s, size_t nStart = npos) const;
311 // same as rfind(char, size_t)
312 size_t find_last_of (char c, size_t nStart = npos) const;
314 // find first/last occurence of any character not in the set
317 size_t find_first_not_of(const wxString& str, size_t nStart =
0) const;
319 size_t find_first_not_of(const char* s, size_t nStart =
0) const;
321 size_t find_first_not_of(char ch, size_t nStart =
0) const;
323 size_t find_last_not_of(const wxString& str, size_t nStart=npos) const;
325 size_t find_last_not_of(const char* s, size_t nStart = npos) const;
327 size_t find_last_not_of(char ch, size_t nStart = npos) const;
329 // All compare functions return a negative, zero or positive value
330 // if the
[sub
]string is less, equal or greater than the compare() argument.
332 // just like strcmp()
333 int compare(const wxString& str) const;
334 // comparison with a substring
335 int compare(size_t nStart, size_t nLen, const wxString& str) const;
336 // comparison of
2 substrings
337 int compare(size_t nStart, size_t nLen,
338 const wxString& str, size_t nStart2, size_t nLen2) const;
339 // just like strcmp()
340 int compare(const char* sz) const;
341 // substring comparison with first nCount characters of sz
342 int compare(size_t nStart, size_t nLen,
343 const char* sz, size_t nCount = npos) const;
345 // substring extraction
346 wxString substr(size_t nStart =
0, size_t nLen = npos) const;
349 %%%%% MEMBERS HERE %%%%%
350 \helponly{\insertatlevel{2}{
356 \membersection{wxString::wxString
}\label{wxstringconstruct
}
358 \func{}{wxString
}{\void}
362 \func{}{wxString
}{\param{const wxString\&
}{ x
}}
366 \func{}{wxString
}{\param{char
}{ ch
},
\param{size
\_t}{ n =
1}}
368 Constructs a string of
{\it n
} copies of character
{\it ch
}.
370 \func{}{wxString
}{\param{const char*
}{ psz
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
372 Takes first
{\it nLength
} characters from the C string
{\it psz
}.
373 The default value of wxSTRING
\_MAXLEN means take all the string.
375 \func{}{wxString
}{\param{const unsigned char*
}{ psz
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
377 For compilers using unsigned char: takes first
{\it nLength
} characters from the C string
{\it psz
}.
378 The default value of wxSTRING
\_MAXLEN means take all the string.
380 \func{}{wxString
}{\param{const wchar
\_t*
}{ psz
}}
382 Constructs a string from the wide (UNICODE) string.
384 \membersection{wxString::
\destruct{wxString
}}\label{wxstringdestruct
}
386 \func{}{\destruct{wxString
}}{\void}
388 String destructor. Note that this is not virtual, so wxString must not be inherited from.
390 \membersection{wxString::Alloc
}\label{wxstringalloc
}
392 \func{void
}{Alloc
}{\param{size
\_t}{ nLen
}}
394 Preallocate enough space for wxString to store
{\it nLen
} characters. This function
395 may be used to increase speed when the string is constructed by repeated
400 // delete all vowels from the string
401 wxString DeleteAllVowels(const wxString& original)
405 size_t len = original.length();
409 for ( size_t n =
0; n < len; n++ )
411 if ( strchr("aeuio", tolower(original
[n
])) == NULL )
412 result += original
[n
];
420 because it will avoid the need of reallocating string memory many times (in case
421 of long strings). Note that it does not set the maximal length of a string - it
422 will still expand if more than
{\it nLen
} characters are stored in it. Also, it
423 does not truncate the existing string (use
424 \helpref{Truncate()
}{wxstringtruncate
} for this) even if its current length is
425 greater than
{\it nLen
}
427 \membersection{wxString::Append
}\label{wxstringappend
}
429 \func{wxString\&
}{Append
}{\param{const char*
}{ psz
}}
431 Concatenates
{\it psz
} to this string, returning a reference to it.
433 \func{wxString\&
}{Append
}{\param{char
}{ ch
},
\param{int
}{ count =
1}}
435 Concatenates character
{\it ch
} to this string,
{\it count
} times, returning a reference
438 \membersection{wxString::AfterFirst
}\label{wxstringafterfirst
}
440 \constfunc{wxString
}{AfterFirst
}{\param{char
}{ ch
}}
442 Gets all the characters after the first occurence of
{\it ch
}.
443 Returns the empty string if
{\it ch
} is not found.
445 \membersection{wxString::AfterLast
}\label{wxstringafterlast
}
447 \constfunc{wxString
}{AfterLast
}{\param{char
}{ ch
}}
449 Gets all the characters after the last occurence of
{\it ch
}.
450 Returns the whole string if
{\it ch
} is not found.
452 \membersection{wxString::BeforeFirst
}\label{wxstringbeforefirst
}
454 \constfunc{wxString
}{BeforeFirst
}{\param{char
}{ ch
}}
456 Gets all characters before the first occurence of
{\it ch
}.
457 Returns the whole string if
{\it ch
} is not found.
459 \membersection{wxString::BeforeLast
}\label{wxstringbeforelast
}
461 \constfunc{wxString
}{BeforeLast
}{\param{char
}{ ch
}}
463 Gets all characters before the last occurence of
{\it ch
}.
464 Returns the empty string if
{\it ch
} is not found.
466 \membersection{wxString::c
\_str}\label{wxstringcstr
}
468 \constfunc{const char *
}{c
\_str}{\void}
470 Returns a pointer to the string data.
472 \membersection{wxString::Clear
}\label{wxstringclear
}
474 \func{void
}{Clear
}{\void}
476 Empties the string and frees memory occupied by it.
478 See also:
\helpref{Empty
}{wxstringempty
}
480 \membersection{wxString::Cmp
}\label{wxstringcmp
}
482 \constfunc{int
}{Cmp
}{\param{const char*
}{ psz
}}
484 Case-sensitive comparison.
486 Returns a positive value if the string is greater than the argument, zero if
487 it si equal to it or negative value if it is less than argument (same semantics
488 as the standard
{\it strcmp()
} function).
490 See also
\helpref{CmpNoCase
}{wxstringcmpnocase
},
\helpref{IsSameAs
}{wxstringissameas
}.
492 \membersection{wxString::CmpNoCase
}\label{wxstringcmpnocase
}
494 \constfunc{int
}{CmpNoCase
}{\param{const char*
}{ psz
}}
496 Case-insensitive comparison.
498 Returns a positive value if the string is greater than the argument, zero if
499 it si equal to it or negative value if it is less than argument (same semantics
500 as the standard
{\it strcmp()
} function).
502 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{IsSameAs
}{wxstringissameas
}.
504 \membersection{wxString::CompareTo
}\label{wxstringcompareto
}
507 #define NO_POS ((int)(-
1)) // undefined position
508 enum caseCompare
{exact, ignoreCase
};
511 \constfunc{int
}{CompareTo
}{\param{const char*
}{ psz
},
\param{caseCompare
}{ cmp = exact
}}
513 Case-sensitive comparison. Returns
0 if equal,
1 if greater or -
1 if less.
515 \membersection{wxString::Contains
}\label{wxstringcontains
}
517 \constfunc{bool
}{Contains
}{\param{const wxString\&
}{ str
}}
519 Returns
1 if target appears anyhere in wxString; else
0.
521 \membersection{wxString::Empty
}\label{wxstringempty
}
523 \func{void
}{Empty
}{\void}
525 Makes the string empty, but doesn't free memory occupied by the string.
527 See also:
\helpref{Clear()
}{wxstringclear
}.
529 \membersection{wxString::Find
}\label{wxstringfind
}
531 \constfunc{int
}{Find
}{\param{char
}{ ch
},
\param{bool
}{ fromEnd = FALSE
}}
533 Searches for the given character. Returns the starting index, or -
1 if not found.
535 \constfunc{int
}{Find
}{\param{const char*
}{ sz
}}
537 Searches for the given string. Returns the starting index, or -
1 if not found.
539 \membersection{wxString::First
}\label{wxstringfirst
}
541 \func{size
\_t}{First
}{\param{char
}{ c
}}
543 \constfunc{size
\_t}{First
}{\param{const char*
}{ psz
}}
545 \constfunc{size
\_t}{First
}{\param{const wxString\&
}{ str
}}
547 \constfunc{size
\_t}{First
}{\param{const char
}{ ch
}}
549 Returns the first occurrence of the item.
551 \membersection{wxString::Freq
}\label{wxstringfreq
}
553 \constfunc{int
}{Frec
}{\param{char
}{ch
}}
555 Returns the number of occurences of
{it ch
} in the string.
557 \membersection{wxString::GetChar
}\label{wxstringgetchar
}
559 \constfunc{char
}{GetChar
}{\param{size
\_t}{ n
}}
561 Returns the character at position
{\it n
} (read-only).
563 \membersection{wxString::GetData
}\label{wxstringgetdata
}
565 \constfunc{const char*
}{GetData
}{\void}
567 wxWindows compatibility conversion. Returns a constant pointer to the data in the string.
569 \membersection{wxString::GetWritableChar
}\label{wxstringgetwritablechar
}
571 \func{char\&
}{GetWritableChar
}{\param{size
\_t}{ n
}}
573 Returns a reference to the character at position
{\it n
}.
575 \membersection{wxString::GetWriteBuf
}\label{wxstringgetwritebuf
}
577 \func{char*
}{GetWriteBuf
}{\param{size
\_t}{ len
}}
579 Returns a writable buffer of at least
{\it len
} bytes.
581 Call
\helpref{wxString::UngetWriteBuf
}{wxstringungetwritebuf
} as soon as possible
582 to put the string back into a reasonable state.
584 \membersection{wxString::Index
}\label{wxstringindex
}
586 \constfunc{size
\_t}{Index
}{\param{char
}{ ch
},
\param{int
}{ startpos =
0}}
588 Same as
\helpref{wxString::Find
}{wxstringfind
}.
590 \constfunc{size
\_t}{Index
}{\param{const char*
}{ sz
}}
592 Same as
\helpref{wxString::Find
}{wxstringfind
}.
594 \constfunc{size
\_t}{Index
}{\param{const char*
}{ sz
},
\param{bool
}{ caseSensitive = TRUE
},
\param{bool
}{ fromEnd = FALSE
}}
596 Search the element in the array, starting from either side.
598 If
{\it fromEnd
} is TRUE, reverse search direction.
600 If
{\bf caseSensitive
}, comparison is case sensitive (the default).
602 Returns the index of the first item matched, or NOT
\_FOUND.
605 %\membersection{wxString::insert}\label{wxstringinsert}
607 %\func{void}{insert}{\param{const wxString\&}{ str}, \param{size\_t}{ index}}
609 %Add new element at the given position.
611 \membersection{wxString::IsAscii
}\label{wxstringisascii
}
613 \constfunc{bool
}{IsAscii
}{\void}
615 Returns TRUE if the string is ASCII.
617 \membersection{wxString::IsEmpty
}\label{wxstringisempty
}
619 \constfunc{bool
}{IsEmpty
}{\void}
621 Returns TRUE if the string is NULL.
623 \membersection{wxString::IsNull
}\label{wxstringisnull
}
625 \constfunc{bool
}{IsNull
}{\void}
627 Returns TRUE if the string is NULL (same as IsEmpty).
629 \membersection{wxString::IsNumber
}\label{wxstringisnumber
}
631 \constfunc{bool
}{IsNumber
}{\void}
633 Returns TRUE if the string is a number.
635 \membersection{wxString::IsSameAs
}\label{wxstringissameas
}
637 \constfunc{bool
}{IsSameAs
}{\param{const char*
}{ psz
},
\param{bool
}{ caseSensitive = TRUE
}}
639 Test for string equality, case-sensitive (default) or not.
641 caseSensitive is TRUE by default (case matters).
643 Returns TRUE if strings are equal, FALSE otherwise.
645 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{CmpNoCase
}{wxstringcmpnocase
},
\helpref{IsSameAs
}{wxstringissameas2
}
647 \membersection{wxString::IsSameAs
}\label{wxstringissameas2
}
649 \constfunc{bool
}{IsSameAs
}{\param{char
}{ c
},
\param{bool
}{ caseSensitive = TRUE
}}
651 Test whether the string is equal to the single character
{\it c
}. The test is
652 case-sensitive if
{\it caseSensitive
} is TRUE (default) or not if it is FALSE.
654 Returns TRUE if the string is equal to the character, FALSE otherwise.
656 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{CmpNoCase
}{wxstringcmpnocase
},
\helpref{IsSameAs
}{wxstringissameas
}
658 \membersection{wxString::IsWord
}\label{wxstringisword
}
660 \constfunc{bool
}{IsWord
}{\void}
662 Returns TRUE if the string is a word. TODO: what's the definition of a word?
664 \membersection{wxString::Last
}\label{wxstringlast
}
666 \constfunc{char
}{Last
}{\void}
668 Returns the last character.
670 \func{char\&
}{Last
}{\void}
672 Returns a reference to the last character (writable).
674 \membersection{wxString::Left
}\label{wxstringleft
}
676 \constfunc{wxString
}{Left
}{\param{size
\_t}{ count
}}
678 Returns the first
{\it count
} characters.
680 \constfunc{wxString
}{Left
}{\param{char
}{ ch
}}
682 Returns all characters before the first occurence of
{\it ch
}.
683 Returns the whole string if
{\it ch
} is not found.
685 \membersection{wxString::Len
}\label{wxstringlen
}
687 \constfunc{size
\_t}{Len
}{\void}
689 Returns the length of the string.
691 \membersection{wxString::Length
}\label{wxstringlength
}
693 \constfunc{size
\_t}{Length
}{\void}
695 Returns the length of the string (same as Len).
697 \membersection{wxString::Lower
}\label{wxstringlower
}
699 \constfunc{wxString
}{Lower
}{\void}
701 Returns this string converted to the lower case.
703 \membersection{wxString::LowerCase
}\label{wxstringlowercase
}
705 \func{void
}{LowerCase
}{\void}
709 \membersection{wxString::MakeLower
}\label{wxstringmakelower
}
711 \func{void
}{MakeLower
}{\void}
713 Converts all characters to lower case.
715 \membersection{wxString::MakeUpper
}\label{wxstringmakeupper
}
717 \func{void
}{MakeUpper
}{\void}
719 Converts all characters to upper case.
721 \membersection{wxString::Matches
}\label{wxstringmatches
}
723 \constfunc{bool
}{Matches
}{\param{const char*
}{ szMask
}}
725 Returns TRUE if the string contents matches a mask containing '*' and '?'.
727 \membersection{wxString::Mid
}\label{wxstringmid
}
729 \constfunc{wxString
}{Mid
}{\param{size
\_t}{ first
},
\param{size
\_t}{ count = wxSTRING
\_MAXLEN}}
731 Returns a substring starting at
{\it first
}, with length
{\it count
}, or the rest of
732 the string if
{\it count
} is the default value.
734 \membersection{wxString::Pad
}\label{wxstringpad
}
736 \func{wxString\&
}{Pad
}{\param{size
\_t}{ count
},
\param{char
}{ pad = ' '
},
\param{bool
}{ fromRight = TRUE
}}
738 Adds
{\it count
} copies of
{\it pad
} to the beginning, or to the end of the string (the default).
740 Removes spaces from the left or from the right (default).
742 \membersection{wxString::Prepend
}\label{wxstringprepend
}
744 \func{wxString\&
}{Prepend
}{\param{const wxString\&
}{ str
}}
746 Prepends
{\it str
} to this string, returning a reference to this string.
748 \membersection{wxString::Printf
}\label{wxstringprintf
}
750 \func{int
}{Printf
}{\param{const char*
}{pszFormat
},
\param{}{...
}}
752 Similar to the standard function
{\it sprintf()
}. Returns the number of
753 characters written, or an integer less than zero on error.
755 {\bf NB:
} This function will use a safe version of
{\it vsprintf()
} (usually called
756 {\it vsnprintf()
}) whenever available to always allocate the buffer of correct
757 size. Unfortunately, this function is not available on all platforms and the
758 dangerous
{\it vsprintf()
} will be used then which may lead to buffer overflows.
760 \membersection{wxString::PrintfV
}\label{wxstringprintfv
}
762 \func{int
}{PrintfV
}{\param{const char*
}{pszFormat
},
\param{va
\_list}{ argPtr
}}
764 Similar to vprintf. Returns the number of characters written, or an integer less than zero
767 \membersection{wxString::Remove
}\label{wxstringremove
}
769 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
}}
771 Same as Truncate. Removes the portion from
{\it pos
} to the end of the string.
773 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
},
\param{size
\_t}{ len
}}
775 Removes the last
{\it len
} characters from the string, starting at
{\it pos
}.
777 \membersection{wxString::RemoveLast
}\label{wxstringremovelast
}
779 \func{wxString\&
}{RemoveLast
}{\void}
781 Removes the last character.
783 \membersection{wxString::Replace
}\label{wxstringreplace
}
785 \func{size
\_t}{Replace
}{\param{const char*
}{ szOld
},
\param{const char*
}{ szNew
},
\param{bool
}{ replaceAll = TRUE
}}
787 Replace first (or all) occurences of substring with another one.
789 {\it replaceAll
}: global replace (default), or only the first occurence.
791 Returns the number of replacements made.
793 \membersection{wxString::Right
}\label{wxstringright
}
795 \constfunc{wxString
}{Right
}{\param{size
\_t}{ count
}}
797 Returns the last
{\it count
} characters.
799 \membersection{wxString::SetChar
}\label{wxstringsetchar
}
801 \func{void
}{SetChar
}{\param{size
\_t}{ n
},
\param{char
}{ch
}}
803 Sets the character at position
{\it n
}.
805 \membersection{wxString::Shrink
}\label{wxstringshrink
}
807 \func{void
}{Shrink
}{\void}
809 Minimizes the string's memory. This can be useful after a call to
810 \helpref{Alloc()
}{wxstringalloc
} if too much memory were preallocated.
812 \membersection{wxString::sprintf
}\label{wxstringsprintf
}
814 \func{void
}{sprintf
}{\param{const char*
}{ fmt
}}
818 \membersection{wxString::Strip
}\label{wxstringstrip
}
821 enum stripType
{leading =
0x1, trailing =
0x2, both =
0x3};
824 \constfunc{wxString
}{Strip
}{\param{stripType
}{ s = trailing
}}
826 Strip characters at the front and/or end. The same as Trim except that it
827 doesn't change this string.
829 \membersection{wxString::SubString
}\label{wxstringsubstring
}
831 \constfunc{wxString
}{SubString
}{\param{size
\_t}{ to
},
\param{size
\_t}{ from
}}
833 Same as
\helpref{Mid
}{wxstringmid
}.
835 \membersection{wxString::Trim
}\label{wxstringtrim
}
837 \func{wxString\&
}{Trim
}{\param{bool
}{ fromRight = TRUE
}}
839 Removes spaces from the left or from the right (default).
841 \membersection{wxString::Truncate
}\label{wxstringtruncate
}
843 \func{wxString\&
}{Truncate
}{\param{size
\_t}{ len
}}
845 Truncate the string to the given length.
847 \membersection{wxString::UngetWriteBuf
}\label{wxstringungetwritebuf
}
849 \func{void
}{UngetWriteBuf
}{\void}
851 Puts the string back into a reasonable state, after
852 \rtfsp\helpref{wxString::GetWriteBuf
}{wxstringgetwritebuf
} was called.
854 \membersection{wxString::Upper
}\label{wxstringupper
}
856 \constfunc{wxString
}{Upper
}{\void}
858 Returns this string converted to upper case.
860 \membersection{wxString::UpperCase
}\label{wxstringuppercase
}
862 \func{void
}{UpperCase
}{\void}
864 The same as MakeUpper.
866 \membersection{wxString::operator!
}\label{wxstringoperatornot
}
868 \constfunc{bool
}{operator!
}{\void}
870 Empty string is FALSE, so !string will only return TRUE if the string is empty.
871 This allows the tests for NULLness of a
{\it const char *
} pointer and emptyness
872 of the string to look the same in the code and makes it easier to port old code
875 See also
\helpref{IsEmpty()
}{wxstringisempty
}.
877 \membersection{wxString::operator $=$
}\label{wxstringoperatorassign
}
879 \func{wxString\&
}{operator $=$
}{\param{const wxString\&
}{ str
}}
881 \func{wxString\&
}{operator $=$
}{\param{const char*
}{ psz
}}
883 \func{wxString\&
}{operator $=$
}{\param{char
}{ c
}}
885 \func{wxString\&
}{operator $=$
}{\param{const unsigned char*
}{ psz
}}
887 \func{wxString\&
}{operator $=$
}{\param{const wchar
\_t*
}{ pwz
}}
889 Assignment: the effect of each operation is the same as for the corresponding
890 constructor (see
\helpref{wxString constructors
}{wxstringconstruct
}).
892 \membersection{operator wxString::$+$
}\label{wxstringoperatorplus
}
894 Concatenation: all these operators return a new strign equal to the sum of the
897 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
899 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ y
}}
901 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{char
}{ y
}}
903 \func{wxString
}{operator $+$
}{\param{const char*
}{ x
},
\param{const wxString\&
}{ y
}}
905 \membersection{wxString::operator $+=$
}\label{wxstringplusequal
}
907 \func{void
}{operator $+=$
}{\param{const wxString\&
}{ str
}}
909 \func{void
}{operator $+=$
}{\param{const char*
}{ psz
}}
911 \func{void
}{operator $+=$
}{\param{char
}{ c
}}
913 Concatenation in place: the argument is appended to the string.
915 \membersection{wxString::operator
[]}\label{wxstringoperatorbracket
}
917 \func{char\&
}{operator
[]}{\param{size
\_t}{ i
}}
919 \func{char
}{operator
[]}{\param{size
\_t}{ i
}}
921 \func{char
}{operator
[]}{\param{int
}{ i
}}
925 \membersection{wxString::operator ()
}\label{wxstringoperatorparenth
}
927 \func{wxString
}{operator ()
}{\param{size
\_t}{ start
},
\param{size
\_t}{ len
}}
929 Same as Mid (substring extraction).
931 \membersection{wxString::operator
\cinsert}\label{wxstringoperatorout
}
933 \func{wxString\&
}{operator
\cinsert}{\param{const wxString\&
}{ str
}}
935 \func{wxString\&
}{operator
\cinsert}{\param{const char*
}{ psz
}}
937 \func{wxString\&
}{operator
\cinsert}{\param{char
}{ch
}}
941 \func{wxString\&
}{operator
\cinsert}{\param{int
}{ i
}}
943 \func{wxString\&
}{operator
\cinsert}{\param{float
}{ f
}}
945 \func{wxString\&
}{operator
\cinsert}{\param{double
}{ d
}}
947 These functions work as C++ stream insertion operators: they insert the given
948 value into the string. Precision or format cannot be set using them, you can use
949 \helpref{Printf
}{wxstringprintf
} for this.
951 \membersection{wxString::operator
\cextract}\label{wxstringoperatorin
}
953 \func{friend istream\&
}{operator
\cextract}{\param{istream\&
}{ is
},
\param{wxString\&
}{ str
}}
955 Extraction from a stream.
957 \membersection{wxString::operator const char*
}\label{wxstringoperatorconstcharpt
}
959 \constfunc{}{operator const char*
}{\void}
961 Implicit conversion to a C string.
963 \membersection{Comparison operators
}\label{wxstringcomparison
}
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
}}
977 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
979 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
981 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
983 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
985 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
987 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
991 These comparisons are case-sensitive.