]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/ustring.h
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / interface / wx / ustring.h
CommitLineData
9a6d1438
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/ustring.h
3// Purpose: interface of wxUString
4// Author: Robert Roebling
5// Copyright: (c) Robert Roebling
9a6d1438
RR
6// Licence: wxWindows licence
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxUString
11
12 wxUString is a class representing a Unicode character string where
13 each character is stored using a 32-bit value. This is different from
14 wxString which may store a character either as a UTF-8 or as a UTF-16
15 sequence and different from @c std::string which stores a string
d13b34d3 16 as a sequence of simple 8-bit characters and also different from
9a6d1438
RR
17 @c std::wstring which stores the string differently depending on
18 the definition of wchar_t.
cfbe5614 19
9a6d1438 20 The main purpose of wxUString is a to give users a Unicode string
cfbe5614 21 class that has O(1) access to its content, to be identical on all
9a6d1438
RR
22 platforms and to be easily convertable to wxString as well as other
23 ways to store strings (C string literals, wide character
0c339e7c
RR
24 string literals, character buffer, etc) by providing several overloads
25 and built-in conversions to and from the various string formats.
cfbe5614 26
9a6d1438
RR
27 wxUString derives from @c std::basic_string<wxChar32> and therefore
28 offers the complete API of @c std::string.
cfbe5614 29
9a6d1438
RR
30 @library{wxbase}
31 @category{data}
cfbe5614 32
9a6d1438
RR
33 @see wxString, @ref overview_string "wxString overview", @ref overview_unicode
34 "Unicode overview"
35*/
36
37
38class WXDLLIMPEXP_BASE wxUString: public std::basic_string<wxChar32>
39{
cfbe5614 40public:
9a6d1438
RR
41 /**
42 Default constructor.
43 */
44 wxUString();
45 /**
46 Copy constructor.
47 */
a1c9e3de 48 wxUString( const wxUString &str );
9a6d1438
RR
49 /**
50 Constructs a string from a 32-bit string literal.
51 */
cfbe5614 52 wxUString( const wxChar32 *str );
9a6d1438
RR
53 /**
54 Constructs a string from 32-bit string buffer.
55 */
cfbe5614 56 wxUString( const wxU32CharBuffer &buf );
9a6d1438
RR
57 /**
58 Constructs a string from C string literal using wxConvLibc to convert it to Unicode.
59 */
a1c9e3de 60 wxUString( const char *str );
9a6d1438
RR
61 /**
62 Constructs a string from C string buffer using wxConvLibc to convert it to Unicode.
63 */
a1c9e3de 64 wxUString( const wxCharBuffer &buf );
9a6d1438
RR
65 /**
66 Constructs a string from C string literal using @a conv to convert it to Unicode.
67 */
a1c9e3de 68 wxUString( const char *str, const wxMBConv &conv );
9a6d1438
RR
69 /**
70 Constructs a string from C string literal using @a conv to convert it to Unicode.
71 */
a1c9e3de 72 wxUString( const wxCharBuffer &buf, const wxMBConv &conv );
9a6d1438
RR
73 /**
74 Constructs a string from UTF-16 string literal
75 */
a1c9e3de 76 wxUString( const wxChar16 *str );
9a6d1438
RR
77 /**
78 Constructs a string from UTF-16 string buffer
79 */
a1c9e3de 80 wxUString( const wxU16CharBuffer &buf );
9a6d1438
RR
81 /**
82 Constructs a string from wxString.
83 */
a1c9e3de 84 wxUString( const wxString &str );
9a6d1438
RR
85 /**
86 Constructs a string from using wxConvLibc to convert it to Unicode.
87 */
a1c9e3de 88 wxUString( char ch );
9a6d1438
RR
89 /**
90 Constructs a string from a UTF-16 character.
91 */
a1c9e3de 92 wxUString( wxChar16 ch );
9a6d1438
RR
93 /**
94 Constructs a string from 32-bit Unicode character.
95 */
a1c9e3de 96 wxUString( wxChar32 ch );
9a6d1438
RR
97 /**
98 Constructs a string from wxUniChar (returned by wxString's access operator)
99 */
a1c9e3de 100 wxUString( wxUniChar ch );
9a6d1438
RR
101 /**
102 Constructs a string from wxUniCharRef (returned by wxString's access operator)
103 */
a1c9e3de 104 wxUString( wxUniCharRef ch );
9a6d1438
RR
105 /**
106 Constructs a string from @a n characters @a ch.
107 */
cfbe5614 108 wxUString( size_t n, char ch );
9a6d1438
RR
109 /**
110 Constructs a string from @a n characters @a ch.
111 */
cfbe5614 112 wxUString( size_t n, wxChar16 ch );
9a6d1438
RR
113 /**
114 Constructs a string from @a n characters @a ch.
115 */
cfbe5614 116 wxUString( size_t n, wxChar32 ch );
9a6d1438
RR
117 /**
118 Constructs a string from @a n characters @a ch.
119 */
cfbe5614 120 wxUString( size_t n, wxUniChar ch );
9a6d1438
RR
121 /**
122 Constructs a string from @a n characters @a ch.
123 */
cfbe5614
FM
124 wxUString( size_t n, wxUniCharRef ch );
125
9a6d1438
RR
126 /**
127 Static construction of a wxUString from a 7-bit ASCII string
128 */
cfbe5614 129 static wxUString FromAscii( const char *str, size_t n );
9a6d1438
RR
130 /**
131 Static construction of a wxUString from a 7-bit ASCII string
132 */
133 static wxUString FromAscii( const char *str );
134 /**
135 Static construction of a wxUString from a UTF-8 encoded string
136 */
cfbe5614 137 static wxUString FromUTF8( const char *str, size_t n );
9a6d1438
RR
138 /**
139 Static construction of a wxUString from a UTF-8 encoded string
140 */
141 static wxUString FromUTF8( const char *str );
142 /**
143 Static construction of a wxUString from a UTF-16 encoded string
144 */
cfbe5614 145 static wxUString FromUTF16( const wxChar16 *str, size_t n );
9a6d1438
RR
146 /**
147 Static construction of a wxUString from a UTF-16 encoded string
148 */
149 static wxUString FromUTF16( const wxChar16 *str );
cfbe5614 150
9a6d1438
RR
151
152 /**
d13b34d3 153 Assignment from a 7-bit ASCII string literal
cfbe5614 154 */
9a6d1438
RR
155 wxUString &assignFromAscii( const char *str );
156 /**
d13b34d3 157 Assignment from a 7-bit ASCII string literal
cfbe5614
FM
158 */
159 wxUString &assignFromAscii( const char *str, size_t n );
9a6d1438 160 /**
d13b34d3 161 Assignment from a UTF-8 string literal
cfbe5614 162 */
9a6d1438
RR
163 wxUString &assignFromUTF8( const char *str );
164 /**
d13b34d3 165 Assignment from a UTF-8 string literal
cfbe5614
FM
166 */
167 wxUString &assignFromUTF8( const char *str, size_t n );
9a6d1438 168 /**
d13b34d3 169 Assignment from a UTF-16 string literal
cfbe5614 170 */
9a6d1438
RR
171 wxUString &assignFromUTF16( const wxChar16* str );
172 /**
d13b34d3 173 Assignment from a UTF-16 string literal
cfbe5614
FM
174 */
175 wxUString &assignFromUTF16( const wxChar16* str, size_t n );
9a6d1438 176 /**
d13b34d3 177 Assignment from a C string literal using wxConvLibc
cfbe5614 178 */
9a6d1438
RR
179 wxUString &assignFromCString( const char* str );
180 /**
d13b34d3 181 Assignment from a C string literal using @a conv
cfbe5614 182 */
9a6d1438 183 wxUString &assignFromCString( const char* str, const wxMBConv &conv );
cfbe5614 184
9a6d1438
RR
185 /**
186 Conversion to a UTF-8 string
187 */
188 wxCharBuffer utf8_str() const;
189 /**
190 Conversion to a UTF-16 string
191 */
192 wxU16CharBuffer utf16_str() const;
cfbe5614 193
9a6d1438
RR
194 /**
195 Conversion to a wide character string (either UTF-16
196 or UCS-4, depending on the size of wchar_t).
197 */
198 wxWCharBuffer wc_str() const;
199
200 /**
201 Implicit conversion to wxString.
202 */
203 operator wxString() const;
204
205 /**
0c339e7c 206 wxUString assignment. wxUString additionally provides overloads for
9a6d1438
RR
207 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
208 single and repeated characters etc.
209 */
210 wxUString &assign( const wxUString &str );
cfbe5614 211
9a6d1438 212 /**
0c339e7c 213 Appending. wxUString additionally provides overloads for
9a6d1438
RR
214 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
215 single and repeated characters etc.
216 */
217 wxUString &append( const wxUString &s );
cfbe5614 218
9a6d1438 219 /**
0c339e7c 220 Insertion. wxUString additionally provides overloads for
9a6d1438
RR
221 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
222 single characters etc.
223 */
cfbe5614 224 wxUString &insert( size_t pos, const wxUString &s );
9a6d1438
RR
225
226 /**
0c339e7c 227 Assignment operator. wxUString additionally provides overloads for
9a6d1438
RR
228 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
229 single characters etc.
230 */
231 inline wxUString& operator=(const wxUString& s);
cfbe5614 232
9a6d1438 233 /**
0c339e7c 234 Concatenation operator. wxUString additionally provides overloads for
9a6d1438
RR
235 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
236 single characters etc.
237 */
238 inline wxUString& operator+=(const wxUString& s);
cfbe5614 239
9a6d1438
RR
240};
241
242 /**
0c339e7c 243 Concatenation operator. wxUString additionally provides overloads for
9a6d1438
RR
244 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
245 single characters etc.
246 */
247inline wxUString operator+(const wxUString &s1, const wxUString &s2);
248
249 /**
0c339e7c 250 Equality operator. wxUString additionally provides overloads for
9a6d1438
RR
251 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
252 single characters etc.
253 */
254inline bool operator==(const wxUString& s1, const wxUString& s2);
255 /**
0c339e7c 256 Inequality operator. wxUString additionally provides overloads for
9a6d1438
RR
257 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
258 single characters etc.
259 */
260inline bool operator!=(const wxUString& s1, const wxUString& s2);
261 /**
0c339e7c 262 Comparison operator. wxUString additionally provides overloads for
9a6d1438
RR
263 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
264 single characters etc.
265 */
266inline bool operator< (const wxUString& s1, const wxUString& s2);
267 /**
0c339e7c 268 Comparison operator. wxUString additionally provides overloads for
9a6d1438
RR
269 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
270 single characters etc.
271 */
272inline bool operator> (const wxUString& s1, const wxUString& s2);
273 /**
0c339e7c 274 Comparison operator. wxUString additionally provides overloads for
9a6d1438
RR
275 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
276 single characters etc.
277 */
278inline bool operator<=(const wxUString& s1, const wxUString& s2);
279 /**
0c339e7c 280 Comparison operator. wxUString additionally provides overloads for
9a6d1438
RR
281 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
282 single characters etc.
283 */
284inline bool operator>=(const wxUString& s1, const wxUString& s2);