2008-07-29 07:01:16 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/ustring.h
|
|
|
|
// Purpose: interface of wxUString
|
|
|
|
// Author: Robert Roebling
|
|
|
|
// Copyright: (c) Robert Roebling
|
|
|
|
// RCS-ID: $Id: tab.h 37400 2006-02-09 00:28:34Z VZ $
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxUString
|
|
|
|
|
|
|
|
wxUString is a class representing a Unicode character string where
|
|
|
|
each character is stored using a 32-bit value. This is different from
|
|
|
|
wxString which may store a character either as a UTF-8 or as a UTF-16
|
|
|
|
sequence and different from @c std::string which stores a string
|
|
|
|
as a squence of simple 8-bit charactesr and also different from
|
|
|
|
@c std::wstring which stores the string differently depending on
|
|
|
|
the definition of wchar_t.
|
2008-10-28 10:29:36 -04:00
|
|
|
|
2008-07-29 07:01:16 -04:00
|
|
|
The main purpose of wxUString is a to give users a Unicode string
|
2008-10-28 10:29:36 -04:00
|
|
|
class that has O(1) access to its content, to be identical on all
|
2008-07-29 07:01:16 -04:00
|
|
|
platforms and to be easily convertable to wxString as well as other
|
|
|
|
ways to store strings (C string literals, wide character
|
2008-08-02 10:10:54 -04:00
|
|
|
string literals, character buffer, etc) by providing several overloads
|
|
|
|
and built-in conversions to and from the various string formats.
|
2008-10-28 10:29:36 -04:00
|
|
|
|
2008-07-29 07:01:16 -04:00
|
|
|
wxUString derives from @c std::basic_string<wxChar32> and therefore
|
|
|
|
offers the complete API of @c std::string.
|
2008-10-28 10:29:36 -04:00
|
|
|
|
2008-07-29 07:01:16 -04:00
|
|
|
@library{wxbase}
|
|
|
|
@category{data}
|
2008-10-28 10:29:36 -04:00
|
|
|
|
2008-07-29 07:01:16 -04:00
|
|
|
@see wxString, @ref overview_string "wxString overview", @ref overview_unicode
|
|
|
|
"Unicode overview"
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_BASE wxUString: public std::basic_string<wxChar32>
|
|
|
|
{
|
2008-10-28 10:29:36 -04:00
|
|
|
public:
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Default constructor.
|
|
|
|
*/
|
|
|
|
wxUString();
|
|
|
|
/**
|
|
|
|
Copy constructor.
|
|
|
|
*/
|
2008-07-29 08:43:12 -04:00
|
|
|
wxUString( const wxUString &str );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from a 32-bit string literal.
|
|
|
|
*/
|
2008-10-28 10:29:36 -04:00
|
|
|
wxUString( const wxChar32 *str );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from 32-bit string buffer.
|
|
|
|
*/
|
2008-10-28 10:29:36 -04:00
|
|
|
wxUString( const wxU32CharBuffer &buf );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from C string literal using wxConvLibc to convert it to Unicode.
|
|
|
|
*/
|
2008-07-29 08:43:12 -04:00
|
|
|
wxUString( const char *str );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from C string buffer using wxConvLibc to convert it to Unicode.
|
|
|
|
*/
|
2008-07-29 08:43:12 -04:00
|
|
|
wxUString( const wxCharBuffer &buf );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from C string literal using @a conv to convert it to Unicode.
|
|
|
|
*/
|
2008-07-29 08:43:12 -04:00
|
|
|
wxUString( const char *str, const wxMBConv &conv );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from C string literal using @a conv to convert it to Unicode.
|
|
|
|
*/
|
2008-07-29 08:43:12 -04:00
|
|
|
wxUString( const wxCharBuffer &buf, const wxMBConv &conv );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from UTF-16 string literal
|
|
|
|
*/
|
2008-07-29 08:43:12 -04:00
|
|
|
wxUString( const wxChar16 *str );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from UTF-16 string buffer
|
|
|
|
*/
|
2008-07-29 08:43:12 -04:00
|
|
|
wxUString( const wxU16CharBuffer &buf );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from wxString.
|
|
|
|
*/
|
2008-07-29 08:43:12 -04:00
|
|
|
wxUString( const wxString &str );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from using wxConvLibc to convert it to Unicode.
|
|
|
|
*/
|
2008-07-29 08:43:12 -04:00
|
|
|
wxUString( char ch );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from a UTF-16 character.
|
|
|
|
*/
|
2008-07-29 08:43:12 -04:00
|
|
|
wxUString( wxChar16 ch );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from 32-bit Unicode character.
|
|
|
|
*/
|
2008-07-29 08:43:12 -04:00
|
|
|
wxUString( wxChar32 ch );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from wxUniChar (returned by wxString's access operator)
|
|
|
|
*/
|
2008-07-29 08:43:12 -04:00
|
|
|
wxUString( wxUniChar ch );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from wxUniCharRef (returned by wxString's access operator)
|
|
|
|
*/
|
2008-07-29 08:43:12 -04:00
|
|
|
wxUString( wxUniCharRef ch );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from @a n characters @a ch.
|
|
|
|
*/
|
2008-10-28 10:29:36 -04:00
|
|
|
wxUString( size_t n, char ch );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from @a n characters @a ch.
|
|
|
|
*/
|
2008-10-28 10:29:36 -04:00
|
|
|
wxUString( size_t n, wxChar16 ch );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from @a n characters @a ch.
|
|
|
|
*/
|
2008-10-28 10:29:36 -04:00
|
|
|
wxUString( size_t n, wxChar32 ch );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from @a n characters @a ch.
|
|
|
|
*/
|
2008-10-28 10:29:36 -04:00
|
|
|
wxUString( size_t n, wxUniChar ch );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Constructs a string from @a n characters @a ch.
|
|
|
|
*/
|
2008-10-28 10:29:36 -04:00
|
|
|
wxUString( size_t n, wxUniCharRef ch );
|
|
|
|
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Static construction of a wxUString from a 7-bit ASCII string
|
|
|
|
*/
|
2008-10-28 10:29:36 -04:00
|
|
|
static wxUString FromAscii( const char *str, size_t n );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Static construction of a wxUString from a 7-bit ASCII string
|
|
|
|
*/
|
|
|
|
static wxUString FromAscii( const char *str );
|
|
|
|
/**
|
|
|
|
Static construction of a wxUString from a UTF-8 encoded string
|
|
|
|
*/
|
2008-10-28 10:29:36 -04:00
|
|
|
static wxUString FromUTF8( const char *str, size_t n );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Static construction of a wxUString from a UTF-8 encoded string
|
|
|
|
*/
|
|
|
|
static wxUString FromUTF8( const char *str );
|
|
|
|
/**
|
|
|
|
Static construction of a wxUString from a UTF-16 encoded string
|
|
|
|
*/
|
2008-10-28 10:29:36 -04:00
|
|
|
static wxUString FromUTF16( const wxChar16 *str, size_t n );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Static construction of a wxUString from a UTF-16 encoded string
|
|
|
|
*/
|
|
|
|
static wxUString FromUTF16( const wxChar16 *str );
|
2008-10-28 10:29:36 -04:00
|
|
|
|
2008-07-29 07:01:16 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Assigment from a 7-bit ASCII string literal
|
2008-10-28 10:29:36 -04:00
|
|
|
*/
|
2008-07-29 07:01:16 -04:00
|
|
|
wxUString &assignFromAscii( const char *str );
|
|
|
|
/**
|
|
|
|
Assigment from a 7-bit ASCII string literal
|
2008-10-28 10:29:36 -04:00
|
|
|
*/
|
|
|
|
wxUString &assignFromAscii( const char *str, size_t n );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Assigment from a UTF-8 string literal
|
2008-10-28 10:29:36 -04:00
|
|
|
*/
|
2008-07-29 07:01:16 -04:00
|
|
|
wxUString &assignFromUTF8( const char *str );
|
|
|
|
/**
|
|
|
|
Assigment from a UTF-8 string literal
|
2008-10-28 10:29:36 -04:00
|
|
|
*/
|
|
|
|
wxUString &assignFromUTF8( const char *str, size_t n );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Assigment from a UTF-16 string literal
|
2008-10-28 10:29:36 -04:00
|
|
|
*/
|
2008-07-29 07:01:16 -04:00
|
|
|
wxUString &assignFromUTF16( const wxChar16* str );
|
|
|
|
/**
|
|
|
|
Assigment from a UTF-16 string literal
|
2008-10-28 10:29:36 -04:00
|
|
|
*/
|
|
|
|
wxUString &assignFromUTF16( const wxChar16* str, size_t n );
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Assigment from a C string literal using wxConvLibc
|
2008-10-28 10:29:36 -04:00
|
|
|
*/
|
2008-07-29 07:01:16 -04:00
|
|
|
wxUString &assignFromCString( const char* str );
|
|
|
|
/**
|
|
|
|
Assigment from a C string literal using @a conv
|
2008-10-28 10:29:36 -04:00
|
|
|
*/
|
2008-07-29 07:01:16 -04:00
|
|
|
wxUString &assignFromCString( const char* str, const wxMBConv &conv );
|
2008-10-28 10:29:36 -04:00
|
|
|
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Conversion to a UTF-8 string
|
|
|
|
*/
|
|
|
|
wxCharBuffer utf8_str() const;
|
|
|
|
/**
|
|
|
|
Conversion to a UTF-16 string
|
|
|
|
*/
|
|
|
|
wxU16CharBuffer utf16_str() const;
|
2008-10-28 10:29:36 -04:00
|
|
|
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
|
|
|
Conversion to a wide character string (either UTF-16
|
|
|
|
or UCS-4, depending on the size of wchar_t).
|
|
|
|
*/
|
|
|
|
wxWCharBuffer wc_str() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Implicit conversion to wxString.
|
|
|
|
*/
|
|
|
|
operator wxString() const;
|
|
|
|
|
|
|
|
/**
|
2008-08-02 10:10:54 -04:00
|
|
|
wxUString assignment. wxUString additionally provides overloads for
|
2008-07-29 07:01:16 -04:00
|
|
|
wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
|
|
|
|
single and repeated characters etc.
|
|
|
|
*/
|
|
|
|
wxUString &assign( const wxUString &str );
|
2008-10-28 10:29:36 -04:00
|
|
|
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
2008-08-02 10:10:54 -04:00
|
|
|
Appending. wxUString additionally provides overloads for
|
2008-07-29 07:01:16 -04:00
|
|
|
wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
|
|
|
|
single and repeated characters etc.
|
|
|
|
*/
|
|
|
|
wxUString &append( const wxUString &s );
|
2008-10-28 10:29:36 -04:00
|
|
|
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
2008-08-02 10:10:54 -04:00
|
|
|
Insertion. wxUString additionally provides overloads for
|
2008-07-29 07:01:16 -04:00
|
|
|
wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
|
|
|
|
single characters etc.
|
|
|
|
*/
|
2008-10-28 10:29:36 -04:00
|
|
|
wxUString &insert( size_t pos, const wxUString &s );
|
2008-07-29 07:01:16 -04:00
|
|
|
|
|
|
|
/**
|
2008-08-02 10:10:54 -04:00
|
|
|
Assignment operator. wxUString additionally provides overloads for
|
2008-07-29 07:01:16 -04:00
|
|
|
wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
|
|
|
|
single characters etc.
|
|
|
|
*/
|
|
|
|
inline wxUString& operator=(const wxUString& s);
|
2008-10-28 10:29:36 -04:00
|
|
|
|
2008-07-29 07:01:16 -04:00
|
|
|
/**
|
2008-08-02 10:10:54 -04:00
|
|
|
Concatenation operator. wxUString additionally provides overloads for
|
2008-07-29 07:01:16 -04:00
|
|
|
wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
|
|
|
|
single characters etc.
|
|
|
|
*/
|
|
|
|
inline wxUString& operator+=(const wxUString& s);
|
2008-10-28 10:29:36 -04:00
|
|
|
|
2008-07-29 07:01:16 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2008-08-02 10:10:54 -04:00
|
|
|
Concatenation operator. wxUString additionally provides overloads for
|
2008-07-29 07:01:16 -04:00
|
|
|
wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
|
|
|
|
single characters etc.
|
|
|
|
*/
|
|
|
|
inline wxUString operator+(const wxUString &s1, const wxUString &s2);
|
|
|
|
|
|
|
|
/**
|
2008-08-02 10:10:54 -04:00
|
|
|
Equality operator. wxUString additionally provides overloads for
|
2008-07-29 07:01:16 -04:00
|
|
|
wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
|
|
|
|
single characters etc.
|
|
|
|
*/
|
|
|
|
inline bool operator==(const wxUString& s1, const wxUString& s2);
|
|
|
|
/**
|
2008-08-02 10:10:54 -04:00
|
|
|
Inequality operator. wxUString additionally provides overloads for
|
2008-07-29 07:01:16 -04:00
|
|
|
wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
|
|
|
|
single characters etc.
|
|
|
|
*/
|
|
|
|
inline bool operator!=(const wxUString& s1, const wxUString& s2);
|
|
|
|
/**
|
2008-08-02 10:10:54 -04:00
|
|
|
Comparison operator. wxUString additionally provides overloads for
|
2008-07-29 07:01:16 -04:00
|
|
|
wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
|
|
|
|
single characters etc.
|
|
|
|
*/
|
|
|
|
inline bool operator< (const wxUString& s1, const wxUString& s2);
|
|
|
|
/**
|
2008-08-02 10:10:54 -04:00
|
|
|
Comparison operator. wxUString additionally provides overloads for
|
2008-07-29 07:01:16 -04:00
|
|
|
wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
|
|
|
|
single characters etc.
|
|
|
|
*/
|
|
|
|
inline bool operator> (const wxUString& s1, const wxUString& s2);
|
|
|
|
/**
|
2008-08-02 10:10:54 -04:00
|
|
|
Comparison operator. wxUString additionally provides overloads for
|
2008-07-29 07:01:16 -04:00
|
|
|
wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
|
|
|
|
single characters etc.
|
|
|
|
*/
|
|
|
|
inline bool operator<=(const wxUString& s1, const wxUString& s2);
|
|
|
|
/**
|
2008-08-02 10:10:54 -04:00
|
|
|
Comparison operator. wxUString additionally provides overloads for
|
2008-07-29 07:01:16 -04:00
|
|
|
wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
|
|
|
|
single characters etc.
|
|
|
|
*/
|
|
|
|
inline bool operator>=(const wxUString& s1, const wxUString& s2);
|