Line data Source code
1 : /****************************************************************************
2 : **
3 : ** Copyright (C) 2016 The Qt Company Ltd.
4 : ** Contact: https://www.qt.io/licensing/
5 : **
6 : ** This file is part of the QtCore module of the Qt Toolkit.
7 : **
8 : ** $QT_BEGIN_LICENSE:LGPL$
9 : ** Commercial License Usage
10 : ** Licensees holding valid commercial Qt licenses may use this file in
11 : ** accordance with the commercial license agreement provided with the
12 : ** Software or, alternatively, in accordance with the terms contained in
13 : ** a written agreement between you and The Qt Company. For licensing terms
14 : ** and conditions see https://www.qt.io/terms-conditions. For further
15 : ** information use the contact form at https://www.qt.io/contact-us.
16 : **
17 : ** GNU Lesser General Public License Usage
18 : ** Alternatively, this file may be used under the terms of the GNU Lesser
19 : ** General Public License version 3 as published by the Free Software
20 : ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 : ** packaging of this file. Please review the following information to
22 : ** ensure the GNU Lesser General Public License version 3 requirements
23 : ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 : **
25 : ** GNU General Public License Usage
26 : ** Alternatively, this file may be used under the terms of the GNU
27 : ** General Public License version 2.0 or (at your option) the GNU General
28 : ** Public license version 3 or any later version approved by the KDE Free
29 : ** Qt Foundation. The licenses are as published by the Free Software
30 : ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 : ** included in the packaging of this file. Please review the following
32 : ** information to ensure the GNU General Public License requirements will
33 : ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 : ** https://www.gnu.org/licenses/gpl-3.0.html.
35 : **
36 : ** $QT_END_LICENSE$
37 : **
38 : ****************************************************************************/
39 :
40 : #ifndef QCHAR_H
41 : #define QCHAR_H
42 :
43 : #include <QtCore/qglobal.h>
44 :
45 : QT_BEGIN_NAMESPACE
46 :
47 :
48 : class QString;
49 :
50 : struct QLatin1Char
51 : {
52 : public:
53 38 : Q_DECL_CONSTEXPR inline explicit QLatin1Char(char c) Q_DECL_NOTHROW : ch(c) {}
54 : Q_DECL_CONSTEXPR inline char toLatin1() const Q_DECL_NOTHROW { return ch; }
55 38 : Q_DECL_CONSTEXPR inline ushort unicode() const Q_DECL_NOTHROW { return ushort(uchar(ch)); }
56 :
57 : private:
58 : char ch;
59 : };
60 :
61 :
62 : class Q_CORE_EXPORT QChar {
63 : public:
64 : enum SpecialCharacter {
65 : Null = 0x0000,
66 : Tabulation = 0x0009,
67 : LineFeed = 0x000a,
68 : CarriageReturn = 0x000d,
69 : Space = 0x0020,
70 : Nbsp = 0x00a0,
71 : SoftHyphen = 0x00ad,
72 : ReplacementCharacter = 0xfffd,
73 : ObjectReplacementCharacter = 0xfffc,
74 : ByteOrderMark = 0xfeff,
75 : ByteOrderSwapped = 0xfffe,
76 : ParagraphSeparator = 0x2029,
77 : LineSeparator = 0x2028,
78 : LastValidCodePoint = 0x10ffff
79 : };
80 :
81 : Q_DECL_CONSTEXPR QChar() Q_DECL_NOTHROW : ucs(0) {}
82 80 : Q_DECL_CONSTEXPR QChar(ushort rc) Q_DECL_NOTHROW : ucs(rc) {} // implicit
83 : Q_DECL_CONSTEXPR QChar(uchar c, uchar r) Q_DECL_NOTHROW : ucs(ushort((r << 8) | c)) {}
84 : Q_DECL_CONSTEXPR QChar(short rc) Q_DECL_NOTHROW : ucs(ushort(rc)) {} // implicit
85 : Q_DECL_CONSTEXPR QChar(uint rc) Q_DECL_NOTHROW : ucs(ushort(rc & 0xffff)) {}
86 : Q_DECL_CONSTEXPR QChar(int rc) Q_DECL_NOTHROW : ucs(ushort(rc & 0xffff)) {}
87 : Q_DECL_CONSTEXPR QChar(SpecialCharacter s) Q_DECL_NOTHROW : ucs(ushort(s)) {} // implicit
88 38 : Q_DECL_CONSTEXPR QChar(QLatin1Char ch) Q_DECL_NOTHROW : ucs(ch.unicode()) {} // implicit
89 : #if defined(Q_COMPILER_UNICODE_STRINGS)
90 : Q_DECL_CONSTEXPR QChar(char16_t ch) Q_DECL_NOTHROW : ucs(ushort(ch)) {} // implicit
91 : #endif
92 : #if defined(Q_OS_WIN)
93 : Q_STATIC_ASSERT(sizeof(wchar_t) == sizeof(ushort));
94 : Q_DECL_CONSTEXPR QChar(wchar_t ch) Q_DECL_NOTHROW : ucs(ushort(ch)) {} // implicit
95 : #endif
96 :
97 : #ifndef QT_NO_CAST_FROM_ASCII
98 : QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(char c) Q_DECL_NOTHROW : ucs(uchar(c)) { }
99 : #ifndef QT_RESTRICTED_CAST_FROM_ASCII
100 : QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(uchar c) Q_DECL_NOTHROW : ucs(c) { }
101 : #endif
102 : #endif
103 : // Unicode information
104 :
105 : enum Category
106 : {
107 : Mark_NonSpacing, // Mn
108 : Mark_SpacingCombining, // Mc
109 : Mark_Enclosing, // Me
110 :
111 : Number_DecimalDigit, // Nd
112 : Number_Letter, // Nl
113 : Number_Other, // No
114 :
115 : Separator_Space, // Zs
116 : Separator_Line, // Zl
117 : Separator_Paragraph, // Zp
118 :
119 : Other_Control, // Cc
120 : Other_Format, // Cf
121 : Other_Surrogate, // Cs
122 : Other_PrivateUse, // Co
123 : Other_NotAssigned, // Cn
124 :
125 : Letter_Uppercase, // Lu
126 : Letter_Lowercase, // Ll
127 : Letter_Titlecase, // Lt
128 : Letter_Modifier, // Lm
129 : Letter_Other, // Lo
130 :
131 : Punctuation_Connector, // Pc
132 : Punctuation_Dash, // Pd
133 : Punctuation_Open, // Ps
134 : Punctuation_Close, // Pe
135 : Punctuation_InitialQuote, // Pi
136 : Punctuation_FinalQuote, // Pf
137 : Punctuation_Other, // Po
138 :
139 : Symbol_Math, // Sm
140 : Symbol_Currency, // Sc
141 : Symbol_Modifier, // Sk
142 : Symbol_Other // So
143 : };
144 :
145 : enum Script
146 : {
147 : Script_Unknown,
148 : Script_Inherited,
149 : Script_Common,
150 :
151 : Script_Latin,
152 : Script_Greek,
153 : Script_Cyrillic,
154 : Script_Armenian,
155 : Script_Hebrew,
156 : Script_Arabic,
157 : Script_Syriac,
158 : Script_Thaana,
159 : Script_Devanagari,
160 : Script_Bengali,
161 : Script_Gurmukhi,
162 : Script_Gujarati,
163 : Script_Oriya,
164 : Script_Tamil,
165 : Script_Telugu,
166 : Script_Kannada,
167 : Script_Malayalam,
168 : Script_Sinhala,
169 : Script_Thai,
170 : Script_Lao,
171 : Script_Tibetan,
172 : Script_Myanmar,
173 : Script_Georgian,
174 : Script_Hangul,
175 : Script_Ethiopic,
176 : Script_Cherokee,
177 : Script_CanadianAboriginal,
178 : Script_Ogham,
179 : Script_Runic,
180 : Script_Khmer,
181 : Script_Mongolian,
182 : Script_Hiragana,
183 : Script_Katakana,
184 : Script_Bopomofo,
185 : Script_Han,
186 : Script_Yi,
187 : Script_OldItalic,
188 : Script_Gothic,
189 : Script_Deseret,
190 : Script_Tagalog,
191 : Script_Hanunoo,
192 : Script_Buhid,
193 : Script_Tagbanwa,
194 : Script_Coptic,
195 :
196 : // Unicode 4.0 additions
197 : Script_Limbu,
198 : Script_TaiLe,
199 : Script_LinearB,
200 : Script_Ugaritic,
201 : Script_Shavian,
202 : Script_Osmanya,
203 : Script_Cypriot,
204 : Script_Braille,
205 :
206 : // Unicode 4.1 additions
207 : Script_Buginese,
208 : Script_NewTaiLue,
209 : Script_Glagolitic,
210 : Script_Tifinagh,
211 : Script_SylotiNagri,
212 : Script_OldPersian,
213 : Script_Kharoshthi,
214 :
215 : // Unicode 5.0 additions
216 : Script_Balinese,
217 : Script_Cuneiform,
218 : Script_Phoenician,
219 : Script_PhagsPa,
220 : Script_Nko,
221 :
222 : // Unicode 5.1 additions
223 : Script_Sundanese,
224 : Script_Lepcha,
225 : Script_OlChiki,
226 : Script_Vai,
227 : Script_Saurashtra,
228 : Script_KayahLi,
229 : Script_Rejang,
230 : Script_Lycian,
231 : Script_Carian,
232 : Script_Lydian,
233 : Script_Cham,
234 :
235 : // Unicode 5.2 additions
236 : Script_TaiTham,
237 : Script_TaiViet,
238 : Script_Avestan,
239 : Script_EgyptianHieroglyphs,
240 : Script_Samaritan,
241 : Script_Lisu,
242 : Script_Bamum,
243 : Script_Javanese,
244 : Script_MeeteiMayek,
245 : Script_ImperialAramaic,
246 : Script_OldSouthArabian,
247 : Script_InscriptionalParthian,
248 : Script_InscriptionalPahlavi,
249 : Script_OldTurkic,
250 : Script_Kaithi,
251 :
252 : // Unicode 6.0 additions
253 : Script_Batak,
254 : Script_Brahmi,
255 : Script_Mandaic,
256 :
257 : // Unicode 6.1 additions
258 : Script_Chakma,
259 : Script_MeroiticCursive,
260 : Script_MeroiticHieroglyphs,
261 : Script_Miao,
262 : Script_Sharada,
263 : Script_SoraSompeng,
264 : Script_Takri,
265 :
266 : // Unicode 7.0 additions
267 : Script_CaucasianAlbanian,
268 : Script_BassaVah,
269 : Script_Duployan,
270 : Script_Elbasan,
271 : Script_Grantha,
272 : Script_PahawhHmong,
273 : Script_Khojki,
274 : Script_LinearA,
275 : Script_Mahajani,
276 : Script_Manichaean,
277 : Script_MendeKikakui,
278 : Script_Modi,
279 : Script_Mro,
280 : Script_OldNorthArabian,
281 : Script_Nabataean,
282 : Script_Palmyrene,
283 : Script_PauCinHau,
284 : Script_OldPermic,
285 : Script_PsalterPahlavi,
286 : Script_Siddham,
287 : Script_Khudawadi,
288 : Script_Tirhuta,
289 : Script_WarangCiti,
290 :
291 : // Unicode 8.0 additions
292 : Script_Ahom,
293 : Script_AnatolianHieroglyphs,
294 : Script_Hatran,
295 : Script_Multani,
296 : Script_OldHungarian,
297 : Script_SignWriting,
298 :
299 : ScriptCount
300 : };
301 :
302 : enum Direction
303 : {
304 : DirL, DirR, DirEN, DirES, DirET, DirAN, DirCS, DirB, DirS, DirWS, DirON,
305 : DirLRE, DirLRO, DirAL, DirRLE, DirRLO, DirPDF, DirNSM, DirBN,
306 : DirLRI, DirRLI, DirFSI, DirPDI
307 : };
308 :
309 : enum Decomposition
310 : {
311 : NoDecomposition,
312 : Canonical,
313 : Font,
314 : NoBreak,
315 : Initial,
316 : Medial,
317 : Final,
318 : Isolated,
319 : Circle,
320 : Super,
321 : Sub,
322 : Vertical,
323 : Wide,
324 : Narrow,
325 : Small,
326 : Square,
327 : Compat,
328 : Fraction
329 : };
330 :
331 : enum JoiningType {
332 : Joining_None,
333 : Joining_Causing,
334 : Joining_Dual,
335 : Joining_Right,
336 : Joining_Left,
337 : Joining_Transparent
338 : };
339 :
340 : #if QT_DEPRECATED_SINCE(5, 3)
341 : enum Joining
342 : {
343 : OtherJoining, Dual, Right, Center
344 : };
345 : #endif
346 :
347 : enum CombiningClass
348 : {
349 : Combining_BelowLeftAttached = 200,
350 : Combining_BelowAttached = 202,
351 : Combining_BelowRightAttached = 204,
352 : Combining_LeftAttached = 208,
353 : Combining_RightAttached = 210,
354 : Combining_AboveLeftAttached = 212,
355 : Combining_AboveAttached = 214,
356 : Combining_AboveRightAttached = 216,
357 :
358 : Combining_BelowLeft = 218,
359 : Combining_Below = 220,
360 : Combining_BelowRight = 222,
361 : Combining_Left = 224,
362 : Combining_Right = 226,
363 : Combining_AboveLeft = 228,
364 : Combining_Above = 230,
365 : Combining_AboveRight = 232,
366 :
367 : Combining_DoubleBelow = 233,
368 : Combining_DoubleAbove = 234,
369 : Combining_IotaSubscript = 240
370 : };
371 :
372 : enum UnicodeVersion {
373 : Unicode_Unassigned,
374 : Unicode_1_1,
375 : Unicode_2_0,
376 : Unicode_2_1_2,
377 : Unicode_3_0,
378 : Unicode_3_1,
379 : Unicode_3_2,
380 : Unicode_4_0,
381 : Unicode_4_1,
382 : Unicode_5_0,
383 : Unicode_5_1,
384 : Unicode_5_2,
385 : Unicode_6_0,
386 : Unicode_6_1,
387 : Unicode_6_2,
388 : Unicode_6_3,
389 : Unicode_7_0,
390 : Unicode_8_0
391 : };
392 : // ****** WHEN ADDING FUNCTIONS, CONSIDER ADDING TO QCharRef TOO
393 :
394 : inline Category category() const Q_DECL_NOTHROW { return QChar::category(ucs); }
395 : inline Direction direction() const Q_DECL_NOTHROW { return QChar::direction(ucs); }
396 : inline JoiningType joiningType() const Q_DECL_NOTHROW { return QChar::joiningType(ucs); }
397 : #if QT_DEPRECATED_SINCE(5, 3)
398 : QT_DEPRECATED inline Joining joining() const Q_DECL_NOTHROW
399 : {
400 : switch (QChar::joiningType(ucs)) {
401 : case QChar::Joining_Causing: return QChar::Center;
402 : case QChar::Joining_Dual: return QChar::Dual;
403 : case QChar::Joining_Right: return QChar::Right;
404 : case QChar::Joining_None:
405 : case QChar::Joining_Left:
406 : case QChar::Joining_Transparent:
407 : default: return QChar::OtherJoining;
408 : }
409 : }
410 : #endif
411 : inline unsigned char combiningClass() const Q_DECL_NOTHROW { return QChar::combiningClass(ucs); }
412 :
413 : inline QChar mirroredChar() const Q_DECL_NOTHROW { return QChar::mirroredChar(ucs); }
414 : inline bool hasMirrored() const Q_DECL_NOTHROW { return QChar::hasMirrored(ucs); }
415 :
416 : QString decomposition() const;
417 : inline Decomposition decompositionTag() const Q_DECL_NOTHROW { return QChar::decompositionTag(ucs); }
418 :
419 : inline int digitValue() const Q_DECL_NOTHROW { return QChar::digitValue(ucs); }
420 : inline QChar toLower() const Q_DECL_NOTHROW { return QChar::toLower(ucs); }
421 : inline QChar toUpper() const Q_DECL_NOTHROW { return QChar::toUpper(ucs); }
422 : inline QChar toTitleCase() const Q_DECL_NOTHROW { return QChar::toTitleCase(ucs); }
423 : inline QChar toCaseFolded() const Q_DECL_NOTHROW { return QChar::toCaseFolded(ucs); }
424 :
425 : inline Script script() const Q_DECL_NOTHROW { return QChar::script(ucs); }
426 :
427 : inline UnicodeVersion unicodeVersion() const Q_DECL_NOTHROW { return QChar::unicodeVersion(ucs); }
428 :
429 : #if QT_DEPRECATED_SINCE(5, 0)
430 : QT_DEPRECATED Q_DECL_CONSTEXPR inline char toAscii() const Q_DECL_NOTHROW { return toLatin1(); }
431 : #endif
432 : Q_DECL_CONSTEXPR inline char toLatin1() const Q_DECL_NOTHROW { return ucs > 0xff ? '\0' : char(ucs); }
433 80 : Q_DECL_CONSTEXPR inline ushort unicode() const Q_DECL_NOTHROW { return ucs; }
434 122 : Q_DECL_RELAXED_CONSTEXPR inline ushort &unicode() Q_DECL_NOTHROW { return ucs; }
435 :
436 : #if QT_DEPRECATED_SINCE(5, 0)
437 : QT_DEPRECATED static Q_DECL_CONSTEXPR inline QChar fromAscii(char c) Q_DECL_NOTHROW
438 : { return fromLatin1(c); }
439 : #endif
440 : static Q_DECL_CONSTEXPR inline QChar fromLatin1(char c) Q_DECL_NOTHROW { return QChar(ushort(uchar(c))); }
441 :
442 : Q_DECL_CONSTEXPR inline bool isNull() const Q_DECL_NOTHROW { return ucs == 0; }
443 :
444 : inline bool isPrint() const Q_DECL_NOTHROW { return QChar::isPrint(ucs); }
445 : Q_DECL_CONSTEXPR inline bool isSpace() const Q_DECL_NOTHROW { return QChar::isSpace(ucs); }
446 : inline bool isMark() const Q_DECL_NOTHROW { return QChar::isMark(ucs); }
447 : inline bool isPunct() const Q_DECL_NOTHROW { return QChar::isPunct(ucs); }
448 : inline bool isSymbol() const Q_DECL_NOTHROW { return QChar::isSymbol(ucs); }
449 : Q_DECL_CONSTEXPR inline bool isLetter() const Q_DECL_NOTHROW { return QChar::isLetter(ucs); }
450 : Q_DECL_CONSTEXPR inline bool isNumber() const Q_DECL_NOTHROW { return QChar::isNumber(ucs); }
451 : Q_DECL_CONSTEXPR inline bool isLetterOrNumber() const Q_DECL_NOTHROW { return QChar::isLetterOrNumber(ucs); }
452 : Q_DECL_CONSTEXPR inline bool isDigit() const Q_DECL_NOTHROW { return QChar::isDigit(ucs); }
453 : Q_DECL_CONSTEXPR inline bool isLower() const Q_DECL_NOTHROW { return QChar::isLower(ucs); }
454 : Q_DECL_CONSTEXPR inline bool isUpper() const Q_DECL_NOTHROW { return QChar::isUpper(ucs); }
455 : Q_DECL_CONSTEXPR inline bool isTitleCase() const Q_DECL_NOTHROW { return QChar::isTitleCase(ucs); }
456 :
457 : Q_DECL_CONSTEXPR inline bool isNonCharacter() const Q_DECL_NOTHROW { return QChar::isNonCharacter(ucs); }
458 : Q_DECL_CONSTEXPR inline bool isHighSurrogate() const Q_DECL_NOTHROW { return QChar::isHighSurrogate(ucs); }
459 : Q_DECL_CONSTEXPR inline bool isLowSurrogate() const Q_DECL_NOTHROW { return QChar::isLowSurrogate(ucs); }
460 : Q_DECL_CONSTEXPR inline bool isSurrogate() const Q_DECL_NOTHROW { return QChar::isSurrogate(ucs); }
461 :
462 : Q_DECL_CONSTEXPR inline uchar cell() const Q_DECL_NOTHROW { return uchar(ucs & 0xff); }
463 : Q_DECL_CONSTEXPR inline uchar row() const Q_DECL_NOTHROW { return uchar((ucs>>8)&0xff); }
464 : Q_DECL_RELAXED_CONSTEXPR inline void setCell(uchar acell) Q_DECL_NOTHROW { ucs = ushort((ucs & 0xff00) + acell); }
465 : Q_DECL_RELAXED_CONSTEXPR inline void setRow(uchar arow) Q_DECL_NOTHROW { ucs = ushort((ushort(arow)<<8) + (ucs&0xff)); }
466 :
467 : static Q_DECL_CONSTEXPR inline bool isNonCharacter(uint ucs4) Q_DECL_NOTHROW
468 : {
469 : return ucs4 >= 0xfdd0 && (ucs4 <= 0xfdef || (ucs4 & 0xfffe) == 0xfffe);
470 : }
471 : static Q_DECL_CONSTEXPR inline bool isHighSurrogate(uint ucs4) Q_DECL_NOTHROW
472 : {
473 : return ((ucs4 & 0xfffffc00) == 0xd800);
474 : }
475 : static Q_DECL_CONSTEXPR inline bool isLowSurrogate(uint ucs4) Q_DECL_NOTHROW
476 : {
477 : return ((ucs4 & 0xfffffc00) == 0xdc00);
478 : }
479 : static Q_DECL_CONSTEXPR inline bool isSurrogate(uint ucs4) Q_DECL_NOTHROW
480 : {
481 : return (ucs4 - 0xd800u < 2048u);
482 : }
483 : static Q_DECL_CONSTEXPR inline bool requiresSurrogates(uint ucs4) Q_DECL_NOTHROW
484 : {
485 : return (ucs4 >= 0x10000);
486 : }
487 : static Q_DECL_CONSTEXPR inline uint surrogateToUcs4(ushort high, ushort low) Q_DECL_NOTHROW
488 : {
489 : return (uint(high)<<10) + low - 0x35fdc00;
490 : }
491 : static Q_DECL_CONSTEXPR inline uint surrogateToUcs4(QChar high, QChar low) Q_DECL_NOTHROW
492 : {
493 : return surrogateToUcs4(high.ucs, low.ucs);
494 : }
495 : static Q_DECL_CONSTEXPR inline ushort highSurrogate(uint ucs4) Q_DECL_NOTHROW
496 : {
497 : return ushort((ucs4>>10) + 0xd7c0);
498 : }
499 : static Q_DECL_CONSTEXPR inline ushort lowSurrogate(uint ucs4) Q_DECL_NOTHROW
500 : {
501 : return ushort(ucs4%0x400 + 0xdc00);
502 : }
503 :
504 : static Category QT_FASTCALL category(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
505 : static Direction QT_FASTCALL direction(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
506 : static JoiningType QT_FASTCALL joiningType(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
507 : #if QT_DEPRECATED_SINCE(5, 3)
508 : QT_DEPRECATED static Joining QT_FASTCALL joining(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
509 : #endif
510 : static unsigned char QT_FASTCALL combiningClass(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
511 :
512 : static uint QT_FASTCALL mirroredChar(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
513 : static bool QT_FASTCALL hasMirrored(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
514 :
515 : static QString QT_FASTCALL decomposition(uint ucs4);
516 : static Decomposition QT_FASTCALL decompositionTag(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
517 :
518 : static int QT_FASTCALL digitValue(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
519 : static uint QT_FASTCALL toLower(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
520 : static uint QT_FASTCALL toUpper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
521 : static uint QT_FASTCALL toTitleCase(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
522 : static uint QT_FASTCALL toCaseFolded(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
523 :
524 : static Script QT_FASTCALL script(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
525 :
526 : static UnicodeVersion QT_FASTCALL unicodeVersion(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
527 :
528 : static UnicodeVersion QT_FASTCALL currentUnicodeVersion() Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
529 :
530 : static bool QT_FASTCALL isPrint(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
531 : static Q_DECL_CONSTEXPR inline bool isSpace(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION
532 : {
533 : // note that [0x09..0x0d] + 0x85 are exceptional Cc-s and must be handled explicitly
534 : return ucs4 == 0x20 || (ucs4 <= 0x0d && ucs4 >= 0x09)
535 : || (ucs4 > 127 && (ucs4 == 0x85 || ucs4 == 0xa0 || QChar::isSpace_helper(ucs4)));
536 : }
537 : static bool QT_FASTCALL isMark(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
538 : static bool QT_FASTCALL isPunct(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
539 : static bool QT_FASTCALL isSymbol(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
540 : static Q_DECL_CONSTEXPR inline bool isLetter(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION
541 : {
542 : return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z'))
543 : || (ucs4 > 127 && QChar::isLetter_helper(ucs4));
544 : }
545 : static Q_DECL_CONSTEXPR inline bool isNumber(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION
546 : { return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar::isNumber_helper(ucs4)); }
547 : static Q_DECL_CONSTEXPR inline bool isLetterOrNumber(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION
548 : {
549 : return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z'))
550 : || (ucs4 >= '0' && ucs4 <= '9')
551 : || (ucs4 > 127 && QChar::isLetterOrNumber_helper(ucs4));
552 : }
553 : static Q_DECL_CONSTEXPR inline bool isDigit(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION
554 : { return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar::category(ucs4) == Number_DecimalDigit); }
555 : static Q_DECL_CONSTEXPR inline bool isLower(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION
556 : { return (ucs4 <= 'z' && ucs4 >= 'a') || (ucs4 > 127 && QChar::category(ucs4) == Letter_Lowercase); }
557 : static Q_DECL_CONSTEXPR inline bool isUpper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION
558 : { return (ucs4 <= 'Z' && ucs4 >= 'A') || (ucs4 > 127 && QChar::category(ucs4) == Letter_Uppercase); }
559 : static Q_DECL_CONSTEXPR inline bool isTitleCase(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION
560 : { return ucs4 > 127 && QChar::category(ucs4) == Letter_Titlecase; }
561 :
562 : private:
563 : static bool QT_FASTCALL isSpace_helper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
564 : static bool QT_FASTCALL isLetter_helper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
565 : static bool QT_FASTCALL isNumber_helper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
566 : static bool QT_FASTCALL isLetterOrNumber_helper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
567 :
568 : #ifdef QT_NO_CAST_FROM_ASCII
569 : QChar(char c) Q_DECL_NOTHROW;
570 : QChar(uchar c) Q_DECL_NOTHROW;
571 : #endif
572 :
573 : friend Q_DECL_CONSTEXPR bool operator==(QChar, QChar) Q_DECL_NOTHROW;
574 : friend Q_DECL_CONSTEXPR bool operator< (QChar, QChar) Q_DECL_NOTHROW;
575 : ushort ucs;
576 : };
577 :
578 : Q_DECLARE_TYPEINFO(QChar, Q_MOVABLE_TYPE);
579 :
580 : Q_DECL_CONSTEXPR inline bool operator==(QChar c1, QChar c2) Q_DECL_NOTHROW { return c1.ucs == c2.ucs; }
581 : Q_DECL_CONSTEXPR inline bool operator< (QChar c1, QChar c2) Q_DECL_NOTHROW { return c1.ucs < c2.ucs; }
582 :
583 : Q_DECL_CONSTEXPR inline bool operator!=(QChar c1, QChar c2) Q_DECL_NOTHROW { return !operator==(c1, c2); }
584 : Q_DECL_CONSTEXPR inline bool operator>=(QChar c1, QChar c2) Q_DECL_NOTHROW { return !operator< (c1, c2); }
585 : Q_DECL_CONSTEXPR inline bool operator> (QChar c1, QChar c2) Q_DECL_NOTHROW { return operator< (c2, c1); }
586 : Q_DECL_CONSTEXPR inline bool operator<=(QChar c1, QChar c2) Q_DECL_NOTHROW { return !operator< (c2, c1); }
587 :
588 :
589 : Q_DECL_CONSTEXPR inline bool operator==(QChar lhs, std::nullptr_t) Q_DECL_NOTHROW { return lhs.isNull(); }
590 : Q_DECL_CONSTEXPR inline bool operator< (QChar, std::nullptr_t) Q_DECL_NOTHROW { return false; }
591 : Q_DECL_CONSTEXPR inline bool operator==(std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return rhs.isNull(); }
592 : Q_DECL_CONSTEXPR inline bool operator< (std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return !rhs.isNull(); }
593 :
594 : Q_DECL_CONSTEXPR inline bool operator!=(QChar lhs, std::nullptr_t) Q_DECL_NOTHROW { return !operator==(lhs, nullptr); }
595 : Q_DECL_CONSTEXPR inline bool operator>=(QChar lhs, std::nullptr_t) Q_DECL_NOTHROW { return !operator< (lhs, nullptr); }
596 : Q_DECL_CONSTEXPR inline bool operator> (QChar lhs, std::nullptr_t) Q_DECL_NOTHROW { return operator< (nullptr, lhs); }
597 : Q_DECL_CONSTEXPR inline bool operator<=(QChar lhs, std::nullptr_t) Q_DECL_NOTHROW { return !operator< (nullptr, lhs); }
598 :
599 : Q_DECL_CONSTEXPR inline bool operator!=(std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return !operator==(nullptr, rhs); }
600 : Q_DECL_CONSTEXPR inline bool operator>=(std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return !operator< (nullptr, rhs); }
601 : Q_DECL_CONSTEXPR inline bool operator> (std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return operator< (rhs, nullptr); }
602 : Q_DECL_CONSTEXPR inline bool operator<=(std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return !operator< (rhs, nullptr); }
603 :
604 : #ifndef QT_NO_DATASTREAM
605 : Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, QChar);
606 : Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QChar &);
607 : #endif
608 :
609 : QT_END_NAMESPACE
610 :
611 : #endif // QCHAR_H
|