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). Additionally, the
156 \helpref{Format
}{wxstringformat
} function allows to use simply append
157 formatted value to a string:
160 // the following
2 snippets are equivalent
163 s += wxString::Format("
%d", n);
166 s.Printf("...
%d", n);
169 \helpref{Format
}{wxstringformat
}\\
170 \helpref{FormatV
}{wxstringformatv
}\\
171 \helpref{Printf
}{wxstringprintf
}\\
172 \helpref{PrintfV
}{wxstringprintfv
}\\
173 \helpref{operator
\cinsert}{wxstringoperatorout
}
175 \membersection{Memory management
}
177 These are "advanced" functions and they will be needed quite rarily.
178 \helpref{Alloc
}{wxstringalloc
} and
\helpref{Shrink
}{wxstringshrink
} are only
179 interesting for optimization purposes.
180 \helpref{GetWriteBuf
}{wxstringgetwritebuf
} may be very useful when working with
181 some external API which requires the caller to provide a writable buffer, but
182 extreme care should be taken when using it: before performing any other
183 operation on the string
\helpref{UngetWriteBuf
}{wxstringungetwritebuf
} {\bf
186 \helpref{Alloc
}{wxstringalloc
}\\
187 \helpref{Shrink
}{wxstringshrink
}\\
188 \helpref{GetWriteBuf
}{wxstringgetwritebuf
}\\
189 \helpref{UngetWriteBuf
}{wxstringungetwritebuf
}
191 \membersection{Miscellaneous
}
193 Other string functions.
195 \helpref{Trim
}{wxstringtrim
}\\
196 \helpref{Pad
}{wxstringpad
}\\
197 \helpref{Truncate
}{wxstringtruncate
}
199 \membersection{wxWindows
1.xx compatiblity functions
}
201 These functiosn are deprecated, please consider using new wxWindows
2.0
202 functions instead of them (or, even better, std::string compatible variants).
204 \helpref{SubString
}{wxstringsubstring
}\\
205 \helpref{sprintf
}{wxstringsprintf
}\\
206 \helpref{CompareTo
}{wxstringcompareto
}\\
207 \helpref{Length
}{wxstringlength
}\\
208 \helpref{Freq
}{wxstringfreq
}\\
209 \helpref{LowerCase
}{wxstringlowercase
}\\
210 \helpref{UpperCase
}{wxstringuppercase
}\\
211 \helpref{Strip
}{wxstringstrip
}\\
212 \helpref{Index
}{wxstringindex
}\\
213 \helpref{Remove
}{wxstringremove
}\\
214 \helpref{First
}{wxstringfirst
}\\
215 \helpref{Last
}{wxstringlast
}\\
216 \helpref{Contains
}{wxstringcontains
}\\
217 \helpref{IsNull
}{wxstringisnull
}\\
218 \helpref{IsAscii
}{wxstringisascii
}\\
219 \helpref{IsNumber
}{wxstringisnumber
}\\
220 \helpref{IsWord
}{wxstringisword
}
222 \membersection{std::string compatibility functions
}\label{wxstringat
}
224 The supported functions are only listed here, please see any STL reference for
228 // take nLen chars starting at nPos
229 wxString(const wxString& str, size_t nPos, size_t nLen);
230 // take all characters from pStart to pEnd (poor man's iterators)
231 wxString(const void *pStart, const void *pEnd);
233 // lib.string.capacity
234 // return the length of the string
236 // return the length of the string
237 size_t length() const;
238 // return the maximum size of the string
239 size_t max_size() const;
240 // resize the string, filling the space with c if c !=
0
241 void resize(size_t nSize, char ch = '
\0');
242 // delete the contents of the string
244 // returns true if the string is empty
248 // return the character at position n
249 char at(size_t n) const;
250 // returns the writable character at position n
253 // lib.string.modifiers
255 wxString& append(const wxString& str);
256 // append elements str
[pos
], ..., str
[pos+n
]
257 wxString& append(const wxString& str, size_t pos, size_t n);
258 // append first n (or all if n == npos) characters of sz
259 wxString& append(const char *sz, size_t n = npos);
261 // append n copies of ch
262 wxString& append(size_t n, char ch);
264 // same as `this_string = str'
265 wxString& assign(const wxString& str);
266 // same as ` = str
[pos..pos + n
]
267 wxString& assign(const wxString& str, size_t pos, size_t n);
268 // same as `= first n (or all if n == npos) characters of sz'
269 wxString& assign(const char *sz, size_t n = npos);
270 // same as `= n copies of ch'
271 wxString& assign(size_t n, char ch);
273 // insert another string
274 wxString& insert(size_t nPos, const wxString& str);
275 // insert n chars of str starting at nStart (in str)
276 wxString& insert(size_t nPos, const wxString& str, size_t nStart, size_t n);
278 // insert first n (or all if n == npos) characters of sz
279 wxString& insert(size_t nPos, const char *sz, size_t n = npos);
280 // insert n copies of ch
281 wxString& insert(size_t nPos, size_t n, char ch);
283 // delete characters from nStart to nStart + nLen
284 wxString& erase(size_t nStart =
0, size_t nLen = npos);
286 // replaces the substring of length nLen starting at nStart
287 wxString& replace(size_t nStart, size_t nLen, const char* sz);
288 // replaces the substring with nCount copies of ch
289 wxString& replace(size_t nStart, size_t nLen, size_t nCount, char ch);
290 // replaces a substring with another substring
291 wxString& replace(size_t nStart, size_t nLen,
292 const wxString& str, size_t nStart2, size_t nLen2);
293 // replaces the substring with first nCount chars of sz
294 wxString& replace(size_t nStart, size_t nLen,
295 const char* sz, size_t nCount);
298 void swap(wxString& str);
300 // All find() functions take the nStart argument which specifies the
301 // position to start the search on, the default value is
0. All functions
302 // return npos if there were no match.
305 size_t find(const wxString& str, size_t nStart =
0) const;
307 // find first n characters of sz
308 size_t find(const char* sz, size_t nStart =
0, size_t n = npos) const;
310 // find the first occurence of character ch after nStart
311 size_t find(char ch, size_t nStart =
0) const;
313 // rfind() family is exactly like find() but works right to left
315 // as find, but from the end
316 size_t rfind(const wxString& str, size_t nStart = npos) const;
318 // as find, but from the end
319 size_t rfind(const char* sz, size_t nStart = npos,
320 size_t n = npos) const;
321 // as find, but from the end
322 size_t rfind(char ch, size_t nStart = npos) const;
324 // find first/last occurence of any character in the set
327 size_t find_first_of(const wxString& str, size_t nStart =
0) const;
329 size_t find_first_of(const char* sz, size_t nStart =
0) const;
330 // same as find(char, size_t)
331 size_t find_first_of(char c, size_t nStart =
0) const;
333 size_t find_last_of (const wxString& str, size_t nStart = npos) const;
335 size_t find_last_of (const char* s, size_t nStart = npos) const;
336 // same as rfind(char, size_t)
337 size_t find_last_of (char c, size_t nStart = npos) const;
339 // find first/last occurence of any character not in the set
342 size_t find_first_not_of(const wxString& str, size_t nStart =
0) const;
344 size_t find_first_not_of(const char* s, size_t nStart =
0) const;
346 size_t find_first_not_of(char ch, size_t nStart =
0) const;
348 size_t find_last_not_of(const wxString& str, size_t nStart=npos) const;
350 size_t find_last_not_of(const char* s, size_t nStart = npos) const;
352 size_t find_last_not_of(char ch, size_t nStart = npos) const;
354 // All compare functions return a negative, zero or positive value
355 // if the
[sub
]string is less, equal or greater than the compare() argument.
357 // just like strcmp()
358 int compare(const wxString& str) const;
359 // comparison with a substring
360 int compare(size_t nStart, size_t nLen, const wxString& str) const;
361 // comparison of
2 substrings
362 int compare(size_t nStart, size_t nLen,
363 const wxString& str, size_t nStart2, size_t nLen2) const;
364 // just like strcmp()
365 int compare(const char* sz) const;
366 // substring comparison with first nCount characters of sz
367 int compare(size_t nStart, size_t nLen,
368 const char* sz, size_t nCount = npos) const;
370 // substring extraction
371 wxString substr(size_t nStart =
0, size_t nLen = npos) const;
374 %%%%% MEMBERS HERE %%%%%
375 \helponly{\insertatlevel{2}{
381 \membersection{wxString::wxString
}\label{wxstringconstruct
}
383 \func{}{wxString
}{\void}
387 \func{}{wxString
}{\param{const wxString\&
}{ x
}}
391 \func{}{wxString
}{\param{char
}{ ch
},
\param{size
\_t}{ n =
1}}
393 Constructs a string of
{\it n
} copies of character
{\it ch
}.
395 \func{}{wxString
}{\param{const char*
}{ psz
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
397 Takes first
{\it nLength
} characters from the C string
{\it psz
}.
398 The default value of wxSTRING
\_MAXLEN means take all the string.
400 \func{}{wxString
}{\param{const unsigned char*
}{ psz
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
402 For compilers using unsigned char: takes first
{\it nLength
} characters from the C string
{\it psz
}.
403 The default value of wxSTRING
\_MAXLEN means take all the string.
405 \func{}{wxString
}{\param{const wchar
\_t*
}{ psz
}}
407 Constructs a string from the wide (UNICODE) string.
409 \membersection{wxString::
\destruct{wxString
}}\label{wxstringdestruct
}
411 \func{}{\destruct{wxString
}}{\void}
413 String destructor. Note that this is not virtual, so wxString must not be inherited from.
415 \membersection{wxString::Alloc
}\label{wxstringalloc
}
417 \func{void
}{Alloc
}{\param{size
\_t}{ nLen
}}
419 Preallocate enough space for wxString to store
{\it nLen
} characters. This function
420 may be used to increase speed when the string is constructed by repeated
425 // delete all vowels from the string
426 wxString DeleteAllVowels(const wxString& original)
430 size_t len = original.length();
434 for ( size_t n =
0; n < len; n++ )
436 if ( strchr("aeuio", tolower(original
[n
])) == NULL )
437 result += original
[n
];
445 because it will avoid the need of reallocating string memory many times (in case
446 of long strings). Note that it does not set the maximal length of a string - it
447 will still expand if more than
{\it nLen
} characters are stored in it. Also, it
448 does not truncate the existing string (use
449 \helpref{Truncate()
}{wxstringtruncate
} for this) even if its current length is
450 greater than
{\it nLen
}
452 \membersection{wxString::Append
}\label{wxstringappend
}
454 \func{wxString\&
}{Append
}{\param{const char*
}{ psz
}}
456 Concatenates
{\it psz
} to this string, returning a reference to it.
458 \func{wxString\&
}{Append
}{\param{char
}{ ch
},
\param{int
}{ count =
1}}
460 Concatenates character
{\it ch
} to this string,
{\it count
} times, returning a reference
463 \membersection{wxString::AfterFirst
}\label{wxstringafterfirst
}
465 \constfunc{wxString
}{AfterFirst
}{\param{char
}{ ch
}}
467 Gets all the characters after the first occurence of
{\it ch
}.
468 Returns the empty string if
{\it ch
} is not found.
470 \membersection{wxString::AfterLast
}\label{wxstringafterlast
}
472 \constfunc{wxString
}{AfterLast
}{\param{char
}{ ch
}}
474 Gets all the characters after the last occurence of
{\it ch
}.
475 Returns the whole string if
{\it ch
} is not found.
477 \membersection{wxString::BeforeFirst
}\label{wxstringbeforefirst
}
479 \constfunc{wxString
}{BeforeFirst
}{\param{char
}{ ch
}}
481 Gets all characters before the first occurence of
{\it ch
}.
482 Returns the whole string if
{\it ch
} is not found.
484 \membersection{wxString::BeforeLast
}\label{wxstringbeforelast
}
486 \constfunc{wxString
}{BeforeLast
}{\param{char
}{ ch
}}
488 Gets all characters before the last occurence of
{\it ch
}.
489 Returns the empty string if
{\it ch
} is not found.
491 \membersection{wxString::c
\_str}\label{wxstringcstr
}
493 \constfunc{const char *
}{c
\_str}{\void}
495 Returns a pointer to the string data.
497 \membersection{wxString::Clear
}\label{wxstringclear
}
499 \func{void
}{Clear
}{\void}
501 Empties the string and frees memory occupied by it.
503 See also:
\helpref{Empty
}{wxstringempty
}
505 \membersection{wxString::Cmp
}\label{wxstringcmp
}
507 \constfunc{int
}{Cmp
}{\param{const char*
}{ psz
}}
509 Case-sensitive comparison.
511 Returns a positive value if the string is greater than the argument, zero if
512 it si equal to it or negative value if it is less than argument (same semantics
513 as the standard
{\it strcmp()
} function).
515 See also
\helpref{CmpNoCase
}{wxstringcmpnocase
},
\helpref{IsSameAs
}{wxstringissameas
}.
517 \membersection{wxString::CmpNoCase
}\label{wxstringcmpnocase
}
519 \constfunc{int
}{CmpNoCase
}{\param{const char*
}{ psz
}}
521 Case-insensitive comparison.
523 Returns a positive value if the string is greater than the argument, zero if
524 it si equal to it or negative value if it is less than argument (same semantics
525 as the standard
{\it strcmp()
} function).
527 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{IsSameAs
}{wxstringissameas
}.
529 \membersection{wxString::CompareTo
}\label{wxstringcompareto
}
532 #define NO_POS ((int)(-
1)) // undefined position
533 enum caseCompare
{exact, ignoreCase
};
536 \constfunc{int
}{CompareTo
}{\param{const char*
}{ psz
},
\param{caseCompare
}{ cmp = exact
}}
538 Case-sensitive comparison. Returns
0 if equal,
1 if greater or -
1 if less.
540 \membersection{wxString::Contains
}\label{wxstringcontains
}
542 \constfunc{bool
}{Contains
}{\param{const wxString\&
}{ str
}}
544 Returns
1 if target appears anyhere in wxString; else
0.
546 \membersection{wxString::Empty
}\label{wxstringempty
}
548 \func{void
}{Empty
}{\void}
550 Makes the string empty, but doesn't free memory occupied by the string.
552 See also:
\helpref{Clear()
}{wxstringclear
}.
554 \membersection{wxString::Find
}\label{wxstringfind
}
556 \constfunc{int
}{Find
}{\param{char
}{ ch
},
\param{bool
}{ fromEnd = FALSE
}}
558 Searches for the given character. Returns the starting index, or -
1 if not found.
560 \constfunc{int
}{Find
}{\param{const char*
}{ sz
}}
562 Searches for the given string. Returns the starting index, or -
1 if not found.
564 \membersection{wxString::First
}\label{wxstringfirst
}
566 \func{size
\_t}{First
}{\param{char
}{ c
}}
568 \constfunc{size
\_t}{First
}{\param{const char*
}{ psz
}}
570 \constfunc{size
\_t}{First
}{\param{const wxString\&
}{ str
}}
572 \constfunc{size
\_t}{First
}{\param{const char
}{ ch
}}
574 Returns the first occurrence of the item.
576 \membersection{wxString::Format
}\label{wxstringformat
}
578 \func{static wxString
}{Format
}{\param{const wxChar
}{*format
},
\param{}{...
}}
580 This static function returns the string containing the result of calling
581 \helpref{Printf
}{wxstringprintf
} with the passed parameters on it.
585 \helpref{FormatV
}{wxstringformatv
},
\helpref{Printf
}{wxstringprintf
}
587 \membersection{wxString::FormatV
}\label{wxstringformatv
}
589 \func{static wxString
}{Format
}{\param{const wxChar
}{*format
},
\param{va
\_list }{argptr
}}
591 This static function returns the string containing the result of calling
592 \helpref{PrintfV
}{wxstringprintfv
} with the passed parameters on it.
596 \helpref{Format
}{wxstringformat
},
\helpref{PrintfV
}{wxstringprintfv
}
598 \membersection{wxString::Freq
}\label{wxstringfreq
}
600 \constfunc{int
}{Frec
}{\param{char
}{ch
}}
602 Returns the number of occurences of
{it ch
} in the string.
604 \membersection{wxString::GetChar
}\label{wxstringgetchar
}
606 \constfunc{char
}{GetChar
}{\param{size
\_t}{ n
}}
608 Returns the character at position
{\it n
} (read-only).
610 \membersection{wxString::GetData
}\label{wxstringgetdata
}
612 \constfunc{const char*
}{GetData
}{\void}
614 wxWindows compatibility conversion. Returns a constant pointer to the data in the string.
616 \membersection{wxString::GetWritableChar
}\label{wxstringgetwritablechar
}
618 \func{char\&
}{GetWritableChar
}{\param{size
\_t}{ n
}}
620 Returns a reference to the character at position
{\it n
}.
622 \membersection{wxString::GetWriteBuf
}\label{wxstringgetwritebuf
}
624 \func{char*
}{GetWriteBuf
}{\param{size
\_t}{ len
}}
626 Returns a writable buffer of at least
{\it len
} bytes.
628 Call
\helpref{wxString::UngetWriteBuf
}{wxstringungetwritebuf
} as soon as possible
629 to put the string back into a reasonable state.
631 \membersection{wxString::Index
}\label{wxstringindex
}
633 \constfunc{size
\_t}{Index
}{\param{char
}{ ch
},
\param{int
}{ startpos =
0}}
635 Same as
\helpref{wxString::Find
}{wxstringfind
}.
637 \constfunc{size
\_t}{Index
}{\param{const char*
}{ sz
}}
639 Same as
\helpref{wxString::Find
}{wxstringfind
}.
641 \constfunc{size
\_t}{Index
}{\param{const char*
}{ sz
},
\param{bool
}{ caseSensitive = TRUE
},
\param{bool
}{ fromEnd = FALSE
}}
643 Search the element in the array, starting from either side.
645 If
{\it fromEnd
} is TRUE, reverse search direction.
647 If
{\bf caseSensitive
}, comparison is case sensitive (the default).
649 Returns the index of the first item matched, or NOT
\_FOUND.
652 %\membersection{wxString::insert}\label{wxstringinsert}
654 %\func{void}{insert}{\param{const wxString\&}{ str}, \param{size\_t}{ index}}
656 %Add new element at the given position.
658 \membersection{wxString::IsAscii
}\label{wxstringisascii
}
660 \constfunc{bool
}{IsAscii
}{\void}
662 Returns TRUE if the string is ASCII.
664 \membersection{wxString::IsEmpty
}\label{wxstringisempty
}
666 \constfunc{bool
}{IsEmpty
}{\void}
668 Returns TRUE if the string is NULL.
670 \membersection{wxString::IsNull
}\label{wxstringisnull
}
672 \constfunc{bool
}{IsNull
}{\void}
674 Returns TRUE if the string is NULL (same as IsEmpty).
676 \membersection{wxString::IsNumber
}\label{wxstringisnumber
}
678 \constfunc{bool
}{IsNumber
}{\void}
680 Returns TRUE if the string is a number.
682 \membersection{wxString::IsSameAs
}\label{wxstringissameas
}
684 \constfunc{bool
}{IsSameAs
}{\param{const char*
}{ psz
},
\param{bool
}{ caseSensitive = TRUE
}}
686 Test for string equality, case-sensitive (default) or not.
688 caseSensitive is TRUE by default (case matters).
690 Returns TRUE if strings are equal, FALSE otherwise.
692 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{CmpNoCase
}{wxstringcmpnocase
},
\helpref{IsSameAs
}{wxstringissameas2
}
694 \membersection{wxString::IsSameAs
}\label{wxstringissameas2
}
696 \constfunc{bool
}{IsSameAs
}{\param{char
}{ c
},
\param{bool
}{ caseSensitive = TRUE
}}
698 Test whether the string is equal to the single character
{\it c
}. The test is
699 case-sensitive if
{\it caseSensitive
} is TRUE (default) or not if it is FALSE.
701 Returns TRUE if the string is equal to the character, FALSE otherwise.
703 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{CmpNoCase
}{wxstringcmpnocase
},
\helpref{IsSameAs
}{wxstringissameas
}
705 \membersection{wxString::IsWord
}\label{wxstringisword
}
707 \constfunc{bool
}{IsWord
}{\void}
709 Returns TRUE if the string is a word. TODO: what's the definition of a word?
711 \membersection{wxString::Last
}\label{wxstringlast
}
713 \constfunc{char
}{Last
}{\void}
715 Returns the last character.
717 \func{char\&
}{Last
}{\void}
719 Returns a reference to the last character (writable).
721 \membersection{wxString::Left
}\label{wxstringleft
}
723 \constfunc{wxString
}{Left
}{\param{size
\_t}{ count
}}
725 Returns the first
{\it count
} characters.
727 \constfunc{wxString
}{Left
}{\param{char
}{ ch
}}
729 Returns all characters before the first occurence of
{\it ch
}.
730 Returns the whole string if
{\it ch
} is not found.
732 \membersection{wxString::Len
}\label{wxstringlen
}
734 \constfunc{size
\_t}{Len
}{\void}
736 Returns the length of the string.
738 \membersection{wxString::Length
}\label{wxstringlength
}
740 \constfunc{size
\_t}{Length
}{\void}
742 Returns the length of the string (same as Len).
744 \membersection{wxString::Lower
}\label{wxstringlower
}
746 \constfunc{wxString
}{Lower
}{\void}
748 Returns this string converted to the lower case.
750 \membersection{wxString::LowerCase
}\label{wxstringlowercase
}
752 \func{void
}{LowerCase
}{\void}
756 \membersection{wxString::MakeLower
}\label{wxstringmakelower
}
758 \func{void
}{MakeLower
}{\void}
760 Converts all characters to lower case.
762 \membersection{wxString::MakeUpper
}\label{wxstringmakeupper
}
764 \func{void
}{MakeUpper
}{\void}
766 Converts all characters to upper case.
768 \membersection{wxString::Matches
}\label{wxstringmatches
}
770 \constfunc{bool
}{Matches
}{\param{const char*
}{ szMask
}}
772 Returns TRUE if the string contents matches a mask containing '*' and '?'.
774 \membersection{wxString::Mid
}\label{wxstringmid
}
776 \constfunc{wxString
}{Mid
}{\param{size
\_t}{ first
},
\param{size
\_t}{ count = wxSTRING
\_MAXLEN}}
778 Returns a substring starting at
{\it first
}, with length
{\it count
}, or the rest of
779 the string if
{\it count
} is the default value.
781 \membersection{wxString::Pad
}\label{wxstringpad
}
783 \func{wxString\&
}{Pad
}{\param{size
\_t}{ count
},
\param{char
}{ pad = ' '
},
\param{bool
}{ fromRight = TRUE
}}
785 Adds
{\it count
} copies of
{\it pad
} to the beginning, or to the end of the string (the default).
787 Removes spaces from the left or from the right (default).
789 \membersection{wxString::Prepend
}\label{wxstringprepend
}
791 \func{wxString\&
}{Prepend
}{\param{const wxString\&
}{ str
}}
793 Prepends
{\it str
} to this string, returning a reference to this string.
795 \membersection{wxString::Printf
}\label{wxstringprintf
}
797 \func{int
}{Printf
}{\param{const char*
}{pszFormat
},
\param{}{...
}}
799 Similar to the standard function
{\it sprintf()
}. Returns the number of
800 characters written, or an integer less than zero on error.
802 {\bf NB:
} This function will use a safe version of
{\it vsprintf()
} (usually called
803 {\it vsnprintf()
}) whenever available to always allocate the buffer of correct
804 size. Unfortunately, this function is not available on all platforms and the
805 dangerous
{\it vsprintf()
} will be used then which may lead to buffer overflows.
807 \membersection{wxString::PrintfV
}\label{wxstringprintfv
}
809 \func{int
}{PrintfV
}{\param{const char*
}{pszFormat
},
\param{va
\_list}{ argPtr
}}
811 Similar to vprintf. Returns the number of characters written, or an integer less than zero
814 \membersection{wxString::Remove
}\label{wxstringremove
}
816 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
}}
818 Same as Truncate. Removes the portion from
{\it pos
} to the end of the string.
820 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
},
\param{size
\_t}{ len
}}
822 Removes the last
{\it len
} characters from the string, starting at
{\it pos
}.
824 \membersection{wxString::RemoveLast
}\label{wxstringremovelast
}
826 \func{wxString\&
}{RemoveLast
}{\void}
828 Removes the last character.
830 \membersection{wxString::Replace
}\label{wxstringreplace
}
832 \func{size
\_t}{Replace
}{\param{const char*
}{ szOld
},
\param{const char*
}{ szNew
},
\param{bool
}{ replaceAll = TRUE
}}
834 Replace first (or all) occurences of substring with another one.
836 {\it replaceAll
}: global replace (default), or only the first occurence.
838 Returns the number of replacements made.
840 \membersection{wxString::Right
}\label{wxstringright
}
842 \constfunc{wxString
}{Right
}{\param{size
\_t}{ count
}}
844 Returns the last
{\it count
} characters.
846 \membersection{wxString::SetChar
}\label{wxstringsetchar
}
848 \func{void
}{SetChar
}{\param{size
\_t}{ n
},
\param{char
}{ch
}}
850 Sets the character at position
{\it n
}.
852 \membersection{wxString::Shrink
}\label{wxstringshrink
}
854 \func{void
}{Shrink
}{\void}
856 Minimizes the string's memory. This can be useful after a call to
857 \helpref{Alloc()
}{wxstringalloc
} if too much memory were preallocated.
859 \membersection{wxString::sprintf
}\label{wxstringsprintf
}
861 \func{void
}{sprintf
}{\param{const char*
}{ fmt
}}
865 \membersection{wxString::Strip
}\label{wxstringstrip
}
868 enum stripType
{leading =
0x1, trailing =
0x2, both =
0x3};
871 \constfunc{wxString
}{Strip
}{\param{stripType
}{ s = trailing
}}
873 Strip characters at the front and/or end. The same as Trim except that it
874 doesn't change this string.
876 \membersection{wxString::SubString
}\label{wxstringsubstring
}
878 \constfunc{wxString
}{SubString
}{\param{size
\_t}{ to
},
\param{size
\_t}{ from
}}
880 Same as
\helpref{Mid
}{wxstringmid
}.
882 \membersection{wxString::ToDouble
}\label{wxstringtodouble
}
884 \constfunc{bool
}{To
}{\param{double
}{ *val
}}
886 Attempts to convert the string to a floating point number. Returns TRUE on
887 suceess (the number is stored in the location pointed to by
{\it val
}) or FALSE
888 if the string does not represent such number.
890 \membersection{wxString::ToLong
}\label{wxstringtolong
}
892 \constfunc{bool
}{To
}{\param{long
}{ *val
}}
894 Attempts to convert the string to a signed integer. Returns TRUE on suceess
895 (the number is stored in the location pointed to by
{\it val
}) or FALSE if the
896 string does not represent such number.
898 \membersection{wxString::ToULong
}\label{wxstringtoulong
}
900 \constfunc{bool
}{To
}{\param{unsigned long
}{ *val
}}
902 Attempts to convert the string to an unsigned integer. Returns TRUE on suceess
903 (the number is stored in the location pointed to by
{\it val
}) or FALSE if the
904 string does not represent such number.
906 \membersection{wxString::Trim
}\label{wxstringtrim
}
908 \func{wxString\&
}{Trim
}{\param{bool
}{ fromRight = TRUE
}}
910 Removes spaces from the left or from the right (default).
912 \membersection{wxString::Truncate
}\label{wxstringtruncate
}
914 \func{wxString\&
}{Truncate
}{\param{size
\_t}{ len
}}
916 Truncate the string to the given length.
918 \membersection{wxString::UngetWriteBuf
}\label{wxstringungetwritebuf
}
920 \func{void
}{UngetWriteBuf
}{\void}
922 Puts the string back into a reasonable state, after
923 \rtfsp\helpref{wxString::GetWriteBuf
}{wxstringgetwritebuf
} was called.
925 \membersection{wxString::Upper
}\label{wxstringupper
}
927 \constfunc{wxString
}{Upper
}{\void}
929 Returns this string converted to upper case.
931 \membersection{wxString::UpperCase
}\label{wxstringuppercase
}
933 \func{void
}{UpperCase
}{\void}
935 The same as MakeUpper.
937 \membersection{wxString::operator!
}\label{wxstringoperatornot
}
939 \constfunc{bool
}{operator!
}{\void}
941 Empty string is FALSE, so !string will only return TRUE if the string is empty.
942 This allows the tests for NULLness of a
{\it const char *
} pointer and emptyness
943 of the string to look the same in the code and makes it easier to port old code
946 See also
\helpref{IsEmpty()
}{wxstringisempty
}.
948 \membersection{wxString::operator $=$
}\label{wxstringoperatorassign
}
950 \func{wxString\&
}{operator $=$
}{\param{const wxString\&
}{ str
}}
952 \func{wxString\&
}{operator $=$
}{\param{const char*
}{ psz
}}
954 \func{wxString\&
}{operator $=$
}{\param{char
}{ c
}}
956 \func{wxString\&
}{operator $=$
}{\param{const unsigned char*
}{ psz
}}
958 \func{wxString\&
}{operator $=$
}{\param{const wchar
\_t*
}{ pwz
}}
960 Assignment: the effect of each operation is the same as for the corresponding
961 constructor (see
\helpref{wxString constructors
}{wxstringconstruct
}).
963 \membersection{operator wxString::$+$
}\label{wxstringoperatorplus
}
965 Concatenation: all these operators return a new strign equal to the sum of the
968 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
970 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ y
}}
972 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{char
}{ y
}}
974 \func{wxString
}{operator $+$
}{\param{const char*
}{ x
},
\param{const wxString\&
}{ y
}}
976 \membersection{wxString::operator $+=$
}\label{wxstringplusequal
}
978 \func{void
}{operator $+=$
}{\param{const wxString\&
}{ str
}}
980 \func{void
}{operator $+=$
}{\param{const char*
}{ psz
}}
982 \func{void
}{operator $+=$
}{\param{char
}{ c
}}
984 Concatenation in place: the argument is appended to the string.
986 \membersection{wxString::operator
[]}\label{wxstringoperatorbracket
}
988 \func{char\&
}{operator
[]}{\param{size
\_t}{ i
}}
990 \func{char
}{operator
[]}{\param{size
\_t}{ i
}}
992 \func{char
}{operator
[]}{\param{int
}{ i
}}
996 \membersection{wxString::operator ()
}\label{wxstringoperatorparenth
}
998 \func{wxString
}{operator ()
}{\param{size
\_t}{ start
},
\param{size
\_t}{ len
}}
1000 Same as Mid (substring extraction).
1002 \membersection{wxString::operator
\cinsert}\label{wxstringoperatorout
}
1004 \func{wxString\&
}{operator
\cinsert}{\param{const wxString\&
}{ str
}}
1006 \func{wxString\&
}{operator
\cinsert}{\param{const char*
}{ psz
}}
1008 \func{wxString\&
}{operator
\cinsert}{\param{char
}{ch
}}
1012 \func{wxString\&
}{operator
\cinsert}{\param{int
}{ i
}}
1014 \func{wxString\&
}{operator
\cinsert}{\param{float
}{ f
}}
1016 \func{wxString\&
}{operator
\cinsert}{\param{double
}{ d
}}
1018 These functions work as C++ stream insertion operators: they insert the given
1019 value into the string. Precision or format cannot be set using them, you can use
1020 \helpref{Printf
}{wxstringprintf
} for this.
1022 \membersection{wxString::operator
\cextract}\label{wxstringoperatorin
}
1024 \func{friend istream\&
}{operator
\cextract}{\param{istream\&
}{ is
},
\param{wxString\&
}{ str
}}
1026 Extraction from a stream.
1028 \membersection{wxString::operator const char*
}\label{wxstringoperatorconstcharpt
}
1030 \constfunc{}{operator const char*
}{\void}
1032 Implicit conversion to a C string.
1034 \membersection{Comparison operators
}\label{wxstringcomparison
}
1036 \func{bool
}{operator $==$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1038 \func{bool
}{operator $==$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1040 \func{bool
}{operator $!=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1042 \func{bool
}{operator $!=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1044 \func{bool
}{operator $>$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1046 \func{bool
}{operator $>$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1048 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1050 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1052 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1054 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1056 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1058 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1062 These comparisons are case-sensitive.