Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:07:19

0001 // Copyright (C) 2020 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QCHAR_H
0005 #define QCHAR_H
0006 
0007 #include <QtCore/qglobal.h>
0008 
0009 #include <functional> // for std::hash
0010 
0011 QT_BEGIN_NAMESPACE
0012 
0013 
0014 class QString;
0015 
0016 struct QLatin1Char
0017 {
0018 public:
0019     constexpr inline explicit QLatin1Char(char c) noexcept : ch(c) {}
0020     constexpr inline char toLatin1() const noexcept { return ch; }
0021     constexpr inline char16_t unicode() const noexcept { return char16_t(uchar(ch)); }
0022 
0023     friend constexpr inline bool operator==(QLatin1Char lhs, QLatin1Char rhs) noexcept { return lhs.ch == rhs.ch; }
0024     friend constexpr inline bool operator!=(QLatin1Char lhs, QLatin1Char rhs) noexcept { return lhs.ch != rhs.ch; }
0025     friend constexpr inline bool operator<=(QLatin1Char lhs, QLatin1Char rhs) noexcept { return lhs.ch <= rhs.ch; }
0026     friend constexpr inline bool operator>=(QLatin1Char lhs, QLatin1Char rhs) noexcept { return lhs.ch >= rhs.ch; }
0027     friend constexpr inline bool operator< (QLatin1Char lhs, QLatin1Char rhs) noexcept { return lhs.ch <  rhs.ch; }
0028     friend constexpr inline bool operator> (QLatin1Char lhs, QLatin1Char rhs) noexcept { return lhs.ch >  rhs.ch; }
0029 
0030     friend constexpr inline bool operator==(char lhs, QLatin1Char rhs) noexcept { return lhs == rhs.toLatin1(); }
0031     friend constexpr inline bool operator!=(char lhs, QLatin1Char rhs) noexcept { return lhs != rhs.toLatin1(); }
0032     friend constexpr inline bool operator<=(char lhs, QLatin1Char rhs) noexcept { return lhs <= rhs.toLatin1(); }
0033     friend constexpr inline bool operator>=(char lhs, QLatin1Char rhs) noexcept { return lhs >= rhs.toLatin1(); }
0034     friend constexpr inline bool operator< (char lhs, QLatin1Char rhs) noexcept { return lhs <  rhs.toLatin1(); }
0035     friend constexpr inline bool operator> (char lhs, QLatin1Char rhs) noexcept { return lhs >  rhs.toLatin1(); }
0036 
0037     friend constexpr inline bool operator==(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() == rhs; }
0038     friend constexpr inline bool operator!=(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() != rhs; }
0039     friend constexpr inline bool operator<=(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() <= rhs; }
0040     friend constexpr inline bool operator>=(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() >= rhs; }
0041     friend constexpr inline bool operator< (QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() <  rhs; }
0042     friend constexpr inline bool operator> (QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() >  rhs; }
0043 
0044 private:
0045     char ch;
0046 };
0047 
0048 class Q_CORE_EXPORT QChar {
0049 public:
0050     enum SpecialCharacter {
0051         Null = 0x0000,
0052         Tabulation = 0x0009,
0053         LineFeed = 0x000a,
0054         FormFeed = 0x000c,
0055         CarriageReturn = 0x000d,
0056         Space = 0x0020,
0057         Nbsp = 0x00a0,
0058         SoftHyphen = 0x00ad,
0059         ReplacementCharacter = 0xfffd,
0060         ObjectReplacementCharacter = 0xfffc,
0061         ByteOrderMark = 0xfeff,
0062         ByteOrderSwapped = 0xfffe,
0063         ParagraphSeparator = 0x2029,
0064         LineSeparator = 0x2028,
0065         VisualTabCharacter = 0x2192,
0066         LastValidCodePoint = 0x10ffff
0067     };
0068 
0069 #ifdef QT_IMPLICIT_QCHAR_CONSTRUCTION
0070 #define QCHAR_MAYBE_IMPLICIT Q_IMPLICIT
0071 #else
0072 #define QCHAR_MAYBE_IMPLICIT explicit
0073 #endif
0074 
0075     constexpr Q_IMPLICIT QChar() noexcept : ucs(0) {}
0076     constexpr Q_IMPLICIT QChar(ushort rc) noexcept : ucs(rc) {}
0077     constexpr QCHAR_MAYBE_IMPLICIT QChar(uchar c, uchar r) noexcept : ucs(char16_t((r << 8) | c)) {}
0078     constexpr Q_IMPLICIT QChar(short rc) noexcept : ucs(char16_t(rc)) {}
0079     constexpr QCHAR_MAYBE_IMPLICIT QChar(uint rc) noexcept : ucs((Q_ASSERT(rc <= 0xffff), char16_t(rc))) {}
0080     constexpr QCHAR_MAYBE_IMPLICIT QChar(int rc) noexcept : QChar(uint(rc)) {}
0081     constexpr Q_IMPLICIT QChar(SpecialCharacter s) noexcept : ucs(char16_t(s)) {}
0082     constexpr Q_IMPLICIT QChar(QLatin1Char ch) noexcept : ucs(ch.unicode()) {}
0083     constexpr Q_IMPLICIT QChar(char16_t ch) noexcept : ucs(ch) {}
0084 #if defined(Q_OS_WIN) || defined(Q_QDOC)
0085     constexpr Q_IMPLICIT QChar(wchar_t ch) noexcept : ucs(char16_t(ch)) {}
0086 #endif
0087 
0088 #ifndef QT_NO_CAST_FROM_ASCII
0089     // Always implicit -- allow for 'x' => QChar conversions
0090     QT_ASCII_CAST_WARN constexpr Q_IMPLICIT QChar(char c) noexcept : ucs(uchar(c)) { }
0091 #ifndef QT_RESTRICTED_CAST_FROM_ASCII
0092     QT_ASCII_CAST_WARN constexpr QCHAR_MAYBE_IMPLICIT QChar(uchar c) noexcept : ucs(c) { }
0093 #endif
0094 #endif
0095 
0096 #undef QCHAR_MAYBE_IMPLICIT
0097 
0098     static constexpr QChar fromUcs2(char16_t c) noexcept { return QChar{c}; }
0099     static constexpr inline auto fromUcs4(char32_t c) noexcept;
0100 
0101     // Unicode information
0102 
0103     enum Category
0104     {
0105         Mark_NonSpacing,          //   Mn
0106         Mark_SpacingCombining,    //   Mc
0107         Mark_Enclosing,           //   Me
0108 
0109         Number_DecimalDigit,      //   Nd
0110         Number_Letter,            //   Nl
0111         Number_Other,             //   No
0112 
0113         Separator_Space,          //   Zs
0114         Separator_Line,           //   Zl
0115         Separator_Paragraph,      //   Zp
0116 
0117         Other_Control,            //   Cc
0118         Other_Format,             //   Cf
0119         Other_Surrogate,          //   Cs
0120         Other_PrivateUse,         //   Co
0121         Other_NotAssigned,        //   Cn
0122 
0123         Letter_Uppercase,         //   Lu
0124         Letter_Lowercase,         //   Ll
0125         Letter_Titlecase,         //   Lt
0126         Letter_Modifier,          //   Lm
0127         Letter_Other,             //   Lo
0128 
0129         Punctuation_Connector,    //   Pc
0130         Punctuation_Dash,         //   Pd
0131         Punctuation_Open,         //   Ps
0132         Punctuation_Close,        //   Pe
0133         Punctuation_InitialQuote, //   Pi
0134         Punctuation_FinalQuote,   //   Pf
0135         Punctuation_Other,        //   Po
0136 
0137         Symbol_Math,              //   Sm
0138         Symbol_Currency,          //   Sc
0139         Symbol_Modifier,          //   Sk
0140         Symbol_Other              //   So
0141     };
0142 
0143     enum Script
0144     {
0145         Script_Unknown,
0146         Script_Inherited,
0147         Script_Common,
0148 
0149         Script_Latin,
0150         Script_Greek,
0151         Script_Cyrillic,
0152         Script_Armenian,
0153         Script_Hebrew,
0154         Script_Arabic,
0155         Script_Syriac,
0156         Script_Thaana,
0157         Script_Devanagari,
0158         Script_Bengali,
0159         Script_Gurmukhi,
0160         Script_Gujarati,
0161         Script_Oriya,
0162         Script_Tamil,
0163         Script_Telugu,
0164         Script_Kannada,
0165         Script_Malayalam,
0166         Script_Sinhala,
0167         Script_Thai,
0168         Script_Lao,
0169         Script_Tibetan,
0170         Script_Myanmar,
0171         Script_Georgian,
0172         Script_Hangul,
0173         Script_Ethiopic,
0174         Script_Cherokee,
0175         Script_CanadianAboriginal,
0176         Script_Ogham,
0177         Script_Runic,
0178         Script_Khmer,
0179         Script_Mongolian,
0180         Script_Hiragana,
0181         Script_Katakana,
0182         Script_Bopomofo,
0183         Script_Han,
0184         Script_Yi,
0185         Script_OldItalic,
0186         Script_Gothic,
0187         Script_Deseret,
0188         Script_Tagalog,
0189         Script_Hanunoo,
0190         Script_Buhid,
0191         Script_Tagbanwa,
0192         Script_Coptic,
0193 
0194         // Unicode 4.0 additions
0195         Script_Limbu,
0196         Script_TaiLe,
0197         Script_LinearB,
0198         Script_Ugaritic,
0199         Script_Shavian,
0200         Script_Osmanya,
0201         Script_Cypriot,
0202         Script_Braille,
0203 
0204         // Unicode 4.1 additions
0205         Script_Buginese,
0206         Script_NewTaiLue,
0207         Script_Glagolitic,
0208         Script_Tifinagh,
0209         Script_SylotiNagri,
0210         Script_OldPersian,
0211         Script_Kharoshthi,
0212 
0213         // Unicode 5.0 additions
0214         Script_Balinese,
0215         Script_Cuneiform,
0216         Script_Phoenician,
0217         Script_PhagsPa,
0218         Script_Nko,
0219 
0220         // Unicode 5.1 additions
0221         Script_Sundanese,
0222         Script_Lepcha,
0223         Script_OlChiki,
0224         Script_Vai,
0225         Script_Saurashtra,
0226         Script_KayahLi,
0227         Script_Rejang,
0228         Script_Lycian,
0229         Script_Carian,
0230         Script_Lydian,
0231         Script_Cham,
0232 
0233         // Unicode 5.2 additions
0234         Script_TaiTham,
0235         Script_TaiViet,
0236         Script_Avestan,
0237         Script_EgyptianHieroglyphs,
0238         Script_Samaritan,
0239         Script_Lisu,
0240         Script_Bamum,
0241         Script_Javanese,
0242         Script_MeeteiMayek,
0243         Script_ImperialAramaic,
0244         Script_OldSouthArabian,
0245         Script_InscriptionalParthian,
0246         Script_InscriptionalPahlavi,
0247         Script_OldTurkic,
0248         Script_Kaithi,
0249 
0250         // Unicode 6.0 additions
0251         Script_Batak,
0252         Script_Brahmi,
0253         Script_Mandaic,
0254 
0255         // Unicode 6.1 additions
0256         Script_Chakma,
0257         Script_MeroiticCursive,
0258         Script_MeroiticHieroglyphs,
0259         Script_Miao,
0260         Script_Sharada,
0261         Script_SoraSompeng,
0262         Script_Takri,
0263 
0264         // Unicode 7.0 additions
0265         Script_CaucasianAlbanian,
0266         Script_BassaVah,
0267         Script_Duployan,
0268         Script_Elbasan,
0269         Script_Grantha,
0270         Script_PahawhHmong,
0271         Script_Khojki,
0272         Script_LinearA,
0273         Script_Mahajani,
0274         Script_Manichaean,
0275         Script_MendeKikakui,
0276         Script_Modi,
0277         Script_Mro,
0278         Script_OldNorthArabian,
0279         Script_Nabataean,
0280         Script_Palmyrene,
0281         Script_PauCinHau,
0282         Script_OldPermic,
0283         Script_PsalterPahlavi,
0284         Script_Siddham,
0285         Script_Khudawadi,
0286         Script_Tirhuta,
0287         Script_WarangCiti,
0288 
0289         // Unicode 8.0 additions
0290         Script_Ahom,
0291         Script_AnatolianHieroglyphs,
0292         Script_Hatran,
0293         Script_Multani,
0294         Script_OldHungarian,
0295         Script_SignWriting,
0296 
0297         // Unicode 9.0 additions
0298         Script_Adlam,
0299         Script_Bhaiksuki,
0300         Script_Marchen,
0301         Script_Newa,
0302         Script_Osage,
0303         Script_Tangut,
0304 
0305         // Unicode 10.0 additions
0306         Script_MasaramGondi,
0307         Script_Nushu,
0308         Script_Soyombo,
0309         Script_ZanabazarSquare,
0310 
0311         // Unicode 12.1 additions
0312         Script_Dogra,
0313         Script_GunjalaGondi,
0314         Script_HanifiRohingya,
0315         Script_Makasar,
0316         Script_Medefaidrin,
0317         Script_OldSogdian,
0318         Script_Sogdian,
0319         Script_Elymaic,
0320         Script_Nandinagari,
0321         Script_NyiakengPuachueHmong,
0322         Script_Wancho,
0323 
0324         // Unicode 13.0 additions
0325         Script_Chorasmian,
0326         Script_DivesAkuru,
0327         Script_KhitanSmallScript,
0328         Script_Yezidi,
0329 
0330         // Unicode 14.0 additions
0331         Script_CyproMinoan,
0332         Script_OldUyghur,
0333         Script_Tangsa,
0334         Script_Toto,
0335         Script_Vithkuqi,
0336 
0337         // Unicode 15.0 additions
0338         Script_Kawi,
0339         Script_NagMundari,
0340 
0341         ScriptCount
0342     };
0343 
0344     enum Direction
0345     {
0346         DirL, DirR, DirEN, DirES, DirET, DirAN, DirCS, DirB, DirS, DirWS, DirON,
0347         DirLRE, DirLRO, DirAL, DirRLE, DirRLO, DirPDF, DirNSM, DirBN,
0348         DirLRI, DirRLI, DirFSI, DirPDI
0349     };
0350 
0351     enum Decomposition
0352     {
0353         NoDecomposition,
0354         Canonical,
0355         Font,
0356         NoBreak,
0357         Initial,
0358         Medial,
0359         Final,
0360         Isolated,
0361         Circle,
0362         Super,
0363         Sub,
0364         Vertical,
0365         Wide,
0366         Narrow,
0367         Small,
0368         Square,
0369         Compat,
0370         Fraction
0371     };
0372 
0373     enum JoiningType {
0374         Joining_None,
0375         Joining_Causing,
0376         Joining_Dual,
0377         Joining_Right,
0378         Joining_Left,
0379         Joining_Transparent
0380     };
0381 
0382     enum CombiningClass
0383     {
0384         Combining_BelowLeftAttached       = 200,
0385         Combining_BelowAttached           = 202,
0386         Combining_BelowRightAttached      = 204,
0387         Combining_LeftAttached            = 208,
0388         Combining_RightAttached           = 210,
0389         Combining_AboveLeftAttached       = 212,
0390         Combining_AboveAttached           = 214,
0391         Combining_AboveRightAttached      = 216,
0392 
0393         Combining_BelowLeft               = 218,
0394         Combining_Below                   = 220,
0395         Combining_BelowRight              = 222,
0396         Combining_Left                    = 224,
0397         Combining_Right                   = 226,
0398         Combining_AboveLeft               = 228,
0399         Combining_Above                   = 230,
0400         Combining_AboveRight              = 232,
0401 
0402         Combining_DoubleBelow             = 233,
0403         Combining_DoubleAbove             = 234,
0404         Combining_IotaSubscript           = 240
0405     };
0406 
0407     enum UnicodeVersion {
0408         Unicode_Unassigned,
0409         Unicode_1_1,
0410         Unicode_2_0,
0411         Unicode_2_1_2,
0412         Unicode_3_0,
0413         Unicode_3_1,
0414         Unicode_3_2,
0415         Unicode_4_0,
0416         Unicode_4_1,
0417         Unicode_5_0,
0418         Unicode_5_1,
0419         Unicode_5_2,
0420         Unicode_6_0,
0421         Unicode_6_1,
0422         Unicode_6_2,
0423         Unicode_6_3,
0424         Unicode_7_0,
0425         Unicode_8_0,
0426         Unicode_9_0,
0427         Unicode_10_0,
0428         Unicode_11_0,
0429         Unicode_12_0,
0430         Unicode_12_1,
0431         Unicode_13_0,
0432         Unicode_14_0,
0433         Unicode_15_0,
0434     };
0435 
0436     inline Category category() const noexcept { return QChar::category(ucs); }
0437     inline Direction direction() const noexcept { return QChar::direction(ucs); }
0438     inline JoiningType joiningType() const noexcept { return QChar::joiningType(ucs); }
0439     inline unsigned char combiningClass() const noexcept { return QChar::combiningClass(ucs); }
0440 
0441     inline QChar mirroredChar() const noexcept { return QChar(QChar::mirroredChar(ucs)); }
0442     inline bool hasMirrored() const noexcept { return QChar::hasMirrored(ucs); }
0443 
0444     QString decomposition() const;
0445     inline Decomposition decompositionTag() const noexcept { return QChar::decompositionTag(ucs); }
0446 
0447     inline int digitValue() const noexcept { return QChar::digitValue(ucs); }
0448     inline QChar toLower() const noexcept { return QChar(QChar::toLower(ucs)); }
0449     inline QChar toUpper() const noexcept { return QChar(QChar::toUpper(ucs)); }
0450     inline QChar toTitleCase() const noexcept { return QChar(QChar::toTitleCase(ucs)); }
0451     inline QChar toCaseFolded() const noexcept { return QChar(QChar::toCaseFolded(ucs)); }
0452 
0453     inline Script script() const noexcept { return QChar::script(ucs); }
0454 
0455     inline UnicodeVersion unicodeVersion() const noexcept { return QChar::unicodeVersion(ucs); }
0456 
0457     constexpr inline char toLatin1() const noexcept { return ucs > 0xff ? '\0' : char(ucs); }
0458     constexpr inline char16_t unicode() const noexcept { return ucs; }
0459     constexpr inline char16_t &unicode() noexcept { return ucs; }
0460 
0461     static constexpr QChar fromLatin1(char c) noexcept { return QLatin1Char(c); }
0462 
0463     constexpr inline bool isNull() const noexcept { return ucs == 0; }
0464 
0465     inline bool isPrint() const noexcept { return QChar::isPrint(ucs); }
0466     constexpr inline bool isSpace() const noexcept { return QChar::isSpace(ucs); }
0467     inline bool isMark() const noexcept { return QChar::isMark(ucs); }
0468     inline bool isPunct() const noexcept { return QChar::isPunct(ucs); }
0469     inline bool isSymbol() const noexcept { return QChar::isSymbol(ucs); }
0470     constexpr inline bool isLetter() const noexcept { return QChar::isLetter(ucs); }
0471     constexpr inline bool isNumber() const noexcept { return QChar::isNumber(ucs); }
0472     constexpr inline bool isLetterOrNumber() const noexcept { return QChar::isLetterOrNumber(ucs); }
0473     constexpr inline bool isDigit() const noexcept { return QChar::isDigit(ucs); }
0474     constexpr inline bool isLower() const noexcept { return QChar::isLower(ucs); }
0475     constexpr inline bool isUpper() const noexcept { return QChar::isUpper(ucs); }
0476     constexpr inline bool isTitleCase() const noexcept { return QChar::isTitleCase(ucs); }
0477 
0478     constexpr inline bool isNonCharacter() const noexcept { return QChar::isNonCharacter(ucs); }
0479     constexpr inline bool isHighSurrogate() const noexcept { return QChar::isHighSurrogate(ucs); }
0480     constexpr inline bool isLowSurrogate() const noexcept { return QChar::isLowSurrogate(ucs); }
0481     constexpr inline bool isSurrogate() const noexcept { return QChar::isSurrogate(ucs); }
0482 
0483     constexpr inline uchar cell() const noexcept { return uchar(ucs & 0xff); }
0484     constexpr inline uchar row() const noexcept { return uchar((ucs>>8)&0xff); }
0485     constexpr inline void setCell(uchar acell) noexcept { ucs = char16_t((ucs & 0xff00) + acell); }
0486     constexpr inline void setRow(uchar arow) noexcept { ucs = char16_t((char16_t(arow)<<8) + (ucs&0xff)); }
0487 
0488     static constexpr inline bool isNonCharacter(char32_t ucs4) noexcept
0489     {
0490         return ucs4 >= 0xfdd0 && (ucs4 <= 0xfdef || (ucs4 & 0xfffe) == 0xfffe);
0491     }
0492     static constexpr inline bool isHighSurrogate(char32_t ucs4) noexcept
0493     {
0494         return (ucs4 & 0xfffffc00) == 0xd800; // 0xd800 + up to 1023 (0x3ff)
0495     }
0496     static constexpr inline bool isLowSurrogate(char32_t ucs4) noexcept
0497     {
0498         return (ucs4 & 0xfffffc00) == 0xdc00; // 0xdc00 + up to 1023 (0x3ff)
0499     }
0500     static constexpr inline bool isSurrogate(char32_t ucs4) noexcept
0501     {
0502         return (ucs4 - 0xd800u < 2048u);
0503     }
0504     static constexpr inline bool requiresSurrogates(char32_t ucs4) noexcept
0505     {
0506         return (ucs4 >= 0x10000);
0507     }
0508     static constexpr inline char32_t surrogateToUcs4(char16_t high, char16_t low) noexcept
0509     {
0510         // 0x010000 through 0x10ffff, provided params are actual high, low surrogates.
0511         // 0x010000 + ((high - 0xd800) << 10) + (low - 0xdc00), optimized:
0512         return (char32_t(high)<<10) + low - 0x35fdc00;
0513     }
0514     static constexpr inline char32_t surrogateToUcs4(QChar high, QChar low) noexcept
0515     {
0516         return surrogateToUcs4(high.ucs, low.ucs);
0517     }
0518     static constexpr inline char16_t highSurrogate(char32_t ucs4) noexcept
0519     {
0520         return char16_t((ucs4>>10) + 0xd7c0);
0521     }
0522     static constexpr inline char16_t lowSurrogate(char32_t ucs4) noexcept
0523     {
0524         return char16_t(ucs4%0x400 + 0xdc00);
0525     }
0526 
0527     static Category QT_FASTCALL category(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0528     static Direction QT_FASTCALL direction(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0529     static JoiningType QT_FASTCALL joiningType(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0530     static unsigned char QT_FASTCALL combiningClass(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0531 
0532     static char32_t QT_FASTCALL mirroredChar(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0533     static bool QT_FASTCALL hasMirrored(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0534 
0535     static QString QT_FASTCALL decomposition(char32_t ucs4);
0536     static Decomposition QT_FASTCALL decompositionTag(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0537 
0538     static int QT_FASTCALL digitValue(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0539     static char32_t QT_FASTCALL toLower(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0540     static char32_t QT_FASTCALL toUpper(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0541     static char32_t QT_FASTCALL toTitleCase(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0542     static char32_t QT_FASTCALL toCaseFolded(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0543 
0544     static Script QT_FASTCALL script(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0545 
0546     static UnicodeVersion QT_FASTCALL unicodeVersion(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0547 
0548     static UnicodeVersion QT_FASTCALL currentUnicodeVersion() noexcept Q_DECL_CONST_FUNCTION;
0549 
0550     static bool QT_FASTCALL isPrint(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0551     static constexpr inline bool isSpace(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION
0552     {
0553         // note that [0x09..0x0d] + 0x85 are exceptional Cc-s and must be handled explicitly
0554         return ucs4 == 0x20 || (ucs4 <= 0x0d && ucs4 >= 0x09)
0555                 || (ucs4 > 127 && (ucs4 == 0x85 || ucs4 == 0xa0 || QChar::isSpace_helper(ucs4)));
0556     }
0557     static bool QT_FASTCALL isMark(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0558     static bool QT_FASTCALL isPunct(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0559     static bool QT_FASTCALL isSymbol(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0560     static constexpr inline bool isLetter(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION
0561     {
0562         return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z'))
0563                 || (ucs4 > 127 && QChar::isLetter_helper(ucs4));
0564     }
0565     static constexpr inline bool isNumber(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION
0566     { return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar::isNumber_helper(ucs4)); }
0567     static constexpr inline bool isLetterOrNumber(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION
0568     {
0569         return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z'))
0570                 || (ucs4 >= '0' && ucs4 <= '9')
0571                 || (ucs4 > 127 && QChar::isLetterOrNumber_helper(ucs4));
0572     }
0573     static constexpr inline bool isDigit(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION
0574     { return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar::category(ucs4) == Number_DecimalDigit); }
0575     static constexpr inline bool isLower(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION
0576     { return (ucs4 <= 'z' && ucs4 >= 'a') || (ucs4 > 127 && QChar::category(ucs4) == Letter_Lowercase); }
0577     static constexpr inline bool isUpper(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION
0578     { return (ucs4 <= 'Z' && ucs4 >= 'A') || (ucs4 > 127 && QChar::category(ucs4) == Letter_Uppercase); }
0579     static constexpr inline bool isTitleCase(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION
0580     { return ucs4 > 127 && QChar::category(ucs4) == Letter_Titlecase; }
0581 
0582     friend constexpr inline bool operator==(QChar c1, QChar c2) noexcept { return c1.ucs == c2.ucs; }
0583     friend constexpr inline bool operator< (QChar c1, QChar c2) noexcept { return c1.ucs <  c2.ucs; }
0584 
0585     friend constexpr inline bool operator!=(QChar c1, QChar c2) noexcept { return !operator==(c1, c2); }
0586     friend constexpr inline bool operator>=(QChar c1, QChar c2) noexcept { return !operator< (c1, c2); }
0587     friend constexpr inline bool operator> (QChar c1, QChar c2) noexcept { return  operator< (c2, c1); }
0588     friend constexpr inline bool operator<=(QChar c1, QChar c2) noexcept { return !operator< (c2, c1); }
0589 
0590     friend constexpr inline bool operator==(QChar lhs, std::nullptr_t) noexcept { return lhs.isNull(); }
0591     friend constexpr inline bool operator< (QChar,     std::nullptr_t) noexcept { return false; }
0592     friend constexpr inline bool operator==(std::nullptr_t, QChar rhs) noexcept { return rhs.isNull(); }
0593     friend constexpr inline bool operator< (std::nullptr_t, QChar rhs) noexcept { return !rhs.isNull(); }
0594 
0595     friend constexpr inline bool operator!=(QChar lhs, std::nullptr_t) noexcept { return !operator==(lhs, nullptr); }
0596     friend constexpr inline bool operator>=(QChar lhs, std::nullptr_t) noexcept { return !operator< (lhs, nullptr); }
0597     friend constexpr inline bool operator> (QChar lhs, std::nullptr_t) noexcept { return  operator< (nullptr, lhs); }
0598     friend constexpr inline bool operator<=(QChar lhs, std::nullptr_t) noexcept { return !operator< (nullptr, lhs); }
0599 
0600     friend constexpr inline bool operator!=(std::nullptr_t, QChar rhs) noexcept { return !operator==(nullptr, rhs); }
0601     friend constexpr inline bool operator>=(std::nullptr_t, QChar rhs) noexcept { return !operator< (nullptr, rhs); }
0602     friend constexpr inline bool operator> (std::nullptr_t, QChar rhs) noexcept { return  operator< (rhs, nullptr); }
0603     friend constexpr inline bool operator<=(std::nullptr_t, QChar rhs) noexcept { return !operator< (rhs, nullptr); }
0604 
0605 private:
0606     static bool QT_FASTCALL isSpace_helper(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0607     static bool QT_FASTCALL isLetter_helper(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0608     static bool QT_FASTCALL isNumber_helper(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0609     static bool QT_FASTCALL isLetterOrNumber_helper(char32_t ucs4) noexcept Q_DECL_CONST_FUNCTION;
0610 
0611 #ifdef QT_NO_CAST_FROM_ASCII
0612     QChar(char c) = delete;
0613     QChar(uchar c) = delete;
0614 #endif
0615 
0616     char16_t ucs;
0617 };
0618 
0619 Q_DECLARE_TYPEINFO(QChar, Q_PRIMITIVE_TYPE);
0620 
0621 #ifndef QT_NO_DATASTREAM
0622 Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, QChar);
0623 Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QChar &);
0624 #endif
0625 
0626 namespace Qt {
0627 inline namespace Literals {
0628 inline namespace StringLiterals {
0629 
0630 constexpr inline QLatin1Char operator""_L1(char ch) noexcept
0631 {
0632     return QLatin1Char(ch);
0633 }
0634 
0635 } // StringLiterals
0636 } // Literals
0637 } // Qt
0638 
0639 QT_END_NAMESPACE
0640 
0641 namespace std {
0642 template <>
0643 struct hash<QT_PREPEND_NAMESPACE(QChar)>
0644 {
0645     template <typename = void> // for transparent constexpr tracking
0646     constexpr size_t operator()(QT_PREPEND_NAMESPACE(QChar) c) const
0647         noexcept(noexcept(std::hash<char16_t>{}(u' ')))
0648     {
0649         return std::hash<char16_t>{}(c.unicode());
0650     }
0651 };
0652 } // namespace std
0653 
0654 #endif // QCHAR_H
0655 
0656 #include <QtCore/qstringview.h> // for QChar::fromUcs4() definition