2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: string.h
|
2008-03-10 15:24:38 +00:00
|
|
|
// Purpose: interface of wxStringBuffer
|
2008-03-08 13:52:38 +00:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxStringBuffer
|
|
|
|
@wxheader{string.h}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
|
|
|
This tiny class allows to conveniently access the wxString
|
2008-03-08 13:52:38 +00:00
|
|
|
internal buffer as a writable pointer without any risk of forgetting to restore
|
|
|
|
the string to the usable state later.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
|
|
|
For example, assuming you have a low-level OS function called
|
2008-03-08 13:52:38 +00:00
|
|
|
@c GetMeaningOfLifeAsString(char *) returning the value in the provided
|
|
|
|
buffer (which must be writable, of course) you might call it like this:
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@code
|
|
|
|
wxString theAnswer;
|
|
|
|
GetMeaningOfLifeAsString(wxStringBuffer(theAnswer, 1024));
|
|
|
|
if ( theAnswer != "42" )
|
|
|
|
{
|
|
|
|
wxLogError("Something is very wrong!");
|
|
|
|
}
|
|
|
|
@endcode
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Note that the exact usage of this depends on whether on not wxUSE_STL is
|
|
|
|
enabled. If
|
|
|
|
wxUSE_STL is enabled, wxStringBuffer creates a separate empty character buffer,
|
|
|
|
and
|
|
|
|
if wxUSE_STL is disabled, it uses GetWriteBuf() from wxString, keeping the same
|
|
|
|
buffer
|
|
|
|
wxString uses intact. In other words, relying on wxStringBuffer containing the
|
2008-03-08 14:43:31 +00:00
|
|
|
old
|
2008-03-08 13:52:38 +00:00
|
|
|
wxString data is probably not a good idea if you want to build your program in
|
|
|
|
both
|
|
|
|
with and without wxUSE_STL.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxbase}
|
|
|
|
@category{FIXME}
|
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
class wxStringBuffer
|
2008-03-08 13:52:38 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructs a writable string buffer object associated with the given string
|
2008-03-09 12:33:59 +00:00
|
|
|
and containing enough space for at least @a len characters. Basically, this
|
2008-03-08 13:52:38 +00:00
|
|
|
is equivalent to calling wxString::GetWriteBuf and
|
|
|
|
saving the result.
|
|
|
|
*/
|
|
|
|
wxStringBuffer(const wxString& str, size_t len);
|
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
Restores the string passed to the constructor to the usable state by calling
|
2008-03-08 13:52:38 +00:00
|
|
|
wxString::UngetWriteBuf on it.
|
|
|
|
*/
|
|
|
|
~wxStringBuffer();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the writable pointer to a buffer of the size at least equal to the
|
|
|
|
length specified in the constructor.
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
wxChar* operator wxChar *();
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
@class wxString
|
|
|
|
@wxheader{string.h}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
|
|
|
wxString is a class representing a character string. Please see the
|
2008-03-08 13:52:38 +00:00
|
|
|
@ref overview_wxstringoverview "wxString overview" for more information about
|
|
|
|
it.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
As explained there, wxString implements most of the methods of the std::string
|
|
|
|
class.
|
|
|
|
These standard functions are not documented in this manual, please see the
|
|
|
|
STL documentation).
|
|
|
|
The behaviour of all these functions is identical to the behaviour described
|
|
|
|
there.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
You may notice that wxString sometimes has many functions which do the same
|
2008-03-08 14:43:31 +00:00
|
|
|
thing like, for example, wxString::Length,
|
2008-03-08 13:52:38 +00:00
|
|
|
wxString::Len and @c length() which all return the string
|
|
|
|
length. In all cases of such duplication the @c std::string-compatible
|
|
|
|
method (@c length() in this case, always the lowercase version) should be
|
|
|
|
used as it will ensure smoother transition to @c std::string when wxWidgets
|
|
|
|
starts using it instead of wxString.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxbase}
|
|
|
|
@category{data}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@stdobjects
|
2008-03-10 15:24:38 +00:00
|
|
|
::Objects:, ::wxEmptyString,
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
@see @ref overview_wxstringoverview "wxString overview", @ref overview_unicode
|
2008-03-08 13:52:38 +00:00
|
|
|
"Unicode overview"
|
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
class wxString
|
2008-03-08 13:52:38 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
//@{
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Initializes the string from first @a nLength characters of C string.
|
2008-03-08 13:52:38 +00:00
|
|
|
The default value of @c wxSTRING_MAXLEN means take all the string.
|
2008-03-08 14:43:31 +00:00
|
|
|
In Unicode build, @e conv's
|
2008-03-08 13:52:38 +00:00
|
|
|
wxMBConv::MB2WC method is called to
|
2008-03-09 12:33:59 +00:00
|
|
|
convert @a psz to wide string (the default converter uses current locale's
|
2008-03-08 13:52:38 +00:00
|
|
|
charset). It is ignored in ANSI build.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see @ref overview_mbconvclasses "wxMBConv classes", @ref mbstr()
|
|
|
|
mb_str, @ref wcstr() wc_str
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
wxString();
|
2008-03-08 14:43:31 +00:00
|
|
|
wxString(const wxString& x);
|
|
|
|
wxString(wxChar ch, size_t n = 1);
|
|
|
|
wxString(const wxChar* psz, size_t nLength = wxSTRING_MAXLEN);
|
|
|
|
wxString(const unsigned char* psz,
|
|
|
|
size_t nLength = wxSTRING_MAXLEN);
|
|
|
|
wxString(const wchar_t* psz, const wxMBConv& conv,
|
|
|
|
size_t nLength = wxSTRING_MAXLEN);
|
|
|
|
wxString(const char* psz, const wxMBConv& conv = wxConvLibc,
|
|
|
|
size_t nLength = wxSTRING_MAXLEN);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
String destructor. Note that this is not virtual, so wxString must not be
|
|
|
|
inherited from.
|
|
|
|
*/
|
|
|
|
~wxString();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Gets all the characters after the first occurrence of @e ch.
|
2008-03-09 12:33:59 +00:00
|
|
|
Returns the empty string if @a ch is not found.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString AfterFirst(wxChar ch) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets all the characters after the last occurrence of @e ch.
|
2008-03-09 12:33:59 +00:00
|
|
|
Returns the whole string if @a ch is not found.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString AfterLast(wxChar ch) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-04-05 17:50:16 +00:00
|
|
|
Preallocate enough space for wxString to store @a nLen characters.
|
|
|
|
|
|
|
|
Please note that this method does the same thing as the standard
|
|
|
|
reserve() one and shouldn't be used in new code.
|
|
|
|
|
|
|
|
This function may be used to increase speed when the string is
|
|
|
|
constructed by repeated concatenation as in
|
|
|
|
|
|
|
|
@code
|
|
|
|
// delete all vowels from the string
|
|
|
|
wxString DeleteAllVowels(const wxString& original)
|
|
|
|
{
|
|
|
|
wxString result;
|
|
|
|
|
|
|
|
size_t len = original.length();
|
|
|
|
|
|
|
|
result.Alloc(len);
|
|
|
|
|
|
|
|
for ( size_t n = 0; n < len; n++ )
|
|
|
|
{
|
|
|
|
if ( strchr("aeuio", tolower(original[n])) == NULL )
|
|
|
|
result += original[n];
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
because it will avoid the need to reallocate string memory many times
|
|
|
|
(in case of long strings). Note that it does not set the maximal length
|
|
|
|
of a string -- it will still expand if more than @a nLen characters are
|
|
|
|
stored in it. Also, it does not truncate the existing string (use
|
|
|
|
Truncate() for this) even if its current length is greater than @a nLen.
|
|
|
|
|
|
|
|
@return @true if memory was successfully allocated, @false otherwise.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-04-05 17:50:16 +00:00
|
|
|
bool Alloc(size_t nLen);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Concatenates character @a ch to this string, @a count times, returning a
|
2008-03-08 13:52:38 +00:00
|
|
|
reference
|
|
|
|
to it.
|
|
|
|
*/
|
|
|
|
wxString Append(const wxChar* psz);
|
2008-03-08 14:43:31 +00:00
|
|
|
wxString Append(wxChar ch, int count = 1);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Gets all characters before the first occurrence of @e ch.
|
2008-03-09 12:33:59 +00:00
|
|
|
Returns the whole string if @a ch is not found.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString BeforeFirst(wxChar ch) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets all characters before the last occurrence of @e ch.
|
2008-03-09 12:33:59 +00:00
|
|
|
Returns the empty string if @a ch is not found.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString BeforeLast(wxChar ch) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The MakeXXX() variants modify the string in place, while the other functions
|
|
|
|
return a new string which contains the original text converted to the upper or
|
|
|
|
lower case and leave the original string unchanged.
|
|
|
|
MakeUpper()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Upper()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
MakeLower()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Lower()
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Many functions in this section take a character index in the string. As with C
|
|
|
|
strings and/or arrays, the indices start from 0, so the first character of a
|
|
|
|
string is string[0]. Attempt to access a character beyond the end of the
|
|
|
|
string (which may be even 0 if the string is empty) will provoke an assert
|
|
|
|
failure in @ref overview_debuggingoverview "debug build", but no checks are
|
|
|
|
done in
|
|
|
|
release builds.
|
|
|
|
This section also contains both implicit and explicit conversions to C style
|
|
|
|
strings. Although implicit conversion is quite convenient, it is advised to use
|
|
|
|
explicit @ref cstr() c_str method for the sake of clarity. Also
|
2008-03-10 15:24:38 +00:00
|
|
|
see overview() for the cases where it is necessary to
|
2008-03-08 13:52:38 +00:00
|
|
|
use it.
|
|
|
|
GetChar()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
GetWritableChar()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
SetChar()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Last()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@ref operatorbracket() "operator []"
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@ref cstr() c_str
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@ref mbstr() mb_str
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@ref wcstr() wc_str
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@ref fnstr() fn_str
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@ref operatorconstcharpt() "operator const char*"
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Empties the string and frees memory occupied by it.
|
|
|
|
See also: Empty()
|
|
|
|
*/
|
|
|
|
void Clear();
|
|
|
|
|
2008-04-24 07:16:48 +00:00
|
|
|
/**
|
|
|
|
Returns a deep copy of the string.
|
|
|
|
|
|
|
|
That is, the returned string is guaranteed to not share data with this
|
|
|
|
string when using reference-counted wxString implementation.
|
|
|
|
|
|
|
|
This method is primarily useful for passing strings between threads
|
|
|
|
(because wxString is not thread-safe). Unlike creating a copy using
|
|
|
|
@c wxString(c_str()), Clone() handles embedded NULs correctly.
|
|
|
|
|
|
|
|
@since 2.9.0
|
|
|
|
*/
|
|
|
|
wxString Clone() const;
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Case-sensitive comparison.
|
|
|
|
Returns a positive value if the string is greater than the argument, zero if
|
|
|
|
it is equal to it or a negative value if it is less than the argument (same
|
|
|
|
semantics
|
|
|
|
as the standard @e strcmp() function).
|
|
|
|
See also CmpNoCase(), IsSameAs().
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int Cmp(const wxString& s) const;
|
|
|
|
const int Cmp(const wxChar* psz) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Case-insensitive comparison.
|
|
|
|
Returns a positive value if the string is greater than the argument, zero if
|
|
|
|
it is equal to it or a negative value if it is less than the argument (same
|
|
|
|
semantics
|
|
|
|
as the standard @e strcmp() function).
|
|
|
|
See also Cmp(), IsSameAs().
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int CmpNoCase(const wxString& s) const;
|
|
|
|
const int CmpNoCase(const wxChar* psz) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Case-sensitive comparison. Returns 0 if equal, 1 if greater or -1 if less.
|
|
|
|
This is a wxWidgets 1.xx compatibility function; use Cmp() instead.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int CompareTo(const wxChar* psz, caseCompare cmp = exact) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The default comparison function Cmp() is case-sensitive and
|
|
|
|
so is the default version of IsSameAs(). For case
|
|
|
|
insensitive comparisons you should use CmpNoCase() or
|
|
|
|
give a second parameter to IsSameAs. This last function is may be more
|
|
|
|
convenient if only equality of the strings matters because it returns a boolean
|
|
|
|
@true value if the strings are the same and not 0 (which is usually @false in
|
|
|
|
C)
|
|
|
|
as @c Cmp() does.
|
|
|
|
Matches() is a poor man's regular expression matcher:
|
|
|
|
it only understands '*' and '?' metacharacters in the sense of DOS command line
|
|
|
|
interpreter.
|
|
|
|
StartsWith() is helpful when parsing a line of
|
|
|
|
text which should start with some predefined prefix and is more efficient than
|
|
|
|
doing direct string comparison as you would also have to precalculate the
|
|
|
|
length of the prefix then.
|
|
|
|
Cmp()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
CmpNoCase()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
IsSameAs()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Matches()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
StartsWith()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
EndsWith()
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool operator ==(const wxString& x, const wxString& y);
|
2008-03-08 14:43:31 +00:00
|
|
|
bool operator ==(const wxString& x, const wxChar* t);
|
|
|
|
bool operator !=(const wxString& x, const wxString& y);
|
|
|
|
bool operator !=(const wxString& x, const wxChar* t);
|
|
|
|
bool operator(const wxString& x, const wxString& y);
|
|
|
|
bool operator(const wxString& x, const wxChar* t);
|
|
|
|
bool operator =(const wxString& x, const wxString& y);
|
|
|
|
bool operator =(const wxString& x, const wxChar* t);
|
|
|
|
bool operator(const wxString& x, const wxString& y);
|
|
|
|
bool operator(const wxString& x, const wxChar* t);
|
|
|
|
bool operator =(const wxString& x, const wxString& y);
|
|
|
|
bool operator =(const wxString& x, const wxChar* t);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Anything may be concatenated (appended to) with a string. However, you can't
|
|
|
|
append something to a C string (including literal constants), so to do this it
|
|
|
|
should be converted to a wxString first.
|
|
|
|
@ref operatorout() "operator "
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@ref plusequal() "operator +="
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@ref operatorplus() "operator +"
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Append()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Prepend()
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
A string may be constructed either from a C string, (some number of copies of)
|
|
|
|
a single character or a wide (UNICODE) string. For all constructors (except the
|
|
|
|
default which creates an empty string) there is also a corresponding assignment
|
|
|
|
operator.
|
|
|
|
@ref construct() wxString
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@ref operatorassign() "operator ="
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@ref destruct() ~wxString
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if target appears anywhere in wxString; else @false.
|
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool Contains(const wxString& str) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The string provides functions for conversion to signed and unsigned integer and
|
|
|
|
floating point numbers. All three functions take a pointer to the variable to
|
|
|
|
put the numeric value in and return @true if the @b entire string could be
|
|
|
|
converted to a number.
|
|
|
|
ToLong()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
ToLongLong()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
ToULong()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
ToULongLong()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
ToDouble()
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Makes the string empty, but doesn't free memory occupied by the string.
|
|
|
|
See also: Clear().
|
|
|
|
*/
|
|
|
|
void Empty();
|
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
This function can be used to test if the string ends with the specified
|
2008-03-08 13:52:38 +00:00
|
|
|
@e suffix. If it does, the function will return @true and put the
|
2008-03-09 12:33:59 +00:00
|
|
|
beginning of the string before the suffix into @a rest string if it is not
|
2008-03-08 13:52:38 +00:00
|
|
|
@NULL. Otherwise, the function returns @false and doesn't
|
|
|
|
modify the @e rest.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool EndsWith(const wxString& suffix, wxString rest = NULL) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Searches for the given string. Returns the starting index, or @c wxNOT_FOUND if
|
|
|
|
not found.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int Find(wxUniChar ch, bool fromEnd = false) const;
|
|
|
|
const int Find(const wxString& sub) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Same as Find().
|
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int First(wxChar c) const;
|
|
|
|
int First(const wxChar* psz) const;
|
|
|
|
const int First(const wxString& str) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
This static function returns the string containing the result of calling
|
2008-03-08 13:52:38 +00:00
|
|
|
Printf() with the passed parameters on it.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see FormatV(), Printf()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
static wxString Format(const wxChar format, ...);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
This static function returns the string containing the result of calling
|
2008-03-08 13:52:38 +00:00
|
|
|
PrintfV() with the passed parameters on it.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see Format(), PrintfV()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
static wxString FormatV(const wxChar format, va_list argptr);
|
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Returns the number of occurrences of @a ch in the string.
|
2008-03-08 13:52:38 +00:00
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int Freq(wxChar ch) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Converts given buffer of binary data from 8-bit string to wxString. In Unicode
|
|
|
|
build, the string is interpreted as being in ISO-8859-1 encoding. The version
|
2008-03-09 12:33:59 +00:00
|
|
|
without @a len parameter takes NUL-terminated data.
|
2008-03-08 13:52:38 +00:00
|
|
|
This is a convenience method useful when storing binary data in wxString.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-04-21 10:34:23 +00:00
|
|
|
@since 2.8.4
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see wxString::To8BitData
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
static wxString From8BitData(const char* buf, size_t len);
|
2008-03-08 14:43:31 +00:00
|
|
|
static wxString From8BitData(const char* buf);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Converts the string or character from an ASCII, 7-bit form
|
|
|
|
to the native wxString representation. Most useful when using
|
|
|
|
a Unicode build of wxWidgets (note the use of @c char instead of @c wxChar).
|
|
|
|
Use @ref construct() "wxString constructors" if you
|
|
|
|
need to convert from another charset.
|
|
|
|
*/
|
|
|
|
static wxString FromAscii(const char* s);
|
2008-03-08 14:43:31 +00:00
|
|
|
static wxString FromAscii(const unsigned char* s);
|
|
|
|
static wxString FromAscii(const char* s, size_t len);
|
|
|
|
static wxString FromAscii(const unsigned char* s, size_t len);
|
|
|
|
static wxString FromAscii(char c);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Converts C string encoded in UTF-8 to wxString.
|
2008-03-09 12:33:59 +00:00
|
|
|
Note that this method assumes that @a s is a valid UTF-8 sequence and
|
2008-03-08 13:52:38 +00:00
|
|
|
doesn't do any validation in release builds, it's validity is only checked in
|
|
|
|
debug builds.
|
|
|
|
*/
|
|
|
|
static wxString FromUTF8(const char* s);
|
2008-03-08 14:43:31 +00:00
|
|
|
static wxString FromUTF8(const char* s, size_t len);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Returns the character at position @a n (read-only).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxChar GetChar(size_t n) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
wxWidgets compatibility conversion. Returns a constant pointer to the data in
|
|
|
|
the string.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
const wxChar* GetData() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a reference to the character at position @e n.
|
|
|
|
*/
|
|
|
|
wxChar GetWritableChar(size_t n);
|
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Returns a writable buffer of at least @a len bytes.
|
2008-03-08 13:52:38 +00:00
|
|
|
It returns a pointer to a new memory block, and the
|
|
|
|
existing data will not be copied.
|
|
|
|
Call UngetWriteBuf() as soon as
|
|
|
|
possible to put the string back into a reasonable state.
|
|
|
|
This method is deprecated, please use
|
|
|
|
wxStringBuffer or
|
|
|
|
wxStringBufferLength instead.
|
|
|
|
*/
|
|
|
|
wxChar* GetWriteBuf(size_t len);
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Same as Find().
|
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
size_t Index(wxChar ch) const;
|
|
|
|
const size_t Index(const wxChar* sz) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the string contains only ASCII characters.
|
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool IsAscii() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the string is empty.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool IsEmpty() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the string is empty (same as wxString::IsEmpty).
|
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool IsNull() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the string is an integer (with possible sign).
|
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool IsNumber() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Test whether the string is equal to the single character @e c. The test is
|
2008-03-09 12:33:59 +00:00
|
|
|
case-sensitive if @a caseSensitive is @true (default) or not if it is @c
|
2008-03-08 13:52:38 +00:00
|
|
|
@false.
|
|
|
|
Returns @true if the string is equal to the character, @false otherwise.
|
|
|
|
See also Cmp(), CmpNoCase()
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool IsSameAs(const wxChar* psz, bool caseSensitive = true) const;
|
|
|
|
const bool IsSameAs(wxChar c, bool caseSensitive = true) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the string is a word.
|
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool IsWord() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Returns a reference to the last character (writable).
|
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
|
|
|
*/
|
|
|
|
wxChar Last();
|
2008-03-09 16:24:26 +00:00
|
|
|
const wxChar Last();
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Returns the first @a count characters of the string.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString Left(size_t count) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the length of the string.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
size_t Len() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the length of the string (same as Len).
|
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
size_t Length() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns this string converted to the lower case.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString Lower() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Same as MakeLower.
|
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
|
|
|
*/
|
|
|
|
void LowerCase();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Converts all characters to lower case and returns the result.
|
|
|
|
*/
|
|
|
|
wxString MakeLower();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Converts all characters to upper case and returns the result.
|
|
|
|
*/
|
|
|
|
wxString MakeUpper();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the string contents matches a mask containing '*' and '?'.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool Matches(const wxString& mask) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
These are "advanced" functions and they will be needed quite rarely.
|
2008-03-08 13:52:38 +00:00
|
|
|
Alloc() and Shrink() are only
|
2008-03-08 14:43:31 +00:00
|
|
|
interesting for optimization purposes.
|
2008-03-08 13:52:38 +00:00
|
|
|
wxStringBuffer
|
|
|
|
and wxStringBufferLength classes may be very
|
|
|
|
useful when working with some external API which requires the caller to provide
|
|
|
|
a writable buffer.
|
|
|
|
Alloc()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Shrink()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
wxStringBuffer
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
wxStringBufferLength
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a substring starting at @e first, with length @e count, or the rest of
|
2008-03-09 12:33:59 +00:00
|
|
|
the string if @a count is the default value.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString Mid(size_t first, size_t count = wxSTRING_MAXLEN) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Other string functions.
|
|
|
|
Trim()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Truncate()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Pad()
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Adds @a count copies of @a pad to the beginning, or to the end of the string
|
2008-03-08 13:52:38 +00:00
|
|
|
(the default).
|
|
|
|
Removes spaces from the left or from the right (default).
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
wxString Pad(size_t count, wxChar pad = ' ',
|
|
|
|
bool fromRight = true);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Prepends @a str to this string, returning a reference to this string.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
wxString Prepend(const wxString& str);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Similar to the standard function @e sprintf(). Returns the number of
|
|
|
|
characters written, or an integer less than zero on error.
|
|
|
|
Note that if @c wxUSE_PRINTF_POS_PARAMS is set to 1, then this function supports
|
|
|
|
Unix98-style positional parameters:
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-28 16:19:12 +00:00
|
|
|
@note This function will use a safe version of @e vsprintf() (usually called
|
2008-03-08 13:52:38 +00:00
|
|
|
@e vsnprintf()) whenever available to always allocate the buffer of correct
|
|
|
|
size. Unfortunately, this function is not available on all platforms and the
|
|
|
|
dangerous @e vsprintf() will be used then which may lead to buffer overflows.
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
int Printf(const wxChar* pszFormat, ...);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Similar to vprintf. Returns the number of characters written, or an integer
|
|
|
|
less than zero
|
|
|
|
on error.
|
|
|
|
*/
|
|
|
|
int PrintfV(const wxChar* pszFormat, va_list argPtr);
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Removes @a len characters from the string, starting at @e pos.
|
2008-03-08 13:52:38 +00:00
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
|
|
|
*/
|
|
|
|
wxString Remove(size_t pos);
|
2008-03-08 14:43:31 +00:00
|
|
|
wxString Remove(size_t pos, size_t len);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Removes the last character.
|
|
|
|
*/
|
|
|
|
wxString RemoveLast();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Replace first (or all) occurrences of substring with another one.
|
|
|
|
@e replaceAll: global replace (default), or only the first occurrence.
|
|
|
|
Returns the number of replacements made.
|
|
|
|
*/
|
|
|
|
size_t Replace(const wxString& strOld, const wxString& strNew,
|
2008-03-09 12:33:59 +00:00
|
|
|
bool replaceAll = true);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Returns the last @a count characters.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString Right(size_t count) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
These functions replace the standard @e strchr() and @e strstr()
|
2008-03-08 13:52:38 +00:00
|
|
|
functions.
|
|
|
|
Find()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Replace()
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the character at position @e n.
|
|
|
|
*/
|
|
|
|
void SetChar(size_t n, wxChar ch);
|
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
Minimizes the string's memory. This can be useful after a call to
|
2008-03-08 13:52:38 +00:00
|
|
|
Alloc() if too much memory were preallocated.
|
|
|
|
*/
|
|
|
|
void Shrink();
|
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
This function can be used to test if the string starts with the specified
|
2008-03-08 13:52:38 +00:00
|
|
|
@e prefix. If it does, the function will return @true and put the rest
|
2008-03-09 12:33:59 +00:00
|
|
|
of the string (i.e. after the prefix) into @a rest string if it is not
|
2008-03-08 13:52:38 +00:00
|
|
|
@NULL. Otherwise, the function returns @false and doesn't modify the
|
|
|
|
@e rest.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool StartsWith(const wxString& prefix, wxString rest = NULL) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
These functions return the string length and check whether the string is empty
|
|
|
|
or empty it.
|
|
|
|
Len()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
IsEmpty()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@ref operatornot() operator!
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Empty()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Clear()
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Strip characters at the front and/or end. The same as Trim except that it
|
|
|
|
doesn't change this string.
|
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString Strip(stripType s = trailing) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Returns the part of the string between the indices @a from and @e to
|
2008-03-08 13:52:38 +00:00
|
|
|
inclusive.
|
|
|
|
This is a wxWidgets 1.xx compatibility function, use Mid()
|
|
|
|
instead (but note that parameters have different meaning).
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString SubString(size_t from, size_t to) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
These functions allow to extract substring from this string. All of them don't
|
|
|
|
modify the original string and return a new string containing the extracted
|
|
|
|
substring.
|
|
|
|
Mid()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@ref operatorparenth() operator
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Left()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Right()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
BeforeFirst()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
BeforeLast()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
AfterFirst()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
AfterLast()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
StartsWith()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
EndsWith()
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Converts the string to an 8-bit string in ISO-8859-1 encoding in the form of
|
|
|
|
a wxCharBuffer (Unicode builds only).
|
|
|
|
This is a convenience method useful when storing binary data in wxString.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-04-21 10:34:23 +00:00
|
|
|
@since 2.8.4
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see wxString::From8BitData
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
const char* To8BitData() const;
|
|
|
|
const const wxCharBuffer To8BitData() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Converts the string to an ASCII, 7-bit string in the form of
|
|
|
|
a wxCharBuffer (Unicode builds only) or a C string (ANSI builds).
|
|
|
|
Note that this conversion only works if the string contains only ASCII
|
|
|
|
characters. The @ref mbstr() mb_str method provides more
|
|
|
|
powerful means of converting wxString to C string.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
const char* ToAscii() const;
|
|
|
|
const const wxCharBuffer ToAscii() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Attempts to convert the string to a floating point number. Returns @true on
|
|
|
|
success (the number is stored in the location pointed to by @e val) or @false
|
2008-03-09 12:33:59 +00:00
|
|
|
if the string does not represent such number (the value of @a val is not
|
2008-03-08 13:52:38 +00:00
|
|
|
modified in this case).
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see ToLong(), ToULong()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool ToDouble(double val) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Attempts to convert the string to a signed integer in base @e base. Returns
|
|
|
|
@true on success in which case the number is stored in the location
|
2008-03-09 12:33:59 +00:00
|
|
|
pointed to by @a val or @false if the string does not represent a
|
|
|
|
valid number in the given base (the value of @a val is not modified
|
2008-03-08 13:52:38 +00:00
|
|
|
in this case).
|
2008-03-09 12:33:59 +00:00
|
|
|
The value of @a base must be comprised between 2 and 36, inclusive, or
|
2008-03-08 13:52:38 +00:00
|
|
|
be a special value 0 which means that the usual rules of @c C numbers are
|
|
|
|
applied: if the number starts with @c 0x it is considered to be in base
|
|
|
|
16, if it starts with @c 0 - in base 8 and in base 10 otherwise. Note
|
|
|
|
that you may not want to specify the base 0 if you are parsing the numbers
|
|
|
|
which may have leading zeroes as they can yield unexpected (to the user not
|
|
|
|
familiar with C) results.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see ToDouble(), ToULong()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool ToLong(long val, int base = 10) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
This is exactly the same as ToLong() but works with 64
|
|
|
|
bit integer numbers.
|
|
|
|
Notice that currently it doesn't work (always returns @false) if parsing of 64
|
|
|
|
bit numbers is not supported by the underlying C run-time library. Compilers
|
|
|
|
with C99 support and Microsoft Visual C++ version 7 and higher do support this.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see ToLong(), ToULongLong()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool ToLongLong(wxLongLong_t val, int base = 10) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Attempts to convert the string to an unsigned integer in base @e base.
|
|
|
|
Returns @true on success in which case the number is stored in the
|
2008-03-09 12:33:59 +00:00
|
|
|
location pointed to by @a val or @false if the string does not
|
|
|
|
represent a valid number in the given base (the value of @a val is not
|
2008-03-08 13:52:38 +00:00
|
|
|
modified in this case). Please notice that this function
|
|
|
|
behaves in the same way as the standard @c strtoul() and so it simply
|
|
|
|
converts negative numbers to unsigned representation instead of rejecting them
|
|
|
|
(e.g. -1 is returned as @c ULONG_MAX).
|
|
|
|
See ToLong() for the more detailed
|
2008-03-09 12:33:59 +00:00
|
|
|
description of the @a base parameter.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see ToDouble(), ToLong()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool ToULong(unsigned long val, int base = 10) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
This is exactly the same as ToULong() but works with 64
|
|
|
|
bit integer numbers.
|
|
|
|
Please see ToLongLong() for additional remarks.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool ToULongLong(wxULongLong_t val, int base = 10) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Same as @ref wxString::utf8str utf8_str.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
const char* ToUTF8() const;
|
|
|
|
const const wxCharBuffer ToUF8() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Removes white-space (space, tabs, form feed, newline and carriage return) from
|
|
|
|
the left or from the right end of the string (right is default).
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
wxString Trim(bool fromRight = true);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Truncate the string to the given length.
|
|
|
|
*/
|
|
|
|
wxString Truncate(size_t len);
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Puts the string back into a reasonable state (in which it can be used
|
|
|
|
normally), after
|
|
|
|
GetWriteBuf() was called.
|
2008-03-09 12:33:59 +00:00
|
|
|
The version of the function without the @a len parameter will calculate the
|
2008-03-08 13:52:38 +00:00
|
|
|
new string length itself assuming that the string is terminated by the first
|
|
|
|
@c NUL character in it while the second one will use the specified length
|
|
|
|
and thus is the only version which should be used with the strings with
|
2008-03-08 14:43:31 +00:00
|
|
|
embedded @c NULs (it is also slightly more efficient as @c strlen()
|
2008-03-08 13:52:38 +00:00
|
|
|
doesn't have to be called).
|
|
|
|
This method is deprecated, please use
|
|
|
|
wxStringBuffer or
|
|
|
|
wxStringBufferLength instead.
|
|
|
|
*/
|
|
|
|
void UngetWriteBuf();
|
2008-03-08 14:43:31 +00:00
|
|
|
void UngetWriteBuf(size_t len);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns this string converted to upper case.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString Upper() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The same as MakeUpper.
|
|
|
|
This is a wxWidgets 1.xx compatibility function; you should not use it in new
|
|
|
|
code.
|
|
|
|
*/
|
|
|
|
void UpperCase();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Both formatted versions (wxString::Printf) and stream-like
|
2008-03-08 14:43:31 +00:00
|
|
|
insertion operators exist (for basic types only). Additionally, the
|
2008-03-08 13:52:38 +00:00
|
|
|
Format() function allows to use simply append
|
|
|
|
formatted value to a string:
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Format()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
FormatV()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Printf()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
PrintfV()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@ref operatorout() "operator "
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a pointer to the string data (@c const char* in ANSI build,
|
|
|
|
@c const wchar_t* in Unicode build).
|
|
|
|
Note that the returned value is not convertible to @c char* or
|
|
|
|
@c wchar_t*, use @ref charstr() char_str or
|
|
|
|
@ref wcharstr() wchar_string if you need to pass string value
|
|
|
|
to a function expecting non-const pointer.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see @ref mbstr() mb_str, @ref wcstr() wc_str, @ref
|
|
|
|
fnstr() fn_str, @ref charstr() char_str, @ref
|
|
|
|
wcharstr() wchar_string
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
const wxChar* c_str() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns an object with string data that is implicitly convertible to
|
|
|
|
@c char* pointer. Note that any change to the returned buffer is lost and so
|
|
|
|
this function is only usable for passing strings to legacy libraries that
|
|
|
|
don't have const-correct API. Use wxStringBuffer if
|
|
|
|
you want to modify the string.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see @ref mbstr() mb_str, @ref wcstr() wc_str, @ref
|
|
|
|
fnstr() fn_str, @ref cstr() c_str, @ref
|
|
|
|
wcharstr() wchar_str
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxWritableCharBuffer char_str(const wxMBConv& conv = wxConvLibc) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Returns string representation suitable for passing to OS' functions for
|
|
|
|
file handling. In ANSI build, this is same as @ref cstr() c_str.
|
|
|
|
In Unicode build, returned value can be either wide character string
|
|
|
|
or C string in charset matching the @c wxConvFileName object, depending on
|
|
|
|
the OS.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see wxMBConv, @ref wcstr() wc_str, @ref wcstr() mb_str
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
const wchar_t* fn_str() const;
|
|
|
|
const const char* fn_str() const;
|
|
|
|
const const wxCharBuffer fn_str() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Returns multibyte (C string) representation of the string.
|
|
|
|
In Unicode build, converts using @e conv's wxMBConv::cWC2MB
|
|
|
|
method and returns wxCharBuffer. In ANSI build, this function is same
|
|
|
|
as @ref cstr() c_str.
|
|
|
|
The macro wxWX2MBbuf is defined as the correct return type (without const).
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see wxMBConv, @ref cstr() c_str, @ref wcstr() wc_str, @ref
|
|
|
|
fnstr() fn_str, @ref charstr() char_str
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
const char* mb_str(const wxMBConv& conv = wxConvLibc) const;
|
|
|
|
const const wxCharBuffer mb_str(const wxMBConv& conv = wxConvLibc) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Extraction from a stream.
|
|
|
|
*/
|
|
|
|
friend istream operator(istream& is, wxString& str);
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
These functions work as C++ stream insertion operators: they insert the given
|
|
|
|
value into the string. Precision or format cannot be set using them, you can
|
2008-03-08 14:43:31 +00:00
|
|
|
use
|
2008-03-08 13:52:38 +00:00
|
|
|
Printf() for this.
|
|
|
|
*/
|
|
|
|
wxString operator(const wxString& str);
|
2008-03-08 14:43:31 +00:00
|
|
|
wxString operator(const wxChar* psz);
|
|
|
|
wxString operator(wxChar ch);
|
|
|
|
wxString operator(int i);
|
|
|
|
wxString operator(float f);
|
|
|
|
wxString operator(double d);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Same as Mid (substring extraction).
|
|
|
|
*/
|
|
|
|
wxString operator ()(size_t start, size_t len);
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Concatenation: all these operators return a new string equal to the
|
|
|
|
concatenation of the operands.
|
|
|
|
*/
|
|
|
|
wxString operator +(const wxString& x, const wxString& y);
|
2008-03-08 14:43:31 +00:00
|
|
|
wxString operator +(const wxString& x, const wxChar* y);
|
|
|
|
wxString operator +(const wxString& x, wxChar y);
|
|
|
|
wxString operator +(const wxChar* x, const wxString& y);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Concatenation in place: the argument is appended to the string.
|
|
|
|
*/
|
|
|
|
void operator +=(const wxString& str);
|
2008-03-08 14:43:31 +00:00
|
|
|
void operator +=(const wxChar* psz);
|
|
|
|
void operator +=(wxChar c);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Assignment: the effect of each operation is the same as for the corresponding
|
|
|
|
constructor (see @ref construct() "wxString constructors").
|
|
|
|
*/
|
|
|
|
wxString operator =(const wxString& str);
|
2008-03-08 14:43:31 +00:00
|
|
|
wxString operator =(const wxChar* psz);
|
|
|
|
wxString operator =(wxChar c);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Element extraction.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxChar operator [](size_t i) const;
|
|
|
|
wxChar operator [](size_t i) const;
|
|
|
|
const wxChar operator [](int i) const;
|
|
|
|
wxChar operator [](int i) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Implicit conversion to a C string.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
operator const wxChar*() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Empty string is @false, so !string will only return @true if the string is
|
|
|
|
empty.
|
|
|
|
This allows the tests for @NULLness of a @e const wxChar * pointer and emptiness
|
|
|
|
of the string to look the same in the code and makes it easier to port old code
|
|
|
|
to wxString.
|
|
|
|
See also IsEmpty().
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool operator!() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The supported functions are only listed here, please see any STL reference for
|
|
|
|
their documentation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Converts the strings contents to UTF-8 and returns it either as a temporary
|
|
|
|
wxCharBuffer object or as a pointer to the internal string contents in
|
|
|
|
UTF-8 build.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
const char* utf8_str() const;
|
|
|
|
const const wxCharBuffer utf8_str() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Returns wide character representation of the string.
|
|
|
|
In ANSI build, converts using @e conv's wxMBConv::cMB2WC
|
|
|
|
method and returns wxWCharBuffer. In Unicode build, this function is same
|
|
|
|
as @ref cstr() c_str.
|
|
|
|
The macro wxWX2WCbuf is defined as the correct return type (without const).
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see wxMBConv, @ref cstr() c_str, @ref wcstr() mb_str, @ref
|
|
|
|
fnstr() fn_str, @ref wcharstr() wchar_str
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
const wchar_t* wc_str(const wxMBConv& conv) const;
|
|
|
|
const const wxWCharBuffer wc_str(const wxMBConv& conv) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns an object with string data that is implicitly convertible to
|
|
|
|
@c char* pointer. Note that changes to the returned buffer may or may
|
|
|
|
not be lost (depending on the build) and so this function is only usable for
|
|
|
|
passing strings to legacy libraries that don't have const-correct API. Use
|
|
|
|
wxStringBuffer if you want to modify the string.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see @ref mbstr() mb_str, @ref wcstr() wc_str, @ref
|
|
|
|
fnstr() fn_str, @ref cstr() c_str, @ref
|
|
|
|
charstr() char_str
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxWritableWCharBuffer wchar_str() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
These functions are deprecated, please consider using new wxWidgets 2.0
|
|
|
|
functions instead of them (or, even better, std::string compatible variants).
|
|
|
|
CompareTo()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Contains()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
First()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Freq()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Index()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
IsAscii()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
IsNull()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
IsNumber()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
IsWord()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Last()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Length()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
LowerCase()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Remove()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Strip()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
SubString()
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
UpperCase()
|
|
|
|
*/
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
/**
|
|
|
|
FIXME
|
|
|
|
*/
|
|
|
|
wxString Objects:
|
|
|
|
;
|
|
|
|
|
|
|
|
/**
|
|
|
|
FIXME
|
|
|
|
*/
|
|
|
|
wxString wxEmptyString;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
@class wxStringBufferLength
|
|
|
|
@wxheader{string.h}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
|
|
|
This tiny class allows to conveniently access the wxString
|
2008-03-08 13:52:38 +00:00
|
|
|
internal buffer as a writable pointer without any risk of forgetting to restore
|
|
|
|
the string to the usable state later, and allows the user to set the internal
|
|
|
|
length of the string.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
|
|
|
For example, assuming you have a low-level OS function called
|
2008-03-08 13:52:38 +00:00
|
|
|
@c int GetMeaningOfLifeAsString(char *) copying the value in the provided
|
|
|
|
buffer (which must be writable, of course), and returning the actual length
|
|
|
|
of the string, you might call it like this:
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@code
|
|
|
|
wxString theAnswer;
|
|
|
|
wxStringBuffer theAnswerBuffer(theAnswer, 1024);
|
|
|
|
int nLength = GetMeaningOfLifeAsString(theAnswerBuffer);
|
|
|
|
theAnswerBuffer.SetLength(nLength);
|
|
|
|
if ( theAnswer != "42" )
|
|
|
|
{
|
|
|
|
wxLogError("Something is very wrong!");
|
|
|
|
}
|
|
|
|
@endcode
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Note that the exact usage of this depends on whether on not wxUSE_STL is
|
|
|
|
enabled. If
|
|
|
|
wxUSE_STL is enabled, wxStringBuffer creates a separate empty character buffer,
|
|
|
|
and
|
|
|
|
if wxUSE_STL is disabled, it uses GetWriteBuf() from wxString, keeping the same
|
|
|
|
buffer
|
|
|
|
wxString uses intact. In other words, relying on wxStringBuffer containing the
|
2008-03-08 14:43:31 +00:00
|
|
|
old
|
2008-03-08 13:52:38 +00:00
|
|
|
wxString data is probably not a good idea if you want to build your program in
|
|
|
|
both
|
|
|
|
with and without wxUSE_STL.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Note that SetLength @c must be called before wxStringBufferLength destructs.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxbase}
|
|
|
|
@category{FIXME}
|
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
class wxStringBufferLength
|
2008-03-08 13:52:38 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructs a writable string buffer object associated with the given string
|
2008-03-09 12:33:59 +00:00
|
|
|
and containing enough space for at least @a len characters. Basically, this
|
2008-03-08 13:52:38 +00:00
|
|
|
is equivalent to calling wxString::GetWriteBuf and
|
|
|
|
saving the result.
|
|
|
|
*/
|
|
|
|
wxStringBufferLength(const wxString& str, size_t len);
|
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
Restores the string passed to the constructor to the usable state by calling
|
2008-03-08 13:52:38 +00:00
|
|
|
wxString::UngetWriteBuf on it.
|
|
|
|
*/
|
|
|
|
~wxStringBufferLength();
|
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
Sets the internal length of the string referred to by wxStringBufferLength to
|
2008-03-09 12:33:59 +00:00
|
|
|
@a nLength characters.
|
2008-03-08 13:52:38 +00:00
|
|
|
Must be called before wxStringBufferLength destructs.
|
|
|
|
*/
|
|
|
|
void SetLength(size_t nLength);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the writable pointer to a buffer of the size at least equal to the
|
|
|
|
length specified in the constructor.
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
wxChar* operator wxChar *();
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
|
|
|
|