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 \wxheading{Derived from
}
23 \wxheading{Include files
}
27 \wxheading{Predefined objects
}
35 \overview{Overview
}{wxstringoverview
}
37 \latexignore{\rtfignore{\wxheading{Function groups
}}}
39 \membersection{Constructors and assignment operators
}\label{constructorsinwxstring
}
41 A string may be constructed either from a C string, (some number of copies of)
42 a single character or a wide (UNICODE) string. For all constructors (except the
43 default which creates an empty string) there is also a corresponding assignment
46 \helpref{wxString
}{wxstringconstruct
}\\
47 \helpref{operator $=$
}{wxstringoperatorassign
}\\
48 \helpref{\destruct{wxString
}}{wxstringdestruct
}
50 \membersection{String length
}\label{lengthfunctionsinwxstring
}
52 These functions return the string length and check whether the string is empty
55 \helpref{Len
}{wxstringlen
}\\
56 \helpref{IsEmpty
}{wxstringisempty
}\\
57 \helpref{operator!
}{wxstringoperatornot
}\\
58 \helpref{Empty
}{wxstringempty
}\\
59 \helpref{Clear
}{wxstringclear
}
61 \membersection{Character access
}\label{characteraccessinwxstring
}
63 Many functions in this section take a character index in the string. As with C
64 strings and/or arrays, the indices start from $
0$, so the first character of a
65 string is string
[$
0$
]. Attempt to access a character beyond the end of the
66 string (which may be even $
0$ if the string is empty) will provoke an assert
67 failure in
\helpref{debug build
}{debuggingoverview
}, but no checks are done in
70 This section also contains both implicit and explicit conversions to C style
71 strings. Although implicit conversion is quite convenient, it is advised to use
72 explicit
\helpref{c
\_str()
}{wxstringcstr
} method for the sake of clarity. Also
73 see
\helpref{overview
}{wxstringadvices
} for the cases where it is necessary to
76 \helpref{GetChar
}{wxstringgetchar
}\\
77 \helpref{GetWritableChar
}{wxstringgetwritablechar
}\\
78 \helpref{SetChar
}{wxstringsetchar
}\\
79 \helpref{Last
}{wxstringlast
}\\
80 \helpref{operator
[]}{wxstringoperatorbracket
}\\
81 \helpref{c
\_str}{wxstringcstr
}\\
82 \helpref{mb
\_str}{wxstringmbstr
}\\
83 \helpref{wc
\_str}{wxstringwcstr
}\\
84 \helpref{fn
\_str}{wxstringfnstr
}\\
85 \helpref{operator const char*
}{wxstringoperatorconstcharpt
}
87 \membersection{Concatenation
}\label{concatenationinwxstring
}
89 Anything may be concatenated (appended to) with a string. However, you can't
90 append something to a C string (including literal constants), so to do this it
91 should be converted to a wxString first.
93 \helpref{operator
\cinsert}{wxstringoperatorout
}\\
94 \helpref{operator $+=$
}{wxstringplusequal
}\\
95 \helpref{operator $+$
}{wxstringoperatorplus
}\\
96 \helpref{Append
}{wxstringappend
}\\
97 \helpref{Prepend
}{wxstringprepend
}
99 \membersection{Comparison
}\label{comparisoninwxstring
}
101 The default comparison function
\helpref{Cmp
}{wxstringcmp
} is case-sensitive and
102 so is the default version of
\helpref{IsSameAs
}{wxstringissameas
}. For case
103 insensitive comparisons you should use
\helpref{CmpNoCase
}{wxstringcmpnocase
} or
104 give a second parameter to IsSameAs. This last function is may be more
105 convenient if only equality of the strings matters because it returns a boolean
106 true value if the strings are the same and not
0 (which is usually false in C)
109 \helpref{Matches
}{wxstringmatches
} is a poor man's regular expression matcher:
110 it only understands '*' and '?' metacharacters in the sense of DOS command line
113 \helpref{StartsWith
}{wxstringstartswith
} is helpful when parsing a line of
114 text which should start with some predefined prefix and is more efficient than
115 doing direct string comparison as you would also have to precalculate the
116 length of the prefix then.
118 \helpref{Cmp
}{wxstringcmp
}\\
119 \helpref{CmpNoCase
}{wxstringcmpnocase
}\\
120 \helpref{IsSameAs
}{wxstringissameas
}\\
121 \helpref{Matches
}{wxstringmatches
}\\
122 \helpref{StartsWith
}{wxstringstartswith
}
124 \membersection{Substring extraction
}\label{substringextractioninwxstring
}
126 These functions allow to extract substring from this string. All of them don't
127 modify the original string and return a new string containing the extracted
130 \helpref{Mid
}{wxstringmid
}\\
131 \helpref{operator()
}{wxstringoperatorparenth
}\\
132 \helpref{Left
}{wxstringleft
}\\
133 \helpref{Right
}{wxstringright
}\\
134 \helpref{BeforeFirst
}{wxstringbeforefirst
}\\
135 \helpref{BeforeLast
}{wxstringbeforelast
}\\
136 \helpref{AfterFirst
}{wxstringafterfirst
}\\
137 \helpref{AfterLast
}{wxstringafterlast
}\\
138 \helpref{StartsWith
}{wxstringstartswith
}
140 \membersection{Case conversion
}\label{caseconversioninwxstring
}
142 The MakeXXX() variants modify the string in place, while the other functions
143 return a new string which contains the original text converted to the upper or
144 lower case and leave the original string unchanged.
146 \helpref{MakeUpper
}{wxstringmakeupper
}\\
147 \helpref{Upper
}{wxstringupper
}\\
148 \helpref{MakeLower
}{wxstringmakelower
}\\
149 \helpref{Lower
}{wxstringlower
}
151 \membersection{Searching and replacing
}\label{searchingandreplacinginwxstring
}
153 These functions replace the standard
{\it strchr()
} and
{\it strstr()
}
156 \helpref{Find
}{wxstringfind
}\\
157 \helpref{Replace
}{wxstringreplace
}
159 \membersection{Conversion to numbers
}\label{conversiontonumbersinwxstring
}
161 The string provides functions for conversion to signed and unsigned integer and
162 floating point numbers. All three functions take a pointer to the variable to
163 put the numeric value in and return true if the
{\bf entire
} string could be
164 converted to a number.
166 \helpref{ToLong
}{wxstringtolong
}\\
167 \helpref{ToULong
}{wxstringtoulong
}\\
168 \helpref{ToDouble
}{wxstringtodouble
}
170 \membersection{Writing values into the string
}\label{writingintostringinwxstring
}
172 Both formatted versions (
\helpref{Printf
}{wxstringprintf
}) and stream-like
173 insertion operators exist (for basic types only). Additionally, the
174 \helpref{Format
}{wxstringformat
} function allows to use simply append
175 formatted value to a string:
178 // the following
2 snippets are equivalent
181 s += wxString::Format("
%d", n);
184 s.Printf("...
%d", n);
187 \helpref{Format
}{wxstringformat
}\\
188 \helpref{FormatV
}{wxstringformatv
}\\
189 \helpref{Printf
}{wxstringprintf
}\\
190 \helpref{PrintfV
}{wxstringprintfv
}\\
191 \helpref{operator
\cinsert}{wxstringoperatorout
}
193 \membersection{Memory management
}\label{memoryinwxstring
}
195 These are "advanced" functions and they will be needed quite rarely.
196 \helpref{Alloc
}{wxstringalloc
} and
\helpref{Shrink
}{wxstringshrink
} are only
197 interesting for optimization purposes.
198 \helpref{GetWriteBuf
}{wxstringgetwritebuf
} may be very useful when working with
199 some external API which requires the caller to provide a writable buffer, but
200 extreme care should be taken when using it: before performing any other
201 operation on the string
\helpref{UngetWriteBuf
}{wxstringungetwritebuf
} {\bf
204 \helpref{Alloc
}{wxstringalloc
}\\
205 \helpref{Shrink
}{wxstringshrink
}\\
206 \helpref{GetWriteBuf
}{wxstringgetwritebuf
}\\
207 \helpref{UngetWriteBuf
}{wxstringungetwritebuf
}
209 \membersection{Miscellaneous
}\label{miscellaneousinwxstring
}
211 Other string functions.
213 \helpref{Trim
}{wxstringtrim
}\\
214 \helpref{Pad
}{wxstringpad
}\\
215 \helpref{Truncate
}{wxstringtruncate
}
217 \membersection{wxWidgets
1.xx compatibility functions
}\label{backwardcompatibilityinwxstring
}
219 These functions are deprecated, please consider using new wxWidgets
2.0
220 functions instead of them (or, even better, std::string compatible variants).
222 \helpref{SubString
}{wxstringsubstring
}\\
223 \helpref{sprintf
}{wxstringsprintf
}\\
224 \helpref{CompareTo
}{wxstringcompareto
}\\
225 \helpref{Length
}{wxstringlength
}\\
226 \helpref{Freq
}{wxstringfreq
}\\
227 \helpref{LowerCase
}{wxstringlowercase
}\\
228 \helpref{UpperCase
}{wxstringuppercase
}\\
229 \helpref{Strip
}{wxstringstrip
}\\
230 \helpref{Index
}{wxstringindex
}\\
231 \helpref{Remove
}{wxstringremove
}\\
232 \helpref{First
}{wxstringfirst
}\\
233 \helpref{Last
}{wxstringlast
}\\
234 \helpref{Contains
}{wxstringcontains
}\\
235 \helpref{IsNull
}{wxstringisnull
}\\
236 \helpref{IsAscii
}{wxstringisascii
}\\
237 \helpref{IsNumber
}{wxstringisnumber
}\\
238 \helpref{IsWord
}{wxstringisword
}
240 \membersection{std::string compatibility functions
}\label{wxstringat
}
242 The supported functions are only listed here, please see any STL reference for
246 // take nLen chars starting at nPos
247 wxString(const wxString& str, size_t nPos, size_t nLen);
248 // take all characters from pStart to pEnd (poor man's iterators)
249 wxString(const void *pStart, const void *pEnd);
251 // lib.string.capacity
252 // return the length of the string
254 // return the length of the string
255 size_t length() const;
256 // return the maximum size of the string
257 size_t max_size() const;
258 // resize the string, filling the space with c if c !=
0
259 void resize(size_t nSize, char ch = '
\0');
260 // delete the contents of the string
262 // returns true if the string is empty
266 // return the character at position n
267 char at(size_t n) const;
268 // returns the writable character at position n
271 // lib.string.modifiers
273 wxString& append(const wxString& str);
274 // append elements str
[pos
], ..., str
[pos+n
]
275 wxString& append(const wxString& str, size_t pos, size_t n);
276 // append first n (or all if n == npos) characters of sz
277 wxString& append(const char *sz, size_t n = npos);
279 // append n copies of ch
280 wxString& append(size_t n, char ch);
282 // same as `this_string = str'
283 wxString& assign(const wxString& str);
284 // same as ` = str
[pos..pos + n
]
285 wxString& assign(const wxString& str, size_t pos, size_t n);
286 // same as `= first n (or all if n == npos) characters of sz'
287 wxString& assign(const char *sz, size_t n = npos);
288 // same as `= n copies of ch'
289 wxString& assign(size_t n, char ch);
291 // insert another string
292 wxString& insert(size_t nPos, const wxString& str);
293 // insert n chars of str starting at nStart (in str)
294 wxString& insert(size_t nPos, const wxString& str, size_t nStart, size_t n);
296 // insert first n (or all if n == npos) characters of sz
297 wxString& insert(size_t nPos, const char *sz, size_t n = npos);
298 // insert n copies of ch
299 wxString& insert(size_t nPos, size_t n, char ch);
301 // delete characters from nStart to nStart + nLen
302 wxString& erase(size_t nStart =
0, size_t nLen = npos);
304 // replaces the substring of length nLen starting at nStart
305 wxString& replace(size_t nStart, size_t nLen, const char* sz);
306 // replaces the substring with nCount copies of ch
307 wxString& replace(size_t nStart, size_t nLen, size_t nCount, char ch);
308 // replaces a substring with another substring
309 wxString& replace(size_t nStart, size_t nLen,
310 const wxString& str, size_t nStart2, size_t nLen2);
311 // replaces the substring with first nCount chars of sz
312 wxString& replace(size_t nStart, size_t nLen,
313 const char* sz, size_t nCount);
316 void swap(wxString& str);
318 // All find() functions take the nStart argument which specifies the
319 // position to start the search on, the default value is
0. All functions
320 // return npos if there were no match.
323 size_t find(const wxString& str, size_t nStart =
0) const;
325 // find first n characters of sz
326 size_t find(const char* sz, size_t nStart =
0, size_t n = npos) const;
328 // find the first occurrence of character ch after nStart
329 size_t find(char ch, size_t nStart =
0) const;
331 // rfind() family is exactly like find() but works right to left
333 // as find, but from the end
334 size_t rfind(const wxString& str, size_t nStart = npos) const;
336 // as find, but from the end
337 size_t rfind(const char* sz, size_t nStart = npos,
338 size_t n = npos) const;
339 // as find, but from the end
340 size_t rfind(char ch, size_t nStart = npos) const;
342 // find first/last occurrence of any character in the set
345 size_t find_first_of(const wxString& str, size_t nStart =
0) const;
347 size_t find_first_of(const char* sz, size_t nStart =
0) const;
348 // same as find(char, size_t)
349 size_t find_first_of(char c, size_t nStart =
0) const;
351 size_t find_last_of (const wxString& str, size_t nStart = npos) const;
353 size_t find_last_of (const char* s, size_t nStart = npos) const;
354 // same as rfind(char, size_t)
355 size_t find_last_of (char c, size_t nStart = npos) const;
357 // find first/last occurrence of any character not in the set
360 size_t find_first_not_of(const wxString& str, size_t nStart =
0) const;
362 size_t find_first_not_of(const char* s, size_t nStart =
0) const;
364 size_t find_first_not_of(char ch, size_t nStart =
0) const;
366 size_t find_last_not_of(const wxString& str, size_t nStart=npos) const;
368 size_t find_last_not_of(const char* s, size_t nStart = npos) const;
370 size_t find_last_not_of(char ch, size_t nStart = npos) const;
372 // All compare functions return a negative, zero or positive value
373 // if the
[sub
]string is less, equal or greater than the compare() argument.
375 // just like strcmp()
376 int compare(const wxString& str) const;
377 // comparison with a substring
378 int compare(size_t nStart, size_t nLen, const wxString& str) const;
379 // comparison of
2 substrings
380 int compare(size_t nStart, size_t nLen,
381 const wxString& str, size_t nStart2, size_t nLen2) const;
382 // just like strcmp()
383 int compare(const char* sz) const;
384 // substring comparison with first nCount characters of sz
385 int compare(size_t nStart, size_t nLen,
386 const char* sz, size_t nCount = npos) const;
388 // substring extraction
389 wxString substr(size_t nStart =
0, size_t nLen = npos) const;
392 %%%%% MEMBERS HERE %%%%%
393 \helponly{\insertatlevel{2}{
399 \membersection{wxString::wxString
}\label{wxstringconstruct
}
401 \func{}{wxString
}{\void}
403 Default constructor. Initializes the string to
{\tt ""
} (empty string).
405 \func{}{wxString
}{\param{const wxString\&
}{ x
}}
409 \func{}{wxString
}{\param{char
}{ ch
},
\param{size
\_t}{ n =
1}}
411 Constructs a string of
{\it n
} copies of character
{\it ch
}.
413 \func{}{wxString
}{\param{const char*
}{ psz
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
415 Takes first
{\it nLength
} characters from the C string
{\it psz
}.
416 The default value of
{\tt wxSTRING
\_MAXLEN} means to take all the string.
418 Note that this constructor may be used even if
{\it psz
} points to a buffer
419 with binary data (i.e. containing
{\tt NUL
} characters) as long as you provide
420 the correct value for
{\it nLength
}. However, the default form of it works
421 only with strings without intermediate
{\tt NUL
}s because it uses
422 {\tt strlen()
} to calculate the effective length and it would not give correct
425 \func{}{wxString
}{\param{const unsigned char*
}{ psz
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
427 For compilers using unsigned char: takes first
{\it nLength
} characters from the C string
{\it psz
}.
428 The default value of
{\tt wxSTRING
\_MAXLEN} means take all the string.
430 {\bf Note:
} In Unicode build, all of the above constructors take
431 {\tt wchar
\_t} arguments instead of
{\tt char
}.
433 \wxheading{Constructors with conversion
}
435 The following constructors allow you to construct wxString from wide string
436 in ANSI build or from C string in Unicode build.
438 \func{}{wxString
}{\param{const wchar
\_t*
}{ psz
},
\param{wxMBConv\&
}{ conv
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
440 Initializes the string from first
\arg{nLength
} characters of wide string.
441 The default value of
{\tt wxSTRING
\_MAXLEN} means take all the string.
442 In ANSI build,
\arg{conv
}'s
443 \helpref{WC2MB
}{wxmbconvwc2mb
} method is called to
444 convert
\arg{psz
} to wide string. It is ignored in Unicode build.
446 \func{}{wxString
}{\param{const char*
}{ psz
},
\param{wxMBConv\&
}{ conv
},
\param{size
\_t}{ nLength = wxSTRING
\_MAXLEN}}
448 Initializes the string from first
\arg{nLength
} characters of C string.
449 The default value of
{\tt wxSTRING
\_MAXLEN} means take all the string.
450 In Unicode build,
\arg{conv
}'s
451 \helpref{MB2WC
}{wxmbconvmb2wc
} method is called to
452 convert
\arg{psz
} to wide string. It is ignored in ANSI build.
456 \helpref{wxMBConv classes
}{mbconvclasses
},
\helpref{mb
\_str}{wxstringmbstr
},
457 \helpref{wc
\_str}{wxstringwcstr
}
459 \membersection{wxString::
\destruct{wxString
}}\label{wxstringdestruct
}
461 \func{}{\destruct{wxString
}}{\void}
463 String destructor. Note that this is not virtual, so wxString must not be inherited from.
465 \membersection{wxString::Alloc
}\label{wxstringalloc
}
467 \func{void
}{Alloc
}{\param{size
\_t}{ nLen
}}
469 Preallocate enough space for wxString to store
{\it nLen
} characters. This function
470 may be used to increase speed when the string is constructed by repeated
475 // delete all vowels from the string
476 wxString DeleteAllVowels(const wxString& original)
480 size_t len = original.length();
484 for ( size_t n =
0; n < len; n++ )
486 if ( strchr("aeuio", tolower(original
[n
])) == NULL )
487 result += original
[n
];
495 because it will avoid the need to reallocate string memory many times (in case
496 of long strings). Note that it does not set the maximal length of a string - it
497 will still expand if more than
{\it nLen
} characters are stored in it. Also, it
498 does not truncate the existing string (use
499 \helpref{Truncate()
}{wxstringtruncate
} for this) even if its current length is
500 greater than
{\it nLen
}
502 \membersection{wxString::Append
}\label{wxstringappend
}
504 \func{wxString\&
}{Append
}{\param{const char*
}{ psz
}}
506 Concatenates
{\it psz
} to this string, returning a reference to it.
508 \func{wxString\&
}{Append
}{\param{char
}{ ch
},
\param{int
}{ count =
1}}
510 Concatenates character
{\it ch
} to this string,
{\it count
} times, returning a reference
513 \membersection{wxString::AfterFirst
}\label{wxstringafterfirst
}
515 \constfunc{wxString
}{AfterFirst
}{\param{char
}{ ch
}}
517 Gets all the characters after the first occurrence of
{\it ch
}.
518 Returns the empty string if
{\it ch
} is not found.
520 \membersection{wxString::AfterLast
}\label{wxstringafterlast
}
522 \constfunc{wxString
}{AfterLast
}{\param{char
}{ ch
}}
524 Gets all the characters after the last occurrence of
{\it ch
}.
525 Returns the whole string if
{\it ch
} is not found.
527 \membersection{wxString::BeforeFirst
}\label{wxstringbeforefirst
}
529 \constfunc{wxString
}{BeforeFirst
}{\param{char
}{ ch
}}
531 Gets all characters before the first occurrence of
{\it ch
}.
532 Returns the whole string if
{\it ch
} is not found.
534 \membersection{wxString::BeforeLast
}\label{wxstringbeforelast
}
536 \constfunc{wxString
}{BeforeLast
}{\param{char
}{ ch
}}
538 Gets all characters before the last occurrence of
{\it ch
}.
539 Returns the empty string if
{\it ch
} is not found.
541 \membersection{wxString::c
\_str}\label{wxstringcstr
}
543 \constfunc{const char *
}{c
\_str}{\void}
545 Returns a pointer to the string data (
{\tt const char*
} in ANSI build,
546 {\tt const wchar
\_t*
} in Unicode build).
550 \helpref{mb
\_str}{wxstringmbstr
},
\helpref{wc
\_str}{wxstringwcstr
},
551 \helpref{fn
\_str}{wxstringfnstr
}
553 \membersection{wxString::Clear
}\label{wxstringclear
}
555 \func{void
}{Clear
}{\void}
557 Empties the string and frees memory occupied by it.
559 See also:
\helpref{Empty
}{wxstringempty
}
561 \membersection{wxString::Cmp
}\label{wxstringcmp
}
563 \constfunc{int
}{Cmp
}{\param{const char*
}{ psz
}}
565 Case-sensitive comparison.
567 Returns a positive value if the string is greater than the argument, zero if
568 it is equal to it or a negative value if it is less than the argument (same semantics
569 as the standard
{\it strcmp()
} function).
571 See also
\helpref{CmpNoCase
}{wxstringcmpnocase
},
\helpref{IsSameAs
}{wxstringissameas
}.
573 \membersection{wxString::CmpNoCase
}\label{wxstringcmpnocase
}
575 \constfunc{int
}{CmpNoCase
}{\param{const char*
}{ psz
}}
577 Case-insensitive comparison.
579 Returns a positive value if the string is greater than the argument, zero if
580 it is equal to it or a negative value if it is less than the argument (same semantics
581 as the standard
{\it strcmp()
} function).
583 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{IsSameAs
}{wxstringissameas
}.
585 \membersection{wxString::CompareTo
}\label{wxstringcompareto
}
588 #define NO_POS ((int)(-
1)) // undefined position
589 enum caseCompare
{exact, ignoreCase
};
592 \constfunc{int
}{CompareTo
}{\param{const char*
}{ psz
},
\param{caseCompare
}{ cmp = exact
}}
594 Case-sensitive comparison. Returns
0 if equal,
1 if greater or -
1 if less.
596 \membersection{wxString::Contains
}\label{wxstringcontains
}
598 \constfunc{bool
}{Contains
}{\param{const wxString\&
}{ str
}}
600 Returns
1 if target appears anywhere in wxString; else
0.
602 \membersection{wxString::Empty
}\label{wxstringempty
}
604 \func{void
}{Empty
}{\void}
606 Makes the string empty, but doesn't free memory occupied by the string.
608 See also:
\helpref{Clear()
}{wxstringclear
}.
610 \membersection{wxString::Find
}\label{wxstringfind
}
612 \constfunc{int
}{Find
}{\param{char
}{ ch
},
\param{bool
}{ fromEnd = false
}}
614 Searches for the given character. Returns the starting index, or -
1 if not found.
616 \constfunc{int
}{Find
}{\param{const char*
}{ sz
}}
618 Searches for the given string. Returns the starting index, or -
1 if not found.
620 \membersection{wxString::First
}\label{wxstringfirst
}
622 \func{int
}{First
}{\param{char
}{ c
}}
624 \constfunc{int
}{First
}{\param{const char*
}{ psz
}}
626 \constfunc{int
}{First
}{\param{const wxString\&
}{ str
}}
628 Same as
\helpref{Find
}{wxstringfind
}.
630 \membersection{wxString::fn
\_str}\label{wxstringfnstr
}
632 \constfunc{const wchar
\_t*
}{fn
\_str}{\void}
634 \constfunc{const char*
}{fn
\_str}{\void}
636 \constfunc{const wxCharBuffer
}{fn
\_str}{\void}
638 Returns string representation suitable for passing to OS' functions for
639 file handling. In ANSI build, this is same as
\helpref{c
\_str}{wxstringcstr
}.
640 In Unicode build, returned value can be either wide character string
641 or C string in charset matching the
{\tt wxConvFile
} object, depending on
646 \helpref{wxMBConv
}{wxmbconv
},
647 \helpref{wc
\_str}{wxstringwcstr
},
\helpref{mb
\_str}{wxstringwcstr
}
649 \membersection{wxString::Format
}\label{wxstringformat
}
651 \func{static wxString
}{Format
}{\param{const wxChar
}{*format
},
\param{}{...
}}
653 This static function returns the string containing the result of calling
654 \helpref{Printf
}{wxstringprintf
} with the passed parameters on it.
658 \helpref{FormatV
}{wxstringformatv
},
\helpref{Printf
}{wxstringprintf
}
660 \membersection{wxString::FormatV
}\label{wxstringformatv
}
662 \func{static wxString
}{Format
}{\param{const wxChar
}{*format
},
\param{va
\_list }{argptr
}}
664 This static function returns the string containing the result of calling
665 \helpref{PrintfV
}{wxstringprintfv
} with the passed parameters on it.
669 \helpref{Format
}{wxstringformat
},
\helpref{PrintfV
}{wxstringprintfv
}
671 \membersection{wxString::Freq
}\label{wxstringfreq
}
673 \constfunc{int
}{Freq
}{\param{char
}{ch
}}
675 Returns the number of occurrences of
{\it ch
} in the string.
677 \membersection{wxString::FromAscii
}\label{wxstringfromascii
}
679 \func{static wxString
}{FromAscii
}{\param{const char*
}{ s
}}
681 \func{static wxString
}{FromAscii
}{\param{const char
}{ c
}}
683 Converts the string or character from an ASCII,
7-bit form
684 to the native wxString representation. Most useful when using
685 a Unicode build of wxWidgets.
686 Use
\helpref{wxString constructors
}{wxstringconstruct
} if you
687 need to convert from another charset.
689 \membersection{wxString::GetChar
}\label{wxstringgetchar
}
691 \constfunc{char
}{GetChar
}{\param{size
\_t}{ n
}}
693 Returns the character at position
{\it n
} (read-only).
695 \membersection{wxString::GetData
}\label{wxstringgetdata
}
697 \constfunc{const char*
}{GetData
}{\void}
699 wxWidgets compatibility conversion. Returns a constant pointer to the data in the string.
701 \membersection{wxString::GetWritableChar
}\label{wxstringgetwritablechar
}
703 \func{char\&
}{GetWritableChar
}{\param{size
\_t}{ n
}}
705 Returns a reference to the character at position
{\it n
}.
707 \membersection{wxString::GetWriteBuf
}\label{wxstringgetwritebuf
}
709 \func{wxChar*
}{GetWriteBuf
}{\param{size
\_t}{ len
}}
711 Returns a writable buffer of at least
{\it len
} bytes.
712 It returns a pointer to a new memory block, and the
713 existing data will not be copied.
715 Call
\helpref{wxString::UngetWriteBuf
}{wxstringungetwritebuf
} as soon as possible
716 to put the string back into a reasonable state.
718 \membersection{wxString::Index
}\label{wxstringindex
}
720 \constfunc{size
\_t}{Index
}{\param{char
}{ ch
}}
722 \constfunc{size
\_t}{Index
}{\param{const char*
}{ sz
}}
724 Same as
\helpref{wxString::Find
}{wxstringfind
}.
726 \constfunc{size
\_t}{Index
}{\param{const char*
}{ sz
},
\param{bool
}{ caseSensitive = true
},
\param{bool
}{ fromEnd = false
}}
728 Search the element in the array, starting from either side.
730 If
{\it fromEnd
} is true, reverse search direction.
732 If
{\bf caseSensitive
}, comparison is case sensitive (the default).
734 Returns the index of the first item matched, or
{\tt wxNOT
\_FOUND}.
737 %\membersection{wxString::insert}\label{wxstringinsert}
739 %\func{void}{insert}{\param{const wxString\&}{ str}, \param{size\_t}{ index}}
741 %Add new element at the given position.
743 \membersection{wxString::IsAscii
}\label{wxstringisascii
}
745 \constfunc{bool
}{IsAscii
}{\void}
747 Returns true if the string contains only ASCII characters.
749 \membersection{wxString::IsEmpty
}\label{wxstringisempty
}
751 \constfunc{bool
}{IsEmpty
}{\void}
753 Returns true if the string is empty.
755 \membersection{wxString::IsNull
}\label{wxstringisnull
}
757 \constfunc{bool
}{IsNull
}{\void}
759 Returns true if the string is empty (same as
\helpref{IsEmpty
}{wxstringisempty
}).
761 \membersection{wxString::IsNumber
}\label{wxstringisnumber
}
763 \constfunc{bool
}{IsNumber
}{\void}
765 Returns true if the string is an integer (with possible sign).
767 \membersection{wxString::IsSameAs
}\label{wxstringissameas
}
769 \constfunc{bool
}{IsSameAs
}{\param{const char*
}{ psz
},
\param{bool
}{ caseSensitive = true
}}
771 Test for string equality, case-sensitive (default) or not.
773 caseSensitive is true by default (case matters).
775 Returns true if strings are equal, false otherwise.
777 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{CmpNoCase
}{wxstringcmpnocase
}
779 \constfunc{bool
}{IsSameAs
}{\param{char
}{ c
},
\param{bool
}{ caseSensitive = true
}}
781 Test whether the string is equal to the single character
{\it c
}. The test is
782 case-sensitive if
{\it caseSensitive
} is true (default) or not if it is false.
784 Returns true if the string is equal to the character, false otherwise.
786 See also
\helpref{Cmp
}{wxstringcmp
},
\helpref{CmpNoCase
}{wxstringcmpnocase
}
788 \membersection{wxString::IsWord
}\label{wxstringisword
}
790 \constfunc{bool
}{IsWord
}{\void}
792 Returns true if the string is a word. TODO: what's the definition of a word?
794 \membersection{wxString::Last
}\label{wxstringlast
}
796 \constfunc{char
}{Last
}{\void}
798 Returns the last character.
800 \func{char\&
}{Last
}{\void}
802 Returns a reference to the last character (writable).
804 \membersection{wxString::Left
}\label{wxstringleft
}
806 \constfunc{wxString
}{Left
}{\param{size
\_t}{ count
}}
808 Returns the first
{\it count
} characters of the string.
810 \membersection{wxString::Len
}\label{wxstringlen
}
812 \constfunc{size
\_t}{Len
}{\void}
814 Returns the length of the string.
816 \membersection{wxString::Length
}\label{wxstringlength
}
818 \constfunc{size
\_t}{Length
}{\void}
820 Returns the length of the string (same as Len).
822 \membersection{wxString::Lower
}\label{wxstringlower
}
824 \constfunc{wxString
}{Lower
}{\void}
826 Returns this string converted to the lower case.
828 \membersection{wxString::LowerCase
}\label{wxstringlowercase
}
830 \func{void
}{LowerCase
}{\void}
834 \membersection{wxString::MakeLower
}\label{wxstringmakelower
}
836 \func{wxString\&
}{MakeLower
}{\void}
838 Converts all characters to lower case and returns the result.
840 \membersection{wxString::MakeUpper
}\label{wxstringmakeupper
}
842 \func{wxString\&
}{MakeUpper
}{\void}
844 Converts all characters to upper case and returns the result.
846 \membersection{wxString::Matches
}\label{wxstringmatches
}
848 \constfunc{bool
}{Matches
}{\param{const char*
}{ szMask
}}
850 Returns true if the string contents matches a mask containing '*' and '?'.
852 \membersection{wxString::mb
\_str}\label{wxstringmbstr
}
854 \constfunc{const char*
}{mb
\_str}{\param{wxMBConv\&
}{ conv
}}
856 \constfunc{const wxCharBuffer
}{mb
\_str}{\param{wxMBConv\&
}{ conv
}}
858 Returns multibyte (C string) representation of the string.
859 In Unicode build, converts using
\arg{conv
}'s
\helpref{cWC2MB
}{wxmbconvcwc2mb
}
860 method and returns wxCharBuffer. In ANSI build, this function is same
861 as
\helpref{c
\_str}{wxstringcstr
}.
862 The macro wxWX2MBbuf is defined as the correct return type (without const).
866 \helpref{wxMBConv
}{wxmbconv
},
867 \helpref{c
\_str}{wxstringcstr
},
\helpref{wc
\_str}{wxstringwcstr
},
868 \helpref{fn
\_str}{wxstringfnstr
}
870 \membersection{wxString::Mid
}\label{wxstringmid
}
872 \constfunc{wxString
}{Mid
}{\param{size
\_t}{ first
},
\param{size
\_t}{ count = wxSTRING
\_MAXLEN}}
874 Returns a substring starting at
{\it first
}, with length
{\it count
}, or the rest of
875 the string if
{\it count
} is the default value.
877 \membersection{wxString::Pad
}\label{wxstringpad
}
879 \func{wxString\&
}{Pad
}{\param{size
\_t}{ count
},
\param{char
}{ pad = ' '
},
\param{bool
}{ fromRight = true
}}
881 Adds
{\it count
} copies of
{\it pad
} to the beginning, or to the end of the string (the default).
883 Removes spaces from the left or from the right (default).
885 \membersection{wxString::Prepend
}\label{wxstringprepend
}
887 \func{wxString\&
}{Prepend
}{\param{const wxString\&
}{ str
}}
889 Prepends
{\it str
} to this string, returning a reference to this string.
891 \membersection{wxString::Printf
}\label{wxstringprintf
}
893 \func{int
}{Printf
}{\param{const char*
}{pszFormat
},
\param{}{...
}}
895 Similar to the standard function
{\it sprintf()
}. Returns the number of
896 characters written, or an integer less than zero on error.
898 {\bf NB:
} This function will use a safe version of
{\it vsprintf()
} (usually called
899 {\it vsnprintf()
}) whenever available to always allocate the buffer of correct
900 size. Unfortunately, this function is not available on all platforms and the
901 dangerous
{\it vsprintf()
} will be used then which may lead to buffer overflows.
903 \membersection{wxString::PrintfV
}\label{wxstringprintfv
}
905 \func{int
}{PrintfV
}{\param{const char*
}{pszFormat
},
\param{va
\_list}{ argPtr
}}
907 Similar to vprintf. Returns the number of characters written, or an integer less than zero
910 \membersection{wxString::Remove
}\label{wxstringremove
}
912 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
}}
914 Same as Truncate. Removes the portion from
{\it pos
} to the end of the string.
916 \func{wxString\&
}{Remove
}{\param{size
\_t}{ pos
},
\param{size
\_t}{ len
}}
918 Removes the
{\it len
} characters from the string, starting at
{\it pos
}.
920 \membersection{wxString::RemoveLast
}\label{wxstringremovelast
}
922 \func{wxString\&
}{RemoveLast
}{\void}
924 Removes the last character.
926 \membersection{wxString::Replace
}\label{wxstringreplace
}
928 \func{size
\_t}{Replace
}{\param{const char*
}{ szOld
},
\param{const char*
}{ szNew
},
\param{bool
}{ replaceAll = true
}}
930 Replace first (or all) occurrences of substring with another one.
932 {\it replaceAll
}: global replace (default), or only the first occurrence.
934 Returns the number of replacements made.
936 \membersection{wxString::Right
}\label{wxstringright
}
938 \constfunc{wxString
}{Right
}{\param{size
\_t}{ count
}}
940 Returns the last
{\it count
} characters.
942 \membersection{wxString::SetChar
}\label{wxstringsetchar
}
944 \func{void
}{SetChar
}{\param{size
\_t}{ n
},
\param{char
}{ch
}}
946 Sets the character at position
{\it n
}.
948 \membersection{wxString::Shrink
}\label{wxstringshrink
}
950 \func{void
}{Shrink
}{\void}
952 Minimizes the string's memory. This can be useful after a call to
953 \helpref{Alloc()
}{wxstringalloc
} if too much memory were preallocated.
955 \membersection{wxString::sprintf
}\label{wxstringsprintf
}
957 \func{void
}{sprintf
}{\param{const char*
}{ fmt
}}
961 \membersection{wxString::StartsWith
}\label{wxstringstartswith
}
963 \constfunc{bool
}{StartsWith
}{\param{const wxChar
}{*prefix
},
\param{wxString
}{*rest = NULL
}}
965 This function can be used to test if the string starts with the specified
966 {\it prefix
}. If it does, the function will return
{\tt true
} and put the rest
967 of the string (i.e. after the prefix) into
{\it rest
} string if it is not
968 {\tt NULL
}. Otherwise, the function returns
{\tt false
} and doesn't modify the
971 \membersection{wxString::Strip
}\label{wxstringstrip
}
974 enum stripType
{leading =
0x1, trailing =
0x2, both =
0x3};
977 \constfunc{wxString
}{Strip
}{\param{stripType
}{ s = trailing
}}
979 Strip characters at the front and/or end. The same as Trim except that it
980 doesn't change this string.
982 \membersection{wxString::SubString
}\label{wxstringsubstring
}
984 \constfunc{wxString
}{SubString
}{\param{size
\_t}{ from
},
\param{size
\_t}{ to
}}
986 Deprecated, use
\helpref{Mid
}{wxstringmid
} instead (but note that parameters
987 have different meaning).
989 Returns the part of the string between the indices
{\it from
} and
{\it to
}
992 \membersection{wxString::ToAscii
}\label{wxstringtoascii
}
994 \constfunc{const char*
}{ToAscii
}{\void}
996 Converts the string to an ASCII,
7-bit string (ANSI builds only).
998 \constfunc{const wxCharBuffer
}{ToAscii
}{\void}
1000 Converts the string to an ASCII,
7-bit string in the form of
1001 a wxCharBuffer (Unicode builds only).
1003 Note that this conversion only works if the string contains only ASCII
1004 characters. The
\helpref{mb
\_str}{wxstringmbstr
} method provides more
1005 powerful means of converting wxString to C string.
1007 \membersection{wxString::ToDouble
}\label{wxstringtodouble
}
1009 \constfunc{bool
}{ToDouble
}{\param{double
}{ *val
}}
1011 Attempts to convert the string to a floating point number. Returns true on
1012 success (the number is stored in the location pointed to by
{\it val
}) or false
1013 if the string does not represent such number.
1015 \wxheading{See also
}
1017 \helpref{wxString::ToLong
}{wxstringtolong
},\\
1018 \helpref{wxString::ToULong
}{wxstringtoulong
}
1020 \membersection{wxString::ToLong
}\label{wxstringtolong
}
1022 \constfunc{bool
}{ToLong
}{\param{long
}{ *val
},
\param{int
}{base = $
10$
}}
1024 Attempts to convert the string to a signed integer in base
{\it base
}. Returns
1025 {\tt true
} on success in which case the number is stored in the location
1026 pointed to by
{\it val
} or
{\tt false
} if the string does not represent a
1027 valid number in the given base.
1029 The value of
{\it base
} must be comprised between $
2$ and $
36$, inclusive, or
1030 be a special value $
0$ which means that the usual rules of
{\tt C
} numbers are
1031 applied: if the number starts with
{\tt 0x
} it is considered to be in base
1032 $
16$, if it starts with
{\tt 0} - in base $
8$ and in base $
10$ otherwise. Note
1033 that you may not want to specify the base $
0$ if you are parsing the numbers
1034 which may have leading zeroes as they can yield unexpected (to the user not
1035 familiar with C) results.
1037 \wxheading{See also
}
1039 \helpref{wxString::ToDouble
}{wxstringtodouble
},\\
1040 \helpref{wxString::ToULong
}{wxstringtoulong
}
1042 \membersection{wxString::ToULong
}\label{wxstringtoulong
}
1044 \constfunc{bool
}{ToULong
}{\param{unsigned long
}{ *val
},
\param{int
}{base = $
10$
}}
1046 Attempts to convert the string to a unsigned integer in base
{\it base
}.
1047 Returns
{\tt true
} on success in which case the number is stored in the
1048 location pointed to by
{\it val
} or
{\tt false
} if the string does not
1049 represent a valid number in the given base.
1051 See
\helpref{wxString::ToLong
}{wxstringtolong
} for the more detailed
1052 description of the
{\it base
} parameter.
1054 \wxheading{See also
}
1056 \helpref{wxString::ToDouble
}{wxstringtodouble
},\\
1057 \helpref{wxString::ToLong
}{wxstringtolong
}
1059 \membersection{wxString::Trim
}\label{wxstringtrim
}
1061 \func{wxString\&
}{Trim
}{\param{bool
}{ fromRight = true
}}
1063 Removes spaces from the left or from the right (default).
1065 \membersection{wxString::Truncate
}\label{wxstringtruncate
}
1067 \func{wxString\&
}{Truncate
}{\param{size
\_t}{ len
}}
1069 Truncate the string to the given length.
1071 \membersection{wxString::UngetWriteBuf
}\label{wxstringungetwritebuf
}
1073 \func{void
}{UngetWriteBuf
}{\void}
1075 \func{void
}{UngetWriteBuf
}{\param{size
\_t }{len
}}
1077 Puts the string back into a reasonable state (in which it can be used
1079 \rtfsp\helpref{wxString::GetWriteBuf
}{wxstringgetwritebuf
} was called.
1081 The version of the function without the
{\it len
} parameter will calculate the
1082 new string length itself assuming that the string is terminated by the first
1083 {\tt NUL
} character in it while the second one will use the specified length
1084 and thus is the only version which should be used with the strings with
1085 embedded
{\tt NUL
}s (it is also slightly more efficient as
{\tt strlen()
}
1086 doesn't have to be called).
1088 \membersection{wxString::Upper
}\label{wxstringupper
}
1090 \constfunc{wxString
}{Upper
}{\void}
1092 Returns this string converted to upper case.
1094 \membersection{wxString::UpperCase
}\label{wxstringuppercase
}
1096 \func{void
}{UpperCase
}{\void}
1098 The same as MakeUpper.
1100 \membersection{wxString::wc
\_str}\label{wxstringwcstr
}
1102 \constfunc{const wchar
\_t*
}{wc
\_str}{\param{wxMBConv\&
}{ conv
}}
1104 \constfunc{const wxWCharBuffer
}{wc
\_str}{\param{wxMBConv\&
}{ conv
}}
1106 Returns wide character representation of the string.
1107 In ANSI build, converts using
\arg{conv
}'s
\helpref{cMB2WC
}{wxmbconvcmb2wc
}
1108 method and returns wxWCharBuffer. In Unicode build, this function is same
1109 as
\helpref{c
\_str}{wxstringcstr
}.
1110 The macro wxWX2WCbuf is defined as the correct return type (without const).
1112 \wxheading{See also
}
1114 \helpref{wxMBConv
}{wxmbconv
},
1115 \helpref{c
\_str}{wxstringcstr
},
\helpref{mb
\_str}{wxstringwcstr
},
1116 \helpref{fn
\_str}{wxstringfnstr
}
1118 \membersection{wxString::operator!
}\label{wxstringoperatornot
}
1120 \constfunc{bool
}{operator!
}{\void}
1122 Empty string is false, so !string will only return true if the string is empty.
1123 This allows the tests for NULLness of a
{\it const char *
} pointer and emptiness
1124 of the string to look the same in the code and makes it easier to port old code
1127 See also
\helpref{IsEmpty()
}{wxstringisempty
}.
1129 \membersection{wxString::operator $=$
}\label{wxstringoperatorassign
}
1131 \func{wxString\&
}{operator $=$
}{\param{const wxString\&
}{ str
}}
1133 \func{wxString\&
}{operator $=$
}{\param{const char*
}{ psz
}}
1135 \func{wxString\&
}{operator $=$
}{\param{char
}{ c
}}
1137 \func{wxString\&
}{operator $=$
}{\param{const unsigned char*
}{ psz
}}
1139 \func{wxString\&
}{operator $=$
}{\param{const wchar
\_t*
}{ pwz
}}
1141 Assignment: the effect of each operation is the same as for the corresponding
1142 constructor (see
\helpref{wxString constructors
}{wxstringconstruct
}).
1144 \membersection{wxString::operator $+$
}\label{wxstringoperatorplus
}
1146 Concatenation: all these operators return a new string equal to the
1147 concatenation of the operands.
1149 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1151 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ y
}}
1153 \func{wxString
}{operator $+$
}{\param{const wxString\&
}{ x
},
\param{char
}{ y
}}
1155 \func{wxString
}{operator $+$
}{\param{const char*
}{ x
},
\param{const wxString\&
}{ y
}}
1157 \membersection{wxString::operator $+=$
}\label{wxstringplusequal
}
1159 \func{void
}{operator $+=$
}{\param{const wxString\&
}{ str
}}
1161 \func{void
}{operator $+=$
}{\param{const char*
}{ psz
}}
1163 \func{void
}{operator $+=$
}{\param{char
}{ c
}}
1165 Concatenation in place: the argument is appended to the string.
1167 \membersection{wxString::operator
[]}\label{wxstringoperatorbracket
}
1169 \func{char\&
}{operator
[]}{\param{size
\_t}{ i
}}
1171 \func{char
}{operator
[]}{\param{size
\_t}{ i
}}
1173 \func{char
}{operator
[]}{\param{int
}{ i
}}
1177 \membersection{wxString::operator ()
}\label{wxstringoperatorparenth
}
1179 \func{wxString
}{operator ()
}{\param{size
\_t}{ start
},
\param{size
\_t}{ len
}}
1181 Same as Mid (substring extraction).
1183 \membersection{wxString::operator
\cinsert}\label{wxstringoperatorout
}
1185 \func{wxString\&
}{operator
\cinsert}{\param{const wxString\&
}{ str
}}
1187 \func{wxString\&
}{operator
\cinsert}{\param{const char*
}{ psz
}}
1189 \func{wxString\&
}{operator
\cinsert}{\param{char
}{ch
}}
1193 \func{wxString\&
}{operator
\cinsert}{\param{int
}{ i
}}
1195 \func{wxString\&
}{operator
\cinsert}{\param{float
}{ f
}}
1197 \func{wxString\&
}{operator
\cinsert}{\param{double
}{ d
}}
1199 These functions work as C++ stream insertion operators: they insert the given
1200 value into the string. Precision or format cannot be set using them, you can use
1201 \helpref{Printf
}{wxstringprintf
} for this.
1203 \membersection{wxString::operator
\cextract}\label{wxstringoperatorin
}
1205 \func{friend istream\&
}{operator
\cextract}{\param{istream\&
}{ is
},
\param{wxString\&
}{ str
}}
1207 Extraction from a stream.
1209 \membersection{wxString::operator const char*
}\label{wxstringoperatorconstcharpt
}
1211 \constfunc{}{operator const char*
}{\void}
1213 Implicit conversion to a C string.
1215 \membersection{Comparison operators
}\label{wxstringcomparison
}
1217 \func{bool
}{operator $==$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1219 \func{bool
}{operator $==$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1221 \func{bool
}{operator $!=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1223 \func{bool
}{operator $!=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1225 \func{bool
}{operator $>$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1227 \func{bool
}{operator $>$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1229 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1231 \func{bool
}{operator $>=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1233 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1235 \func{bool
}{operator $<$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1237 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const wxString\&
}{ y
}}
1239 \func{bool
}{operator $<=$
}{\param{const wxString\&
}{ x
},
\param{const char*
}{ t
}}
1243 These comparisons are case-sensitive.
1246 \section{\class{wxStringBuffer
}}\label{wxstringbuffer
}
1248 This tiny class allows to conveniently access the
\helpref{wxString
}{wxstring
}
1249 internal buffer as a writable pointer without any risk of forgetting to restore
1250 the string to the usable state later.
1252 For example, assuming you have a low-level OS function called
1253 {\tt GetMeaningOfLifeAsString(char *)
} returning the value in the provided
1254 buffer (which must be writable, of course) you might call it like this:
1258 GetMeaningOfLifeAsString(wxStringBuffer(theAnswer,
1024));
1259 if ( theAnswer != "
42" )
1261 wxLogError("Something is very wrong!");
1265 Note that the exact usage of this depends on whether on not wxUSE
\_STL is enabled. If
1266 wxUSE
\_STL is enabled, wxStringBuffer creates a seperate empty character buffer, and
1267 if wxUSE
\_STL is disabled, it uses GetWriteBuf() from wxString, keeping the same buffer
1268 wxString uses intact. In other words, relying on wxStringBuffer containing the old
1269 wxString data is probably not a good idea if you want to build your program in both
1270 with and without wxUSE
\_STL.
1272 \wxheading{Derived from
}
1276 \wxheading{Include files
}
1280 \latexignore{\rtfignore{\wxheading{Members
}}}
1282 \membersection{wxStringBuffer::wxStringBuffer
}\label{wxstringbufferctor
}
1284 \func{}{wxStringBuffer
}{\param{const wxString\&
}{str
},
\param{size
\_t }{len
}}
1286 Constructs a writable string buffer object associated with the given string
1287 and containing enough space for at least
{\it len
} characters. Basically, this
1288 is equivalent to calling
\helpref{GetWriteBuf
}{wxstringgetwritebuf
} and
1291 \membersection{wxStringBuffer::
\destruct{wxStringBuffer
}}\label{wxstringbufferdtor
}
1293 \func{}{\destruct{wxStringBuffer
}}{\void}
1295 Restores the string passed to the constructor to the usable state by calling
1296 \helpref{UngetWriteBuf
}{wxstringungetwritebuf
} on it.
1298 \membersection{wxStringBuffer::operator wxChar *
}\label{wxstringbufferwxchar
}
1300 \func{wxChar *
}{operator wxChar *
}{\void}
1302 Returns the writable pointer to a buffer of the size at least equal to the
1303 length specified in the constructor.
1307 \section{\class{wxStringBufferLength
}}\label{wxstringbufferlength
}
1309 This tiny class allows to conveniently access the
\helpref{wxString
}{wxstring
}
1310 internal buffer as a writable pointer without any risk of forgetting to restore
1311 the string to the usable state later, and allows the user to set the internal
1312 length of the string.
1314 For example, assuming you have a low-level OS function called
1315 {\tt int GetMeaningOfLifeAsString(char *)
} copying the value in the provided
1316 buffer (which must be writable, of course), and returning the actual length
1317 of the string, you might call it like this:
1321 wxStringBuffer theAnswerBuffer(theAnswer,
1024);
1322 int nLength = GetMeaningOfLifeAsString(theAnswerBuffer);
1323 theAnswerBuffer.SetLength(nLength);
1324 if ( theAnswer != "
42" )
1326 wxLogError("Something is very wrong!");
1330 Note that the exact usage of this depends on whether on not wxUSE
\_STL is enabled. If
1331 wxUSE
\_STL is enabled, wxStringBuffer creates a seperate empty character buffer, and
1332 if wxUSE
\_STL is disabled, it uses GetWriteBuf() from wxString, keeping the same buffer
1333 wxString uses intact. In other words, relying on wxStringBuffer containing the old
1334 wxString data is probably not a good idea if you want to build your program in both
1335 with and without wxUSE
\_STL.
1337 Note that SetLength
{\tt must
} be called before wxStringBufferLength destructs.
1339 \wxheading{Derived from
}
1343 \wxheading{Include files
}
1347 \latexignore{\rtfignore{\wxheading{Members
}}}
1349 \membersection{wxStringBufferLength::wxStringBufferLength
}\label{wxstringbufferlengthctor
}
1351 \func{}{wxStringBuffer
}{\param{const wxString\&
}{str
},
\param{size
\_t }{len
}}
1353 Constructs a writable string buffer object associated with the given string
1354 and containing enough space for at least
{\it len
} characters. Basically, this
1355 is equivalent to calling
\helpref{GetWriteBuf
}{wxstringgetwritebuf
} and
1358 \membersection{wxStringBufferLength::
\destruct{wxStringBufferLength
}}\label{wxstringbufferlengthdtor
}
1360 \func{}{\destruct{wxStringBufferLength
}}{\void}
1362 Restores the string passed to the constructor to the usable state by calling
1363 \helpref{UngetWriteBuf
}{wxstringungetwritebuf
} on it.
1365 \membersection{wxStringBufferLength::SetLength
}\label{wxstringbufferlengthsetlength
}
1367 \func{void
}{SetLength
}{\param{size
\_t }{nLength
}}
1369 Sets the internal length of the string referred to by wxStringBufferLength to
1370 {\it nLength
} characters.
1372 Must be called before wxStringBufferLength destructs.
1374 \membersection{wxStringBufferLength::operator wxChar *
}\label{wxstringbufferlengthwxchar
}
1376 \func{wxChar *
}{operator wxChar *
}{\void}
1378 Returns the writable pointer to a buffer of the size at least equal to the
1379 length specified in the constructor.