*/
wxString(const wxString& stringSrc);
+ /**
+ Construct a string consisting of @a nRepeat copies of ch.
+ */
+ wxString(wxUniChar ch, size_t nRepeat = 1);
+
+ /**
+ Construct a string consisting of @a nRepeat copies of ch.
+ */
+ wxString(wxUniCharRef ch, size_t nRepeat = 1);
+
+ /**
+ Construct a string consisting of @a nRepeat copies of ch
+ converted to Unicode using the current locale encoding.
+ */
+ wxString(char ch, size_t nRepeat = 1);
+
+ /**
+ Construct a string consisting of @a nRepeat copies of ch.
+ */
+ wxString(wchar_t ch, size_t nRepeat = 1);
/**
Constructs a string from the string literal @a psz using
/**
Constructs a string from @a str using the using the current locale encoding
to convert it to Unicode (wxConvLibc).
+
+ @see ToStdString()
*/
wxString(const std::string& str);
/**
Constructs a string from @a str.
+
+ @see ToStdWstring()
*/
wxString(const std::wstring& str);
*/
const wxCharBuffer ToAscii() const;
+ /**
+ Return the string as an std::string in current locale encoding.
+
+ Note that if the conversion of (Unicode) string contents to the current
+ locale fails, the return string will be empty. Be sure to check for
+ this to avoid silent data loss.
+
+ Instead of using this function it's also possible to write
+ @code
+ std::string s;
+ wxString wxs;
+ ...
+ s = std::string(wxs);
+ @endcode
+ but using ToStdString() may make the code more clear.
+
+ @since 2.9.1
+ */
+ std::string ToStdString() const;
+
+ /**
+ Return the string as an std::wstring.
+
+ Unlike ToStdString(), there is no danger of data loss when using this
+ function.
+
+ @since 2.9.1
+ */
+ std::wstring ToStdWstring() const;
+
/**
Same as utf8_str().
*/
wxString& operator<<(wchar_t ch);
wxString& operator<<(const wxCharBuffer& s);
wxString& operator<<(const wxWCharBuffer& s);
+ wxString& operator<<(wxUniChar ch);
wxString& operator<<(wxUniCharRef ch);
wxString& operator<<(unsigned int ui);
wxString& operator<<(long l);
@member_group_name{numconv, Conversion to numbers}
The string provides functions for conversion to signed and unsigned integer and
- floating point numbers. All 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.
- */
+ floating point numbers.
+
+ All 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. Notice if there is a valid number in the beginning of the
+ string, it is returned in the output parameter even if the function
+ returns @false because there is more text following it.
+ */
//@{
/**
Returns @true on success (the number is stored in the location pointed to by
@a val) or @false if the string does not represent such number (the value of
- @a val is not modified in this case).
+ @a val may still be modified in this case).
Note that unlike ToCDouble() this function uses a localized version of
@c wxStrtod() and thus needs as decimal point (and thousands separator) the
bool ToDouble(double* val) const;
/**
+ Variant of ToDouble() always working in "C" locale.
+
Works like ToDouble() but unlike it this function expects the floating point
number to be formatted always with the rules dictated by the "C" locale
(in particular, the decimal point must be a dot), independently from the
Returns @true on success in which case the number is stored in the 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 modified
- in this case).
+ valid number in the given base (the value of @a val may still be
+ modified in this case).
The value of @a base must be comprised between 2 and 36, inclusive, or
be a special value 0 which means that the usual rules of @c C numbers are
bool ToLong(long* val, int base = 10) const;
/**
+ Variant of ToLong() always working in "C" locale.
+
Works like ToLong() but unlike it this function expects the integer
number to be formatted always with the rules dictated by the "C" locale,
independently from the current application-wide locale (see wxLocale).
Returns @true on success in which case the number is stored in the
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
- modified in this case).
+ represent a valid number in the given base (the value of @a val may
+ still be 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
bool ToULong(unsigned long* val, int base = 10) const;
/**
+ Variant of ToULong() always working in "C" locale.
+
Works like ToULong() but unlike it this function expects the integer
number to be formatted always with the rules dictated by the "C" locale,
independently from the current application-wide locale (see wxLocale).
bool ToCULong(unsigned long* val, int base = 10) const;
/**
- This is exactly the same as ToULong() but works with 64
- bit integer numbers.
+ This is exactly the same as ToULong() but works with 64 bit integer
+ numbers.
+
Please see ToLongLong() for additional remarks.
*/
bool ToULongLong(wxULongLong_t* val, int base = 10) const;