]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: unichar.h | |
3 | // Purpose: interface of wxUniChar | |
4 | // Author: wxWidgets team | |
5 | // Licence: wxWindows licence | |
6 | ///////////////////////////////////////////////////////////////////////////// | |
7 | ||
8 | /** | |
9 | @class wxUniChar | |
10 | ||
11 | This class represents a single Unicode character. It can be converted to | |
12 | and from @c char or @c wchar_t and implements commonly used character operations. | |
13 | ||
14 | @library{wxbase} | |
15 | @category{data} | |
16 | */ | |
17 | class wxUniChar | |
18 | { | |
19 | public: | |
20 | /** | |
21 | A type capable of holding any Unicode code point. | |
22 | We do not use wchar_t as it cannot do the job on Win32, | |
23 | where wchar_t is a 16-bit type (wchar_t* is encoded using UTF-16 on Win32). | |
24 | */ | |
25 | typedef wxUint32 value_type; | |
26 | ||
27 | /** | |
28 | Default ctor. | |
29 | */ | |
30 | wxUniChar(); | |
31 | ||
32 | //@{ | |
33 | /** | |
34 | Create a character from the 8-bit character value @a c using the | |
35 | current locale encoding. | |
36 | */ | |
37 | wxUniChar(char c); | |
38 | wxUniChar(unsigned char c); | |
39 | //@} | |
40 | ||
41 | wxUniChar(int c); | |
42 | wxUniChar(unsigned int c); | |
43 | wxUniChar(long int c); | |
44 | wxUniChar(unsigned long int c); | |
45 | wxUniChar(short int c); | |
46 | wxUniChar(unsigned short int c); | |
47 | wxUniChar(wxLongLong_t c); | |
48 | wxUniChar(wxULongLong_t c); | |
49 | ||
50 | wxUniChar(const wxUniCharRef& c); | |
51 | ||
52 | /** | |
53 | Returns Unicode code point value of the character. | |
54 | */ | |
55 | value_type GetValue() const; | |
56 | ||
57 | /** | |
58 | Returns true if the character is an ASCII character (i.e.\ if its value is less than 128). | |
59 | */ | |
60 | bool IsAscii() const; | |
61 | ||
62 | /** | |
63 | Returns true if the character is representable as a single byte in the | |
64 | current locale encoding. | |
65 | ||
66 | This function only returns true if the character can be converted in | |
67 | exactly one byte, e.g. it only returns true for 7 bit ASCII characters | |
68 | when the encoding used is UTF-8. | |
69 | ||
70 | It is mostly useful to test if the character can be passed to functions | |
71 | taking a char and is used by wxWidgets itself for this purpose. | |
72 | ||
73 | @param c | |
74 | An output pointer to the value of this Unicode character as a @c | |
75 | char. Must be non-@NULL. | |
76 | @return | |
77 | @true if the object is an 8 bit char and @a c was filled with its | |
78 | value as char or @false otherwise (@a c won't be modified then). | |
79 | ||
80 | @see IsAscii() | |
81 | ||
82 | @since 2.9.1 | |
83 | */ | |
84 | bool GetAsChar(char *c) const; | |
85 | ||
86 | //@{ | |
87 | /** | |
88 | Conversions to char and wchar_t types: all of those are needed to be | |
89 | able to pass wxUniChars to various standard narrow and wide character | |
90 | functions. | |
91 | */ | |
92 | operator char() const; | |
93 | operator unsigned char() const; | |
94 | operator wchar_t() const; | |
95 | operator int() const; | |
96 | operator unsigned int() const; | |
97 | operator long int() const; | |
98 | operator unsigned long int() const; | |
99 | operator short int() const; | |
100 | operator unsigned short int() const; | |
101 | operator wxLongLong_t() const; | |
102 | operator wxULongLong_t() const; | |
103 | //@} | |
104 | ||
105 | //@{ | |
106 | /** | |
107 | Assignment operators | |
108 | */ | |
109 | wxUniChar& operator=(const wxUniChar& c); | |
110 | wxUniChar& operator=(const wxUniCharRef& c); | |
111 | wxUniChar& operator=(char c); | |
112 | wxUniChar& operator=(unsigned char c); | |
113 | wxUniChar& operator=(wchar_t c); | |
114 | wxUniChar& operator=(int c); | |
115 | wxUniChar& operator=(unsigned int c); | |
116 | wxUniChar& operator=(long int c); | |
117 | wxUniChar& operator=(unsigned long int c); | |
118 | wxUniChar& operator=(short int c); | |
119 | wxUniChar& operator=(unsigned short int c); | |
120 | wxUniChar& operator=(wxLongLong_t c); | |
121 | wxUniChar& operator=(wxULongLong_t c); | |
122 | //@} | |
123 | }; | |
124 | ||
125 | ||
126 | /** | |
127 | @class wxUniCharRef | |
128 | ||
129 | Writeable reference to a character in wxString. | |
130 | ||
131 | This class can be used in the same way wxChar is used, except that changing | |
132 | its value updates the underlying string object. | |
133 | ||
134 | @library{wxbase} | |
135 | @category{data} | |
136 | */ | |
137 | class wxUniCharRef | |
138 | { | |
139 | public: | |
140 | }; | |
141 |