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
9 there (except that wxString is sensitive to null character).
11 You may notice that wxString sometimes has many functions which do the same
12 thing like, for example,
\helpref{Length()
}{wxstringlength
},
13 \helpref{Len()
}{wxstringlen
} and
{\tt length()
} which all return the string
14 length. In all cases of such duplication the
{\tt std::string
}-compatible
15 method (
{\tt length()
} in this case, always the lowercase version) should be
16 used as it will ensure smoother transition to
{\tt std::string
} when wxWidgets
17 starts using it instead of wxString.
19 Also please note that in this manual
\texttt{char
} is sometimes used instead of
20 \texttt{wxChar
} because it hasn't been fully updated yet. Please substitute as
21 necessary and refer to the sources in case of a doubt.
24 \wxheading{Derived from
}
28 \wxheading{Include files
}
32 \wxheading{Predefined objects
}
40 \overview{Overview
}{wxstringoverview
}
42 \latexignore{\rtfignore{\wxheading{Function groups
}}}
45 \membersection{Constructors and assignment operators
}\label{constructorsinwxstring
}
47 A string may be constructed either from a C string, (some number of copies of)
48 a single character or a wide (UNICODE) string. For all constructors (except the
49 default which creates an empty string) there is also a corresponding assignment
52 \helpref{wxString
}{wxstringconstruct
}\\
53 \helpref{operator $=$
}{wxstringoperatorassign
}\\
54 \helpref{\destruct{wxString
}}{wxstringdestruct
}
57 \membersection{String length
}\label{lengthfunctionsinwxstring
}
59 These functions return the string length and check whether the string is empty
62 \helpref{Len
}{wxstringlen
}\\
63 \helpref{IsEmpty
}{wxstringisempty
}\\
64 \helpref{operator!
}{wxstringoperatornot
}\\
65 \helpref{Empty
}{wxstringempty
}\\
66 \helpref{Clear
}{wxstringclear
}
69 \membersection{Character access
}\label{characteraccessinwxstring
}
71 Many functions in this section take a character index in the string. As with C
72 strings and/or arrays, the indices start from $
0$, so the first character of a
73 string is string
[$
0$
]. Attempt to access a character beyond the end of the
74 string (which may be even $
0$ if the string is empty) will provoke an assert
75 failure in
\helpref{debug build
}{debuggingoverview
}, but no checks are done in
78 This section also contains both implicit and explicit conversions to C style
79 strings. Although implicit conversion is quite convenient, it is advised to use
80 explicit
\helpref{c
\_str()
}{wxstringcstr
} method for the sake of clarity. Also
81 see
\helpref{overview
}{wxstringadvices
} for the cases where it is necessary to
84 \helpref{GetChar
}{wxstringgetchar
}\\
85 \helpref{GetWritableChar
}{wxstringgetwritablechar
}\\
86 \helpref{SetChar
}{wxstringsetchar
}\\
87 \helpref{Last
}{wxstringlast
}\\
88 \helpref{operator
[]}{wxstringoperatorbracket
}\\
89 \helpref{c
\_str}{wxstringcstr
}\\
90 \helpref{mb
\_str}{wxstringmbstr
}\\
91 \helpref{wc
\_str}{wxstringwcstr
}\\
92 \helpref{fn
\_str}{wxstringfnstr
}\\
93 \helpref{operator const char*
}{wxstringoperatorconstcharpt
}
96 \membersection{Concatenation
}\label{concatenationinwxstring
}
98 Anything may be concatenated (appended to) with a string. However, you can't
99 append something to a C string (including literal constants), so to do this it
100 should be converted to a wxString first.
102 \helpref{operator
\cinsert}{wxstringoperatorout
}\\
103 \helpref{operator $+=$
}{wxstringplusequal
}\\
104 \helpref{operator $+$
}{wxstringoperatorplus
}\\
105 \helpref{Append
}{wxstringappend
}\\
106 \helpref{Prepend
}{wxstringprepend
}
109 \membersection{Comparison
}\label{comparisoninwxstring
}
111 The default comparison function
\helpref{Cmp
}{wxstringcmp
} is case-sensitive and
112 so is the default version of
\helpref{IsSameAs
}{wxstringissameas
}. For case
113 insensitive comparisons you should use
\helpref{CmpNoCase
}{wxstringcmpnocase
} or
114 give a second parameter to IsSameAs. This last function is may be more
115 convenient if only equality of the strings matters because it returns a boolean
116 true value if the strings are the same and not
0 (which is usually false in C)
119 \helpref{Matches
}{wxstringmatches
} is a poor man's regular expression matcher:
120 it only understands '*' and '?' metacharacters in the sense of DOS command line
123 \helpref{StartsWith
}{wxstringstartswith
} is helpful when parsing a line of
124 text which should start with some predefined prefix and is more efficient than
125 doing direct string comparison as you would also have to precalculate the
126 length of the prefix then.
128 \helpref{Cmp
}{wxstringcmp
}\\
129 \helpref{CmpNoCase
}{wxstringcmpnocase
}\\
130 \helpref{IsSameAs
}{wxstringissameas
}\\
131 \helpref{Matches
}{wxstringmatches
}\\
132 \helpref{StartsWith
}{wxstringstartswith
}\\
133 \helpref{EndsWith
}{wxstringendswith
}
136 \membersection{Substring extraction
}\label{substringextractioninwxstring
}
138 These functions allow to extract substring from this string. All of them don't
139 modify the original string and return a new string containing the extracted
142 \helpref{Mid
}{wxstringmid
}\\
143 \helpref{operator()
}{wxstringoperatorparenth
}\\
144 \helpref{Left
}{wxstringleft
}\\
145 \helpref{Right
}{wxstringright
}\\
146 \helpref{BeforeFirst
}{wxstringbeforefirst
}\\
147 \helpref{BeforeLast
}{wxstringbeforelast
}\\
148 \helpref{AfterFirst
}{wxstringafterfirst
}\\
149 \helpref{AfterLast
}{wxstringafterlast
}\\
150 \helpref{StartsWith
}{wxstringstartswith
}\\
151 \helpref{EndsWith
}{wxstringendswith
}
155 \membersection{Case conversion
}\label{caseconversioninwxstring
}
157 The MakeXXX() variants modify the string in place, while the other functions
158 return a new string which contains the original text converted to the upper or
159 lower case and leave the original string unchanged.
161 \helpref{MakeUpper
}{wxstringmakeupper
}\\
162 \helpref{Upper
}{wxstringupper
}\\
163 \helpref{MakeLower
}{wxstringmakelower
}\\
164 \helpref{Lower
}{wxstringlower
}
167 \membersection{Searching and replacing
}\label{searchingandreplacinginwxstring
}
169 These functions replace the standard
{\it strchr()
} and
{\it strstr()
}
172 \helpref{Find
}{wxstringfind
}\\
173 \helpref{Replace
}{wxstringreplace
}
176 \membersection{Conversion to numbers
}\label{conversiontonumbersinwxstring
}
178 The string provides functions for conversion to signed and unsigned integer and
179 floating point numbers. All three functions take a pointer to the variable to
180 put the numeric value in and return true if the
{\bf entire
} string could be
181 converted to a number.
183 \helpref{ToLong
}{wxstringtolong
}\\
184 \helpref{ToULong
}{wxstringtoulong
}\\
185 \helpref{ToDouble
}{wxstringtodouble
}
188 \membersection{Writing values into the string
}\label{writingintostringinwxstring
}
190 Both formatted versions (
\helpref{Printf
}{wxstringprintf
}) and stream-like
191 insertion operators exist (for basic types only). Additionally, the
192 \helpref{Format
}{wxstringformat
} function allows to use simply append
193 formatted value to a string:
196 // the following
2 snippets are equivalent
199 s += wxString::Format("
%d", n);
202 s.Printf("...
%d", n);
205 \helpref{Format
}{wxstringformat
}\\
206 \helpref{FormatV
}{wxstringformatv
}\\
207 \helpref{Printf
}{wxstringprintf
}\\
208 \helpref{PrintfV
}{wxstringprintfv
}\\
209 \helpref{operator
\cinsert}{wxstringoperatorout
}
212 \membersection{Memory management
}\label{memoryinwxstring
}
214 These are "advanced" functions and they will be needed quite rarely.
215 \helpref{Alloc
}{wxstringalloc
} and
\helpref{Shrink
}{wxstringshrink
} are only
216 interesting for optimization purposes.
217 \helpref{GetWriteBuf
}{wxstringgetwritebuf
} may be very useful when working with
218 some external API which requires the caller to provide a writable buffer, but
219 extreme care should be taken when using it: before performing any other
220 operation on the string
\helpref{UngetWriteBuf
}{wxstringungetwritebuf
} {\bf
223 \helpref{Alloc
}{wxstringalloc
}\\
224 \helpref{Shrink
}{wxstringshrink
}\\
225 \helpref{GetWriteBuf
}{wxstringgetwritebuf
}\\
226 \helpref{UngetWriteBuf
}{wxstringungetwritebuf
}
229 \membersection{Miscellaneous
}\label{miscellaneousinwxstring
}
231 Other string functions.
233 \helpref{Trim
}{wxstringtrim
}\\
234 \helpref{Pad
}{wxstringpad
}\\
235 \helpref{Truncate
}{wxstringtruncate
}
238 \membersection{wxWidgets
1.xx compatibility functions
}\label{backwardcompatibilityinwxstring
}
240 These functions are deprecated, please consider using new wxWidgets
2.0
241 functions instead of them (or, even better, std::string compatible variants).
243 \helpref{SubString
}{wxstringsubstring
}\\
244 \helpref{sprintf
}{wxstringsprintf
}\\
245 \helpref{CompareTo
}{wxstringcompareto
}\\
246 \helpref{Length
}{wxstringlength
}\\
247 \helpref{Freq
}{wxstringfreq
}\\
248 \helpref{LowerCase
}{wxstringlowercase
}\\
249 \helpref{UpperCase
}{wxstringuppercase
}\\
250 \helpref{Strip
}{wxstringstrip
}\\
251 \helpref{Index
}{wxstringindex
}\\
252 \helpref{Remove
}{wxstringremove
}\\
253 \helpref{First
}{wxstringfirst
}\\
254 \helpref{Last
}{wxstringlast
}\\
255 \helpref{Contains
}{wxstringcontains
}\\
256 \helpref{IsNull
}{wxstringisnull
}\\
257 \helpref{IsAscii
}{wxstringisascii
}\\
258 \helpref{IsNumber
}{wxstringisnumber
}\\
259 \helpref{IsWord
}{wxstringisword
}
262 \membersection{std::string compatibility functions
}\label{wxstringat
}
264 The supported functions are only listed here, please see any STL reference for
268 // take nLen chars starting at nPos
269 wxString(const wxString& str, size_t nPos, size_t nLen);
270 // take all characters from pStart to pEnd (poor man's iterators)
271 wxString(const void *pStart, const void *pEnd);
273 // lib.string.capacity
274 // return the length of the string
276 // return the length of the string
277 size_t length() const;
278 // return the maximum size of the string
279 size_t max_size() const;
280 // resize the string, filling the space with c if c !=
0
281 void resize(size_t nSize, char ch = '
\0');
282 // delete the contents of the string
284 // returns true if the string is empty
288 // return the character at position n
289 char at(size_t n) const;
290 // returns the writable character at position n
293 // lib.string.modifiers
295 wxString& append(const wxString& str);
296 // append elements str
[pos
], ..., str
[pos+n
]
297 wxString& append(const wxString& str, size_t pos, size_t n);
298 // append first n (or all if n == npos) characters of sz
299 wxString& append(const char *sz, size_t n = npos);
301 // append n copies of ch
302 wxString& append(size_t n, char ch);
304 // same as `this_string = str'
305 wxString& assign(const wxString& str);
306 // same as ` = str
[pos..pos + n
]
307 wxString& assign(const wxString& str, size_t pos, size_t n);
308 // same as `= first n (or all if n == npos) characters of sz'
309 wxString& assign(const char *sz, size_t n = npos);
310 // same as `= n copies of ch'
311 wxString& assign(size_t n, char ch);
313 // insert another string
314 wxString& insert(size_t nPos, const wxString& str);
315 // insert n chars of str starting at nStart (in str)
316 wxString& insert(size_t nPos, const wxString& str, size_t nStart, size_t n);
318 // insert first n (or all if n == npos) characters of sz
319 wxString& insert(size_t nPos, const char *sz, size_t n = npos);
320 // insert n copies of ch
321 wxString& insert(size_t nPos, size_t n, char ch);
323 // delete characters from nStart to nStart + nLen
324 wxString& erase(size_t nStart =
0, size_t nLen = npos);
326 // replaces the substring of length nLen starting at nStart
327 wxString& replace(size_t nStart, size_t nLen, const char* sz);
328 // replaces the substring with nCount copies of ch
329 wxString& replace(size_t nStart, size_t nLen, size_t nCount, char ch);
330 // replaces a substring with another substring
331 wxString& replace(size_t nStart, size_t nLen,
332 const wxString& str, size_t nStart2, size_t nLen2);
333 // replaces the substring with first nCount chars of sz
334 wxString& replace(size_t nStart, size_t nLen,
335 const char* sz, size_t nCount);
338 void swap(wxString& str);
340 // All find() functions take the nStart argument which specifies the
341 // position to start the search on, the default value is
0. All functions
342 // return npos if there were no match.
345 size_t find(const wxString& str, size_t nStart =
0) const;
347 // find first n characters of sz
348 size_t find(const char* sz, size_t nStart =
0, size_t n = npos) const;
350 // find the first occurrence of character ch after nStart
351 size_t find(char ch, size_t nStart =
0) const;
353 // rfind() family is exactly like find() but works right to left
355 // as find, but from the end
356 size_t rfind(const wxString& str, size_t nStart = npos) const;
358 // as find, but from the end
359 size_t rfind(const char* sz, size_t nStart = npos,
360 size_t n = npos) const;
361 // as find, but from the end
362 size_t rfind(char ch, size_t nStart = npos) const;
364 // find first/last occurrence of any character in the set
367 size_t find_first_of(const wxString& str, size_t nStart =
0) const;
369 size_t find_first_of(const char* sz, size_t nStart =
0) const;
370 // same as find(char, size_t)
371 size_t find_first_of(char c, size_t nStart =
0) const;
373 size_t find_last_of (const wxString& str, size_t nStart = npos) const;
375 size_t find_last_of (const char* s, size_t nStart = npos) const;
376 // same as rfind(char, size_t)
377 size_t find_last_of (char c, size_t nStart = npos) const;
379 // find first/last occurrence of any character not in the set
382 size_t find_first_not_of(const wxString& str, size_t nStart =
0) const;
384 size_t find_first_not_of(const char* s, size_t nStart =
0) const;
386 size_t find_first_not_of(char ch, size_t nStart =
0) const;
388 size_t find_last_not_of(const wxString& str, size_t nStart=npos) const;
390 size_t find_last_not_of(const char* s, size_t nStart = npos) const;
392 size_t find_last_not_of(char ch, size_t nStart = npos) const;
394 // All compare functions return a negative, zero or positive value
395 // if the
[sub
]string is less, equal or greater than the compare() argument.
397 // just like strcmp()
398 int compare(const wxString& str) const;
399 // comparison with a substring
400 int compare(size_t nStart, size_t nLen, const wxString& str) const;
401 // comparison of
2 substrings
402 int compare(size_t nStart, size_t nLen,
403 const wxString& str, size_t nStart2, size_t nLen2) const;
404 // just like strcmp()
405 int compare(const char* sz) const;
406 // substring comparison with first nCount characters of sz
407 int compare(size_t nStart, size_t nLen,
408 const char* sz, size_t nCount = npos) const;
410 // substring extraction
411 wxString substr(size_t nStart =
0, size_t nLen = npos) const;
414 %%%%% MEMBERS HERE %%%%%
415 \helponly{\insertatlevel{2}{
422 \membersection{wxString::wxString
}\label{wxstringconstruct
}
424 \func{}{wxString
}{\void}
426 Default constructor. Initializes the string to
{\tt ""
} (empty string).
428 \func{}{wxString
}{\param{const wxString\&
}{ x
}}
432 \func{}{wxString
}{\param{char
}{ ch
},
\param{size
\_t}{ n =
1}}
434 Constructs a string of
{\it n
} copies of character
{\it ch
}.
436 \func{}{wxString
}{\param{const char*
}{ psz
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
438 Takes first
{\it nLength
} characters from the C string
{\it psz
}.
439 The default value of
{\tt wxSTRING
\_MAXLEN} means to take all the string.
441 Note that this constructor may be used even if
{\it psz
} points to a buffer
442 with binary data (i.e. containing
{\tt NUL
} characters) as long as you provide
443 the correct value for
{\it nLength
}. However, the default form of it works
444 only with strings without intermediate
{\tt NUL
}s because it uses
445 {\tt strlen()
} to calculate the effective length and it would not give correct
448 \func{}{wxString
}{\param{const unsigned char*
}{ psz
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
450 For compilers using unsigned char: takes first
{\it nLength
} characters from the C string
{\it psz
}.
451 The default value of
{\tt wxSTRING
\_MAXLEN} means take all the string.
453 {\bf Note:
} In Unicode build, all of the above constructors take
454 {\tt wchar
\_t} arguments instead of
{\tt char
}.
456 \wxheading{Constructors with conversion
}
458 The following constructors allow you to construct wxString from wide string
459 in ANSI build or from C string in Unicode build.
461 \func{}{wxString
}{\param{const wchar
\_t*
}{ psz
},
\param{wxMBConv\&
}{ conv
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
463 Initializes the string from first
\arg{nLength
} characters of wide string.
464 The default value of
{\tt wxSTRING
\_MAXLEN} means take all the string.
465 In ANSI build,
\arg{conv
}'s
466 \helpref{WC2MB
}{wxmbconvwc2mb
} method is called to
467 convert
\arg{psz
} to wide string. It is ignored in Unicode build.
469 \func{}{wxString
}{\param{const char*
}{ psz
},
\param{wxMBConv\&
}{ conv
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
471 Initializes the string from first
\arg{nLength
} characters of C string.
472 The default value of
{\tt wxSTRING
\_MAXLEN} means take all the string.
473 In Unicode build,
\arg{conv
}'s
474 \helpref{MB2WC
}{wxmbconvmb2wc
} method is called to
475 convert
\arg{psz
} to wide string. It is ignored in ANSI build.
479 \helpref{wxMBConv classes
}{mbconvclasses
},
\helpref{mb
\_str}{wxstringmbstr
},
480 \helpref{wc
\_str}{wxstringwcstr
}
483 \membersection{wxString::
\destruct{wxString
}}\label{wxstringdestruct
}
485 \func{}{\destruct{wxString
}}{\void}
487 String destructor. Note that this is not virtual, so wxString must not be inherited from.
490 \membersection{wxString::Alloc
}\label{wxstringalloc
}
492 \func{void
}{Alloc
}{\param{size
\_t}{ nLen
}}
494 Preallocate enough space for wxString to store
{\it nLen
} characters. This function
495 may be used to increase speed when the string is constructed by repeated
500 // delete all vowels from the string
501 wxString DeleteAllVowels(const wxString& original)
505 size_t len = original.length();
509 for ( size_t n =
0; n < len; n++ )
511 if ( strchr("aeuio", tolower(original
[n
])) == NULL )
512 result += original
[n
];
520 because it will avoid the need to reallocate string memory many times (in case
521 of long strings). Note that it does not set the maximal length of a string - it
522 will still expand if more than
{\it nLen
} characters are stored in it. Also, it
523 does not truncate the existing string (use
524 \helpref{Truncate()
}{wxstringtruncate
} for this) even if its current length is
525 greater than
{\it nLen
}
528 \membersection{wxString::Append
}\label{wxstringappend
}
530 \func{wxString\&
}{Append
}{\param{const char*
}{ psz
}}
532 Concatenates
{\it psz
} to this string, returning a reference to it.
534 \func{wxString\&
}{Append
}{\param{char
}{ ch
},
\param{int
}{ count =
1}}
536 Concatenates character
{\it ch
} to this string,
{\it count
} times, returning a reference
540 \membersection{wxString::AfterFirst
}\label{wxstringafterfirst
}
542 \constfunc{wxString
}{AfterFirst
}{\param{char
}{ ch
}}
544 Gets all the characters after the first occurrence of
{\it ch
}.
545 Returns the empty string if
{\it ch
} is not found.
548 \membersection{wxString::AfterLast
}\label{wxstringafterlast
}
550 \constfunc{wxString
}{AfterLast
}{\param{char
}{ ch
}}
552 Gets all the characters after the last occurrence of
{\it ch
}.
553 Returns the whole string if
{\it ch
} is not found.
556 \membersection{wxString::BeforeFirst
}\label{wxstringbeforefirst
}
558 \constfunc{wxString
}{BeforeFirst
}{\param{char
}{ ch
}}
560 Gets all characters before the first occurrence of
{\it ch
}.
561 Returns the whole string if
{\it ch
} is not found.
564 \membersection{wxString::BeforeLast
}\label{wxstringbeforelast
}
566 \constfunc{wxString
}{BeforeLast
}{\param{char
}{ ch
}}
568 Gets all characters before the last occurrence of
{\it ch
}.
569 Returns the empty string if
{\it ch
} is not found.
572 \membersection{wxString::c
\_str}\label{wxstringcstr
}
574 \constfunc{const wxChar *
}{c
\_str}{\void}
576 Returns a pointer to the string data (
{\tt const char*
} in ANSI build,
577 {\tt const wchar
\_t*
} in Unicode build).
581 \helpref{mb
\_str}{wxstringmbstr
},
\helpref{wc
\_str}{wxstringwcstr
},
582 \helpref{fn
\_str}{wxstringfnstr
}
585 \membersection{wxString::Clear
}\label{wxstringclear
}
587 \func{void
}{Clear
}{\void}
589 Empties the string and frees memory occupied by it.
591 See also:
\helpref{Empty
}{wxstringempty
}
594 \membersection{wxString::Cmp
}\label{wxstringcmp
}
596 \constfunc{int
}{Cmp
}{\param{const wxString\&
}{ s
}}
598 \constfunc{int
}{Cmp
}{\param{const char*
}{ psz
}}
600 Case-sensitive comparison.
602 Returns a positive value if the string is greater than the argument, zero if
603 it is equal to it or a negative value if it is less than the argument (same semantics
604 as the standard
{\it strcmp()
} function).
606 See also
\helpref{CmpNoCase
}{wxstringcmpnocase
},
\helpref{IsSameAs
}{wxstringissameas
}.
609 \membersection{wxString::CmpNoCase
}\label{wxstringcmpnocase
}
611 \constfunc{int
}{CmpNoCase
}{\param{const wxString\&
}{ s
}}
613 \constfunc{int
}{CmpNoCase
}{\param{const char*
}{ psz
}}
615 Case-insensitive comparison.
617 Returns a positive value if the string is greater than the argument, zero if
618 it is equal to it or a negative value if it is less than the argument (same semantics
619 as the standard
{\it strcmp()
} function).
621 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{IsSameAs
}{wxstringissameas
}.
624 \membersection{wxString::CompareTo
}\label{wxstringcompareto
}
627 #define NO_POS ((int)(-
1)) // undefined position
628 enum caseCompare
{exact, ignoreCase
};
631 \constfunc{int
}{CompareTo
}{\param{const char*
}{ psz
},
\param{caseCompare
}{ cmp = exact
}}
633 Case-sensitive comparison. Returns
0 if equal,
1 if greater or -
1 if less.
636 \membersection{wxString::Contains
}\label{wxstringcontains
}
638 \constfunc{bool
}{Contains
}{\param{const wxString\&
}{ str
}}
640 Returns
1 if target appears anywhere in wxString; else
0.
643 \membersection{wxString::Empty
}\label{wxstringempty
}
645 \func{void
}{Empty
}{\void}
647 Makes the string empty, but doesn't free memory occupied by the string.
649 See also:
\helpref{Clear()
}{wxstringclear
}.
652 \membersection{wxString::Find
}\label{wxstringfind
}
654 \constfunc{int
}{Find
}{\param{char
}{ ch
},
\param{bool
}{ fromEnd = false
}}
656 Searches for the given character. Returns the starting index, or -
1 if not found.
658 \constfunc{int
}{Find
}{\param{const char*
}{ sz
}}
660 Searches for the given string. Returns the starting index, or -
1 if not found.
663 \membersection{wxString::First
}\label{wxstringfirst
}
665 \func{int
}{First
}{\param{char
}{ c
}}
667 \constfunc{int
}{First
}{\param{const char*
}{ psz
}}
669 \constfunc{int
}{First
}{\param{const wxString\&
}{ str
}}
671 Same as
\helpref{Find
}{wxstringfind
}.
674 \membersection{wxString::fn
\_str}\label{wxstringfnstr
}
676 \constfunc{const wchar
\_t*
}{fn
\_str}{\void}
678 \constfunc{const char*
}{fn
\_str}{\void}
680 \constfunc{const wxCharBuffer
}{fn
\_str}{\void}
682 Returns string representation suitable for passing to OS' functions for
683 file handling. In ANSI build, this is same as
\helpref{c
\_str}{wxstringcstr
}.
684 In Unicode build, returned value can be either wide character string
685 or C string in charset matching the
{\tt wxConvFileName
} object, depending on
690 \helpref{wxMBConv
}{wxmbconv
},
691 \helpref{wc
\_str}{wxstringwcstr
},
\helpref{mb
\_str}{wxstringwcstr
}
694 \membersection{wxString::Format
}\label{wxstringformat
}
696 \func{static wxString
}{Format
}{\param{const wxChar
}{*format
},
\param{}{...
}}
698 This static function returns the string containing the result of calling
699 \helpref{Printf
}{wxstringprintf
} with the passed parameters on it.
703 \helpref{FormatV
}{wxstringformatv
},
\helpref{Printf
}{wxstringprintf
}
706 \membersection{wxString::FormatV
}\label{wxstringformatv
}
708 \func{static wxString
}{FormatV
}{\param{const wxChar
}{*format
},
\param{va
\_list }{argptr
}}
710 This static function returns the string containing the result of calling
711 \helpref{PrintfV
}{wxstringprintfv
} with the passed parameters on it.
715 \helpref{Format
}{wxstringformat
},
\helpref{PrintfV
}{wxstringprintfv
}
718 \membersection{wxString::Freq
}\label{wxstringfreq
}
720 \constfunc{int
}{Freq
}{\param{char
}{ch
}}
722 Returns the number of occurrences of
{\it ch
} in the string.
725 \membersection{wxString::FromAscii
}\label{wxstringfromascii
}
727 \func{static wxString
}{FromAscii
}{\param{const char*
}{ s
}}
729 \func{static wxString
}{FromAscii
}{\param{const char
}{ c
}}
731 Converts the string or character from an ASCII,
7-bit form
732 to the native wxString representation. Most useful when using
733 a Unicode build of wxWidgets.
734 Use
\helpref{wxString constructors
}{wxstringconstruct
} if you
735 need to convert from another charset.
738 \membersection{wxString::GetChar
}\label{wxstringgetchar
}
740 \constfunc{char
}{GetChar
}{\param{size
\_t}{ n
}}
742 Returns the character at position
{\it n
} (read-only).
745 \membersection{wxString::GetData
}\label{wxstringgetdata
}
747 \constfunc{const wxChar*
}{GetData
}{\void}
749 wxWidgets compatibility conversion. Returns a constant pointer to the data in the string.
752 \membersection{wxString::GetWritableChar
}\label{wxstringgetwritablechar
}
754 \func{char\&
}{GetWritableChar
}{\param{size
\_t}{ n
}}
756 Returns a reference to the character at position
{\it n
}.
759 \membersection{wxString::GetWriteBuf
}\label{wxstringgetwritebuf
}
761 \func{wxChar*
}{GetWriteBuf
}{\param{size
\_t}{ len
}}
763 Returns a writable buffer of at least
{\it len
} bytes.
764 It returns a pointer to a new memory block, and the
765 existing data will not be copied.
767 Call
\helpref{wxString::UngetWriteBuf
}{wxstringungetwritebuf
} as soon as possible
768 to put the string back into a reasonable state.
771 \membersection{wxString::Index
}\label{wxstringindex
}
773 \constfunc{size
\_t}{Index
}{\param{char
}{ ch
}}
775 \constfunc{size
\_t}{Index
}{\param{const char*
}{ sz
}}
777 Same as
\helpref{wxString::Find
}{wxstringfind
}.
780 %\membersection{wxString::insert}\label{wxstringinsert}
782 %\func{void}{insert}{\param{const wxString\&}{ str}, \param{size\_t}{ index}}
784 %Add new element at the given position.
787 \membersection{wxString::IsAscii
}\label{wxstringisascii
}
789 \constfunc{bool
}{IsAscii
}{\void}
791 Returns true if the string contains only ASCII characters.
794 \membersection{wxString::IsEmpty
}\label{wxstringisempty
}
796 \constfunc{bool
}{IsEmpty
}{\void}
798 Returns true if the string is empty.
801 \membersection{wxString::IsNull
}\label{wxstringisnull
}
803 \constfunc{bool
}{IsNull
}{\void}
805 Returns true if the string is empty (same as
\helpref{IsEmpty
}{wxstringisempty
}).
808 \membersection{wxString::IsNumber
}\label{wxstringisnumber
}
810 \constfunc{bool
}{IsNumber
}{\void}
812 Returns true if the string is an integer (with possible sign).
815 \membersection{wxString::IsSameAs
}\label{wxstringissameas
}
817 \constfunc{bool
}{IsSameAs
}{\param{const char*
}{ psz
},
\param{bool
}{ caseSensitive = true
}}
819 Test for string equality, case-sensitive (default) or not.
821 caseSensitive is true by default (case matters).
823 Returns true if strings are equal, false otherwise.
825 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{CmpNoCase
}{wxstringcmpnocase
}
827 \constfunc{bool
}{IsSameAs
}{\param{char
}{ c
},
\param{bool
}{ caseSensitive = true
}}
829 Test whether the string is equal to the single character
{\it c
}. The test is
830 case-sensitive if
{\it caseSensitive
} is true (default) or not if it is false.
832 Returns true if the string is equal to the character, false otherwise.
834 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{CmpNoCase
}{wxstringcmpnocase
}
837 \membersection{wxString::IsWord
}\label{wxstringisword
}
839 \constfunc{bool
}{IsWord
}{\void}
841 Returns true if the string is a word. TODO: what's the definition of a word?
844 \membersection{wxString::Last
}\label{wxstringlast
}
846 \constfunc{char
}{Last
}{\void}
848 Returns the last character.
850 \func{char\&
}{Last
}{\void}
852 Returns a reference to the last character (writable).
855 \membersection{wxString::Left
}\label{wxstringleft
}
857 \constfunc{wxString
}{Left
}{\param{size
\_t}{ count
}}
859 Returns the first
{\it count
} characters of the string.
862 \membersection{wxString::Len
}\label{wxstringlen
}
864 \constfunc{size
\_t}{Len
}{\void}
866 Returns the length of the string.
869 \membersection{wxString::Length
}\label{wxstringlength
}
871 \constfunc{size
\_t}{Length
}{\void}
873 Returns the length of the string (same as Len).
876 \membersection{wxString::Lower
}\label{wxstringlower
}
878 \constfunc{wxString
}{Lower
}{\void}
880 Returns this string converted to the lower case.
883 \membersection{wxString::LowerCase
}\label{wxstringlowercase
}
885 \func{void
}{LowerCase
}{\void}
890 \membersection{wxString::MakeLower
}\label{wxstringmakelower
}
892 \func{wxString\&
}{MakeLower
}{\void}
894 Converts all characters to lower case and returns the result.
897 \membersection{wxString::MakeUpper
}\label{wxstringmakeupper
}
899 \func{wxString\&
}{MakeUpper
}{\void}
901 Converts all characters to upper case and returns the result.
904 \membersection{wxString::Matches
}\label{wxstringmatches
}
906 \constfunc{bool
}{Matches
}{\param{const char*
}{ szMask
}}
908 Returns true if the string contents matches a mask containing '*' and '?'.
911 \membersection{wxString::mb
\_str}\label{wxstringmbstr
}
913 \constfunc{const char*
}{mb
\_str}{\param{wxMBConv\&
}{ conv
}}
915 \constfunc{const wxCharBuffer
}{mb
\_str}{\param{wxMBConv\&
}{ conv
}}
917 Returns multibyte (C string) representation of the string.
918 In Unicode build, converts using
\arg{conv
}'s
\helpref{cWC2MB
}{wxmbconvcwc2mb
}
919 method and returns wxCharBuffer. In ANSI build, this function is same
920 as
\helpref{c
\_str}{wxstringcstr
}.
921 The macro wxWX2MBbuf is defined as the correct return type (without const).
925 \helpref{wxMBConv
}{wxmbconv
},
926 \helpref{c
\_str}{wxstringcstr
},
\helpref{wc
\_str}{wxstringwcstr
},
927 \helpref{fn
\_str}{wxstringfnstr
}
930 \membersection{wxString::Mid
}\label{wxstringmid
}
932 \constfunc{wxString
}{Mid
}{\param{size
\_t}{ first
},
\param{size
\_t}{ count = wxSTRING
\_MAXLEN}}
934 Returns a substring starting at
{\it first
}, with length
{\it count
}, or the rest of
935 the string if
{\it count
} is the default value.
938 \membersection{wxString::Pad
}\label{wxstringpad
}
940 \func{wxString\&
}{Pad
}{\param{size
\_t}{ count
},
\param{char
}{ pad = ' '
},
\param{bool
}{ fromRight = true
}}
942 Adds
{\it count
} copies of
{\it pad
} to the beginning, or to the end of the string (the default).
944 Removes spaces from the left or from the right (default).
947 \membersection{wxString::Prepend
}\label{wxstringprepend
}
949 \func{wxString\&
}{Prepend
}{\param{const wxString\&
}{ str
}}
951 Prepends
{\it str
} to this string, returning a reference to this string.
954 \membersection{wxString::Printf
}\label{wxstringprintf
}
956 \func{int
}{Printf
}{\param{const char*
}{pszFormat
},
\param{}{...
}}
958 Similar to the standard function
{\it sprintf()
}. Returns the number of
959 characters written, or an integer less than zero on error.
961 Note that if
{\tt wxUSE
\_PRINTF\_POS\_PARAMS} is set to
1, then this function supports
962 Unix98-style positional parameters:
967 str.Printf(wxT("
%d %d %d"), 1, 2, 3);
968 // str now contains "
1 2 3"
970 str.Printf(wxT("
%2$d %3$d %1$d"), 1, 2, 3);
971 // str now contains "
2 3 1"
974 {\bf NB:
} This function will use a safe version of
{\it vsprintf()
} (usually called
975 {\it vsnprintf()
}) whenever available to always allocate the buffer of correct
976 size. Unfortunately, this function is not available on all platforms and the
977 dangerous
{\it vsprintf()
} will be used then which may lead to buffer overflows.
980 \membersection{wxString::PrintfV
}\label{wxstringprintfv
}
982 \func{int
}{PrintfV
}{\param{const char*
}{pszFormat
},
\param{va
\_list}{ argPtr
}}
984 Similar to vprintf. Returns the number of characters written, or an integer less than zero
988 \membersection{wxString::Remove
}\label{wxstringremove
}
990 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
}}
992 Same as Truncate. Removes the portion from
{\it pos
} to the end of the string.
994 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
},
\param{size
\_t}{ len
}}
996 Removes
{\it len
} characters from the string, starting at
{\it pos
}.
999 \membersection{wxString::RemoveLast
}\label{wxstringremovelast
}
1001 \func{wxString\&
}{RemoveLast
}{\void}
1003 Removes the last character.
1006 \membersection{wxString::Replace
}\label{wxstringreplace
}
1008 \func{size
\_t}{Replace
}{\param{const char*
}{ szOld
},
\param{const char*
}{ szNew
},
\param{bool
}{ replaceAll = true
}}
1010 Replace first (or all) occurrences of substring with another one.
1012 {\it replaceAll
}: global replace (default), or only the first occurrence.
1014 Returns the number of replacements made.
1017 \membersection{wxString::Right
}\label{wxstringright
}
1019 \constfunc{wxString
}{Right
}{\param{size
\_t}{ count
}}
1021 Returns the last
{\it count
} characters.
1024 \membersection{wxString::SetChar
}\label{wxstringsetchar
}
1026 \func{void
}{SetChar
}{\param{size
\_t}{ n
},
\param{char
}{ch
}}
1028 Sets the character at position
{\it n
}.
1031 \membersection{wxString::Shrink
}\label{wxstringshrink
}
1033 \func{void
}{Shrink
}{\void}
1035 Minimizes the string's memory. This can be useful after a call to
1036 \helpref{Alloc()
}{wxstringalloc
} if too much memory were preallocated.
1039 \membersection{wxString::sprintf
}\label{wxstringsprintf
}
1041 \func{void
}{sprintf
}{\param{const char*
}{ fmt
}}
1046 \membersection{wxString::StartsWith
}\label{wxstringstartswith
}
1048 \constfunc{bool
}{StartsWith
}{\param{const wxChar
}{*prefix
},
\param{wxString
}{*rest = NULL
}}
1050 This function can be used to test if the string starts with the specified
1051 {\it prefix
}. If it does, the function will return
{\tt true
} and put the rest
1052 of the string (i.e. after the prefix) into
{\it rest
} string if it is not
1053 {\tt NULL
}. Otherwise, the function returns
{\tt false
} and doesn't modify the
1057 \membersection{wxString::EndsWith
}\label{wxstringendswith
}
1059 \constfunc{bool
}{EndsWith
}{\param{const wxChar
}{*suffix
},
\param{wxString
}{*rest = NULL
}}
1061 This function can be used to test if the string ends with the specified
1062 {\it suffix
}. If it does, the function will return
{\tt true
} and put the
1063 beginning of the string before the suffix into
{\it rest
} string if it is not
1064 {\tt NULL
}. Otherwise, the function returns
{\tt false
} and doesn't
1065 modify the
{\it rest
}.
1068 \membersection{wxString::Strip
}\label{wxstringstrip
}
1071 enum stripType
{leading =
0x1, trailing =
0x2, both =
0x3};
1074 \constfunc{wxString
}{Strip
}{\param{stripType
}{ s = trailing
}}
1076 Strip characters at the front and/or end. The same as Trim except that it
1077 doesn't change this string.
1080 \membersection{wxString::SubString
}\label{wxstringsubstring
}
1082 \constfunc{wxString
}{SubString
}{\param{size
\_t}{ from
},
\param{size
\_t}{ to
}}
1084 Deprecated, use
\helpref{Mid
}{wxstringmid
} instead (but note that parameters
1085 have different meaning).
1087 Returns the part of the string between the indices
{\it from
} and
{\it to
}
1091 \membersection{wxString::ToAscii
}\label{wxstringtoascii
}
1093 \constfunc{const char*
}{ToAscii
}{\void}
1095 Converts the string to an ASCII,
7-bit string (ANSI builds only).
1097 \constfunc{const wxCharBuffer
}{ToAscii
}{\void}
1099 Converts the string to an ASCII,
7-bit string in the form of
1100 a wxCharBuffer (Unicode builds only).
1102 Note that this conversion only works if the string contains only ASCII
1103 characters. The
\helpref{mb
\_str}{wxstringmbstr
} method provides more
1104 powerful means of converting wxString to C string.
1107 \membersection{wxString::ToDouble
}\label{wxstringtodouble
}
1109 \constfunc{bool
}{ToDouble
}{\param{double
}{ *val
}}
1111 Attempts to convert the string to a floating point number. Returns true on
1112 success (the number is stored in the location pointed to by
{\it val
}) or false
1113 if the string does not represent such number.
1115 \wxheading{See also
}
1117 \helpref{wxString::ToLong
}{wxstringtolong
},\\
1118 \helpref{wxString::ToULong
}{wxstringtoulong
}
1121 \membersection{wxString::ToLong
}\label{wxstringtolong
}
1123 \constfunc{bool
}{ToLong
}{\param{long
}{ *val
},
\param{int
}{base = $
10$
}}
1125 Attempts to convert the string to a signed integer in base
{\it base
}. Returns
1126 {\tt true
} on success in which case the number is stored in the location
1127 pointed to by
{\it val
} or
{\tt false
} if the string does not represent a
1128 valid number in the given base.
1130 The value of
{\it base
} must be comprised between $
2$ and $
36$, inclusive, or
1131 be a special value $
0$ which means that the usual rules of
{\tt C
} numbers are
1132 applied: if the number starts with
{\tt 0x
} it is considered to be in base
1133 $
16$, if it starts with
{\tt 0} - in base $
8$ and in base $
10$ otherwise. Note
1134 that you may not want to specify the base $
0$ if you are parsing the numbers
1135 which may have leading zeroes as they can yield unexpected (to the user not
1136 familiar with C) results.
1138 \wxheading{See also
}
1140 \helpref{wxString::ToDouble
}{wxstringtodouble
},\\
1141 \helpref{wxString::ToULong
}{wxstringtoulong
}
1144 \membersection{wxString::ToLongLong
}\label{wxstringtolonglong
}
1146 \constfunc{bool
}{ToLongLong
}{\param{wxLongLong
\_t}{ *val
},
\param{int
}{base = $
10$
}}
1148 This is exactly the same as
\helpref{ToLong
}{wxstringtolong
} but works with
64
1149 bit integer numbers.
1151 Notice that currently it doesn't work (always returns
\false) if parsing of
64
1152 bit numbers is not supported by the underlying C run-time library. Compilers
1153 with C99 support and Microsoft Visual C++ version
7 and higher do support this.
1155 \wxheading{See also
}
1157 \helpref{wxString::ToLong
}{wxstringtolong
},\\
1158 \helpref{wxString::ToULongLong
}{wxstringtoulonglong
}
1161 \membersection{wxString::ToULong
}\label{wxstringtoulong
}
1163 \constfunc{bool
}{ToULong
}{\param{unsigned long
}{ *val
},
\param{int
}{base = $
10$
}}
1165 Attempts to convert the string to an unsigned integer in base
{\it base
}.
1166 Returns
{\tt true
} on success in which case the number is stored in the
1167 location pointed to by
{\it val
} or
{\tt false
} if the string does not
1168 represent a valid number in the given base. Please notice that this function
1169 behaves in the same way as the standard
\texttt{strtoul()
} and so it simply
1170 converts negative numbers to unsigned representation instead of rejecting them
1171 (e.g. $-
1$ is returned as
\texttt{ULONG
\_MAX}).
1173 See
\helpref{wxString::ToLong
}{wxstringtolong
} for the more detailed
1174 description of the
{\it base
} parameter.
1176 \wxheading{See also
}
1178 \helpref{wxString::ToDouble
}{wxstringtodouble
},\\
1179 \helpref{wxString::ToLong
}{wxstringtolong
}
1182 \membersection{wxString::ToULongLong
}\label{wxstringtoulonglong
}
1184 \constfunc{bool
}{ToULongLong
}{\param{wxULongLong
\_t}{ *val
},
\param{int
}{base = $
10$
}}
1186 This is exactly the same as
\helpref{ToULong
}{wxstringtoulong
} but works with
64
1187 bit integer numbers.
1189 Please see
\helpref{ToLongLong
}{wxstringtolonglong
} for additional remarks.
1192 \membersection{wxString::Trim
}\label{wxstringtrim
}
1194 \func{wxString\&
}{Trim
}{\param{bool
}{ fromRight = true
}}
1196 Removes white-space (space, tabs, form feed, newline and carriage return) from
1197 the left or from the right end of the string (right is default).
1200 \membersection{wxString::Truncate
}\label{wxstringtruncate
}
1202 \func{wxString\&
}{Truncate
}{\param{size
\_t}{ len
}}
1204 Truncate the string to the given length.
1207 \membersection{wxString::UngetWriteBuf
}\label{wxstringungetwritebuf
}
1209 \func{void
}{UngetWriteBuf
}{\void}
1211 \func{void
}{UngetWriteBuf
}{\param{size
\_t }{len
}}
1213 Puts the string back into a reasonable state (in which it can be used
1215 \rtfsp\helpref{wxString::GetWriteBuf
}{wxstringgetwritebuf
} was called.
1217 The version of the function without the
{\it len
} parameter will calculate the
1218 new string length itself assuming that the string is terminated by the first
1219 {\tt NUL
} character in it while the second one will use the specified length
1220 and thus is the only version which should be used with the strings with
1221 embedded
{\tt NUL
}s (it is also slightly more efficient as
{\tt strlen()
}
1222 doesn't have to be called).
1225 \membersection{wxString::Upper
}\label{wxstringupper
}
1227 \constfunc{wxString
}{Upper
}{\void}
1229 Returns this string converted to upper case.
1232 \membersection{wxString::UpperCase
}\label{wxstringuppercase
}
1234 \func{void
}{UpperCase
}{\void}
1236 The same as MakeUpper.
1239 \membersection{wxString::wc
\_str}\label{wxstringwcstr
}
1241 \constfunc{const wchar
\_t*
}{wc
\_str}{\param{wxMBConv\&
}{ conv
}}
1243 \constfunc{const wxWCharBuffer
}{wc
\_str}{\param{wxMBConv\&
}{ conv
}}
1245 Returns wide character representation of the string.
1246 In ANSI build, converts using
\arg{conv
}'s
\helpref{cMB2WC
}{wxmbconvcmb2wc
}
1247 method and returns wxWCharBuffer. In Unicode build, this function is same
1248 as
\helpref{c
\_str}{wxstringcstr
}.
1249 The macro wxWX2WCbuf is defined as the correct return type (without const).
1251 \wxheading{See also
}
1253 \helpref{wxMBConv
}{wxmbconv
},
1254 \helpref{c
\_str}{wxstringcstr
},
\helpref{mb
\_str}{wxstringwcstr
},
1255 \helpref{fn
\_str}{wxstringfnstr
}
1258 \membersection{wxString::operator!
}\label{wxstringoperatornot
}
1260 \constfunc{bool
}{operator!
}{\void}
1262 Empty string is false, so !string will only return true if the string is empty.
1263 This allows the tests for NULLness of a
{\it const char *
} pointer and emptiness
1264 of the string to look the same in the code and makes it easier to port old code
1267 See also
\helpref{IsEmpty()
}{wxstringisempty
}.
1270 \membersection{wxString::operator $=$
}\label{wxstringoperatorassign
}
1272 \func{wxString\&
}{operator $=$
}{\param{const wxString\&
}{ str
}}
1274 \func{wxString\&
}{operator $=$
}{\param{const char*
}{ psz
}}
1276 \func{wxString\&
}{operator $=$
}{\param{char
}{ c
}}
1278 \func{wxString\&
}{operator $=$
}{\param{const unsigned char*
}{ psz
}}
1280 \func{wxString\&
}{operator $=$
}{\param{const wchar
\_t*
}{ pwz
}}
1282 Assignment: the effect of each operation is the same as for the corresponding
1283 constructor (see
\helpref{wxString constructors
}{wxstringconstruct
}).
1286 \membersection{wxString::operator $+$
}\label{wxstringoperatorplus
}
1288 Concatenation: all these operators return a new string equal to the
1289 concatenation of the operands.
1291 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1293 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ y
}}
1295 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{char
}{ y
}}
1297 \func{wxString
}{operator $+$
}{\param{const char*
}{ x
},
\param{const wxString\&
}{ y
}}
1300 \membersection{wxString::operator $+=$
}\label{wxstringplusequal
}
1302 \func{void
}{operator $+=$
}{\param{const wxString\&
}{ str
}}
1304 \func{void
}{operator $+=$
}{\param{const char*
}{ psz
}}
1306 \func{void
}{operator $+=$
}{\param{char
}{ c
}}
1308 Concatenation in place: the argument is appended to the string.
1311 \membersection{wxString::operator
[]}\label{wxstringoperatorbracket
}
1313 \func{wxChar\&
}{operator
[]}{\param{size
\_t}{ i
}}
1315 \constfunc{wxChar
}{operator
[]}{\param{size
\_t}{ i
}}
1317 \func{wxChar\&
}{operator
[]}{\param{int
}{ i
}}
1319 \constfunc{wxChar
}{operator
[]}{\param{int
}{ i
}}
1324 \membersection{wxString::operator ()
}\label{wxstringoperatorparenth
}
1326 \func{wxString
}{operator ()
}{\param{size
\_t}{ start
},
\param{size
\_t}{ len
}}
1328 Same as Mid (substring extraction).
1331 \membersection{wxString::operator
\cinsert}\label{wxstringoperatorout
}
1333 \func{wxString\&
}{operator
\cinsert}{\param{const wxString\&
}{ str
}}
1335 \func{wxString\&
}{operator
\cinsert}{\param{const char*
}{ psz
}}
1337 \func{wxString\&
}{operator
\cinsert}{\param{char
}{ch
}}
1341 \func{wxString\&
}{operator
\cinsert}{\param{int
}{ i
}}
1343 \func{wxString\&
}{operator
\cinsert}{\param{float
}{ f
}}
1345 \func{wxString\&
}{operator
\cinsert}{\param{double
}{ d
}}
1347 These functions work as C++ stream insertion operators: they insert the given
1348 value into the string. Precision or format cannot be set using them, you can use
1349 \helpref{Printf
}{wxstringprintf
} for this.
1352 \membersection{wxString::operator
\cextract}\label{wxstringoperatorin
}
1354 \func{friend istream\&
}{operator
\cextract}{\param{istream\&
}{ is
},
\param{wxString\&
}{ str
}}
1356 Extraction from a stream.
1359 \membersection{wxString::operator const char*
}\label{wxstringoperatorconstcharpt
}
1361 \constfunc{}{operator const char*
}{\void}
1363 Implicit conversion to a C string.
1366 \membersection{Comparison operators
}\label{wxstringcomparison
}
1368 \func{bool
}{operator $==$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1370 \func{bool
}{operator $==$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1372 \func{bool
}{operator $!=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1374 \func{bool
}{operator $!=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1376 \func{bool
}{operator $>$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1378 \func{bool
}{operator $>$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1380 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1382 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1384 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1386 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1388 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1390 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1394 These comparisons are case-sensitive.
1397 \section{\class{wxStringBuffer
}}\label{wxstringbuffer
}
1399 This tiny class allows to conveniently access the
\helpref{wxString
}{wxstring
}
1400 internal buffer as a writable pointer without any risk of forgetting to restore
1401 the string to the usable state later.
1403 For example, assuming you have a low-level OS function called
1404 {\tt GetMeaningOfLifeAsString(char *)
} returning the value in the provided
1405 buffer (which must be writable, of course) you might call it like this:
1409 GetMeaningOfLifeAsString(wxStringBuffer(theAnswer,
1024));
1410 if ( theAnswer != "
42" )
1412 wxLogError("Something is very wrong!");
1416 Note that the exact usage of this depends on whether on not wxUSE
\_STL is enabled. If
1417 wxUSE
\_STL is enabled, wxStringBuffer creates a separate empty character buffer, and
1418 if wxUSE
\_STL is disabled, it uses GetWriteBuf() from wxString, keeping the same buffer
1419 wxString uses intact. In other words, relying on wxStringBuffer containing the old
1420 wxString data is probably not a good idea if you want to build your program in both
1421 with and without wxUSE
\_STL.
1423 \wxheading{Derived from
}
1427 \wxheading{Include files
}
1431 \latexignore{\rtfignore{\wxheading{Members
}}}
1434 \membersection{wxStringBuffer::wxStringBuffer
}\label{wxstringbufferctor
}
1436 \func{}{wxStringBuffer
}{\param{const wxString\&
}{str
},
\param{size
\_t }{len
}}
1438 Constructs a writable string buffer object associated with the given string
1439 and containing enough space for at least
{\it len
} characters. Basically, this
1440 is equivalent to calling
\helpref{GetWriteBuf
}{wxstringgetwritebuf
} and
1444 \membersection{wxStringBuffer::
\destruct{wxStringBuffer
}}\label{wxstringbufferdtor
}
1446 \func{}{\destruct{wxStringBuffer
}}{\void}
1448 Restores the string passed to the constructor to the usable state by calling
1449 \helpref{UngetWriteBuf
}{wxstringungetwritebuf
} on it.
1452 \membersection{wxStringBuffer::operator wxChar *
}\label{wxstringbufferwxchar
}
1454 \func{wxChar *
}{operator wxChar *
}{\void}
1456 Returns the writable pointer to a buffer of the size at least equal to the
1457 length specified in the constructor.
1461 \section{\class{wxStringBufferLength
}}\label{wxstringbufferlength
}
1463 This tiny class allows to conveniently access the
\helpref{wxString
}{wxstring
}
1464 internal buffer as a writable pointer without any risk of forgetting to restore
1465 the string to the usable state later, and allows the user to set the internal
1466 length of the string.
1468 For example, assuming you have a low-level OS function called
1469 {\tt int GetMeaningOfLifeAsString(char *)
} copying the value in the provided
1470 buffer (which must be writable, of course), and returning the actual length
1471 of the string, you might call it like this:
1475 wxStringBuffer theAnswerBuffer(theAnswer,
1024);
1476 int nLength = GetMeaningOfLifeAsString(theAnswerBuffer);
1477 theAnswerBuffer.SetLength(nLength);
1478 if ( theAnswer != "
42" )
1480 wxLogError("Something is very wrong!");
1484 Note that the exact usage of this depends on whether on not wxUSE
\_STL is enabled. If
1485 wxUSE
\_STL is enabled, wxStringBuffer creates a separate empty character buffer, and
1486 if wxUSE
\_STL is disabled, it uses GetWriteBuf() from wxString, keeping the same buffer
1487 wxString uses intact. In other words, relying on wxStringBuffer containing the old
1488 wxString data is probably not a good idea if you want to build your program in both
1489 with and without wxUSE
\_STL.
1491 Note that SetLength
{\tt must
} be called before wxStringBufferLength destructs.
1493 \wxheading{Derived from
}
1497 \wxheading{Include files
}
1501 \latexignore{\rtfignore{\wxheading{Members
}}}
1504 \membersection{wxStringBufferLength::wxStringBufferLength
}\label{wxstringbufferlengthctor
}
1506 \func{}{wxStringBufferLength
}{\param{const wxString\&
}{str
},
\param{size
\_t }{len
}}
1508 Constructs a writable string buffer object associated with the given string
1509 and containing enough space for at least
{\it len
} characters. Basically, this
1510 is equivalent to calling
\helpref{GetWriteBuf
}{wxstringgetwritebuf
} and
1514 \membersection{wxStringBufferLength::
\destruct{wxStringBufferLength
}}\label{wxstringbufferlengthdtor
}
1516 \func{}{\destruct{wxStringBufferLength
}}{\void}
1518 Restores the string passed to the constructor to the usable state by calling
1519 \helpref{UngetWriteBuf
}{wxstringungetwritebuf
} on it.
1522 \membersection{wxStringBufferLength::SetLength
}\label{wxstringbufferlengthsetlength
}
1524 \func{void
}{SetLength
}{\param{size
\_t }{nLength
}}
1526 Sets the internal length of the string referred to by wxStringBufferLength to
1527 {\it nLength
} characters.
1529 Must be called before wxStringBufferLength destructs.
1532 \membersection{wxStringBufferLength::operator wxChar *
}\label{wxstringbufferlengthwxchar
}
1534 \func{wxChar *
}{operator wxChar *
}{\void}
1536 Returns the writable pointer to a buffer of the size at least equal to the
1537 length specified in the constructor.