1 /* 2 * DQt - D bindings for the Qt Toolkit 3 * 4 * GNU Lesser General Public License Usage 5 * This file may be used under the terms of the GNU Lesser 6 * General Public License version 3 as published by the Free Software 7 * Foundation and appearing in the file LICENSE.LGPL3 included in the 8 * packaging of this file. Please review the following information to 9 * ensure the GNU Lesser General Public License version 3 requirements 10 * will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 11 */ 12 module qt.core.qchar; 13 extern(C++): 14 15 import core.stdc.stddef; 16 import qt.config; 17 import qt.core.global; 18 import qt.core.string; 19 import qt.core.typeinfo; 20 import qt.helpers; 21 22 /+ #ifndef QCHAR_H +/ 23 /+ #define QCHAR_H +/ 24 25 26 27 28 struct QLatin1Char 29 { 30 public: 31 /+ explicit +/pragma(inline, true) this(char c)/+ noexcept+/ 32 { 33 this.ch = c; 34 } 35 pragma(inline, true) char toLatin1() const/+ noexcept+/ { return ch; } 36 pragma(inline, true) wchar unicode() const/+ noexcept+/ { return wchar(uchar(ch)); } 37 38 /+ friend constexpr inline bool operator==(QLatin1Char lhs, QLatin1Char rhs) noexcept { return lhs.ch == rhs.ch; } +/ 39 /+ friend constexpr inline bool operator!=(QLatin1Char lhs, QLatin1Char rhs) noexcept { return lhs.ch != rhs.ch; } +/ 40 /+ friend constexpr inline bool operator<=(QLatin1Char lhs, QLatin1Char rhs) noexcept { return lhs.ch <= rhs.ch; } +/ 41 /+ friend constexpr inline bool operator>=(QLatin1Char lhs, QLatin1Char rhs) noexcept { return lhs.ch >= rhs.ch; } +/ 42 /+ friend constexpr inline bool operator< (QLatin1Char lhs, QLatin1Char rhs) noexcept { return lhs.ch < rhs.ch; } +/ 43 /+ friend constexpr inline bool operator> (QLatin1Char lhs, QLatin1Char rhs) noexcept { return lhs.ch > rhs.ch; } +/ 44 45 /+ friend constexpr inline bool operator==(char lhs, QLatin1Char rhs) noexcept { return lhs == rhs.toLatin1(); } +/ 46 /+ friend constexpr inline bool operator!=(char lhs, QLatin1Char rhs) noexcept { return lhs != rhs.toLatin1(); } +/ 47 /+ friend constexpr inline bool operator<=(char lhs, QLatin1Char rhs) noexcept { return lhs <= rhs.toLatin1(); } +/ 48 /+ friend constexpr inline bool operator>=(char lhs, QLatin1Char rhs) noexcept { return lhs >= rhs.toLatin1(); } +/ 49 /+ friend constexpr inline bool operator< (char lhs, QLatin1Char rhs) noexcept { return lhs < rhs.toLatin1(); } +/ 50 /+ friend constexpr inline bool operator> (char lhs, QLatin1Char rhs) noexcept { return lhs > rhs.toLatin1(); } +/ 51 52 /+ friend constexpr inline bool operator==(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() == rhs; } +/ 53 /+ friend constexpr inline bool operator!=(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() != rhs; } +/ 54 /+ friend constexpr inline bool operator<=(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() <= rhs; } +/ 55 /+ friend constexpr inline bool operator>=(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() >= rhs; } +/ 56 /+ friend constexpr inline bool operator< (QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() < rhs; } +/ 57 /+ friend constexpr inline bool operator> (QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() > rhs; } +/ 58 59 private: 60 char ch; 61 mixin(CREATE_CONVENIENCE_WRAPPERS); 62 } 63 static if(false) 64 { 65 /+ #define QCHAR_MAYBE_IMPLICIT Q_IMPLICIT +/ 66 } 67 /+ #define QCHAR_MAYBE_IMPLICIT explicit +/ 68 69 /// Binding for C++ class [QChar](https://doc.qt.io/qt-6/qchar.html). 70 @Q_PRIMITIVE_TYPE extern(C++, class) struct /+ Q_CORE_EXPORT +/ QChar { 71 public: 72 enum SpecialCharacter { 73 Null = 0x0000, 74 Tabulation = 0x0009, 75 LineFeed = 0x000a, 76 FormFeed = 0x000c, 77 CarriageReturn = 0x000d, 78 Space = 0x0020, 79 Nbsp = 0x00a0, 80 SoftHyphen = 0x00ad, 81 ReplacementCharacter = 0xfffd, 82 ObjectReplacementCharacter = 0xfffc, 83 ByteOrderMark = 0xfeff, 84 ByteOrderSwapped = 0xfffe, 85 ParagraphSeparator = 0x2029, 86 LineSeparator = 0x2028, 87 VisualTabCharacter = 0x2192, 88 LastValidCodePoint = 0x10ffff 89 } 90 91 /+ #ifdef QT_IMPLICIT_QCHAR_CONSTRUCTION 92 #define QCHAR_MAYBE_IMPLICIT Q_IMPLICIT 93 #else 94 #define QCHAR_MAYBE_IMPLICIT explicit 95 #endif +/ 96 97 /+this()/+ noexcept+/ 98 { 99 this.ucs = 0; 100 }+/ 101 this(ushort rc)/+ noexcept+/ 102 { 103 this.ucs = rc; 104 } 105 /+ QCHAR_MAYBE_IMPLICIT +/this(uchar c, uchar r)/+ noexcept+/ 106 { 107 this.ucs = cast(wchar)((r << 8) | c); 108 } 109 this(short rc)/+ noexcept+/ 110 { 111 this.ucs = wchar(rc); 112 } 113 /+ QCHAR_MAYBE_IMPLICIT +/this(uint rc)/+ noexcept+/ 114 { 115 this.ucs = ((){ (mixin(Q_ASSERT(q{rc <= 0xffff}))); 116 return cast(wchar)(rc); 117 }()); 118 } 119 /+ QCHAR_MAYBE_IMPLICIT +/this(int rc)/+ noexcept+/ 120 { 121 this(uint(rc)); 122 } 123 this(SpecialCharacter s)/+ noexcept+/ 124 { 125 this.ucs = cast(wchar)(s); 126 } 127 this(QLatin1Char ch)/+ noexcept+/ 128 { 129 this.ucs = ch.unicode(); 130 } 131 this(wchar ch)/+ noexcept+/ 132 { 133 this.ucs = ch; 134 } 135 /+ #if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) +/ 136 /+ static if((versionIsSet!("Windows") && !versionIsSet!("Cygwin"))) 137 { 138 this(wchar_t ch)/+ noexcept+/ 139 { 140 this.ucs = cast(wchar)(ch); 141 } 142 } +/ 143 /+ #endif 144 145 #ifndef QT_NO_CAST_FROM_ASCII 146 // Always implicit -- allow for 'x' => QChar conversions 147 QT_ASCII_CAST_WARN constexpr Q_IMPLICIT QChar(char c) noexcept : ucs(uchar(c)) { } 148 #ifndef QT_RESTRICTED_CAST_FROM_ASCII 149 QT_ASCII_CAST_WARN constexpr QCHAR_MAYBE_IMPLICIT QChar(uchar c) noexcept : ucs(c) { } 150 #endif 151 #endif 152 153 #undef QCHAR_MAYBE_IMPLICIT +/ 154 155 static QChar fromUcs2(wchar c)/+ noexcept+/ { return QChar(c); } 156 pragma(inline, true) static auto fromUcs4()(dchar c)/+ noexcept+/ 157 /+/+ [[nodiscard]] +/ pragma(inline, true) static auto fromUcs4(dchar c)/+ noexcept+/+/ 158 { 159 import qt.core.stringview; 160 161 struct R { 162 wchar[2] chars; 163 /+/+ [[nodiscard]] +/ auto opCast(T : QStringView)() const/+ noexcept+/ { return QStringView(begin(), end()); }+/ 164 /+ [[nodiscard]] +/ qsizetype size() const/+ noexcept+/ { return chars[1] ? 2 : 1; } 165 /+ [[nodiscard]] +/ const(wchar)* begin() const/+ noexcept+/ return { return chars.ptr; } 166 /+ [[nodiscard]] +/ const(wchar)* end() const/+ noexcept+/ return { return begin() + size(); } 167 }/+ ; +/ 168 return requiresSurrogates(c) ? R([QChar.highSurrogate(c), 169 QChar.lowSurrogate(c)]) : 170 R([cast(wchar)(c), '\0']) ; 171 } 172 173 // Unicode information 174 175 enum Category 176 { 177 Mark_NonSpacing, // Mn 178 Mark_SpacingCombining, // Mc 179 Mark_Enclosing, // Me 180 181 Number_DecimalDigit, // Nd 182 Number_Letter, // Nl 183 Number_Other, // No 184 185 Separator_Space, // Zs 186 Separator_Line, // Zl 187 Separator_Paragraph, // Zp 188 189 Other_Control, // Cc 190 Other_Format, // Cf 191 Other_Surrogate, // Cs 192 Other_PrivateUse, // Co 193 Other_NotAssigned, // Cn 194 195 Letter_Uppercase, // Lu 196 Letter_Lowercase, // Ll 197 Letter_Titlecase, // Lt 198 Letter_Modifier, // Lm 199 Letter_Other, // Lo 200 201 Punctuation_Connector, // Pc 202 Punctuation_Dash, // Pd 203 Punctuation_Open, // Ps 204 Punctuation_Close, // Pe 205 Punctuation_InitialQuote, // Pi 206 Punctuation_FinalQuote, // Pf 207 Punctuation_Other, // Po 208 209 Symbol_Math, // Sm 210 Symbol_Currency, // Sc 211 Symbol_Modifier, // Sk 212 Symbol_Other // So 213 } 214 215 enum Script 216 { 217 Script_Unknown, 218 Script_Inherited, 219 Script_Common, 220 221 Script_Latin, 222 Script_Greek, 223 Script_Cyrillic, 224 Script_Armenian, 225 Script_Hebrew, 226 Script_Arabic, 227 Script_Syriac, 228 Script_Thaana, 229 Script_Devanagari, 230 Script_Bengali, 231 Script_Gurmukhi, 232 Script_Gujarati, 233 Script_Oriya, 234 Script_Tamil, 235 Script_Telugu, 236 Script_Kannada, 237 Script_Malayalam, 238 Script_Sinhala, 239 Script_Thai, 240 Script_Lao, 241 Script_Tibetan, 242 Script_Myanmar, 243 Script_Georgian, 244 Script_Hangul, 245 Script_Ethiopic, 246 Script_Cherokee, 247 Script_CanadianAboriginal, 248 Script_Ogham, 249 Script_Runic, 250 Script_Khmer, 251 Script_Mongolian, 252 Script_Hiragana, 253 Script_Katakana, 254 Script_Bopomofo, 255 Script_Han, 256 Script_Yi, 257 Script_OldItalic, 258 Script_Gothic, 259 Script_Deseret, 260 Script_Tagalog, 261 Script_Hanunoo, 262 Script_Buhid, 263 Script_Tagbanwa, 264 Script_Coptic, 265 266 // Unicode 4.0 additions 267 Script_Limbu, 268 Script_TaiLe, 269 Script_LinearB, 270 Script_Ugaritic, 271 Script_Shavian, 272 Script_Osmanya, 273 Script_Cypriot, 274 Script_Braille, 275 276 // Unicode 4.1 additions 277 Script_Buginese, 278 Script_NewTaiLue, 279 Script_Glagolitic, 280 Script_Tifinagh, 281 Script_SylotiNagri, 282 Script_OldPersian, 283 Script_Kharoshthi, 284 285 // Unicode 5.0 additions 286 Script_Balinese, 287 Script_Cuneiform, 288 Script_Phoenician, 289 Script_PhagsPa, 290 Script_Nko, 291 292 // Unicode 5.1 additions 293 Script_Sundanese, 294 Script_Lepcha, 295 Script_OlChiki, 296 Script_Vai, 297 Script_Saurashtra, 298 Script_KayahLi, 299 Script_Rejang, 300 Script_Lycian, 301 Script_Carian, 302 Script_Lydian, 303 Script_Cham, 304 305 // Unicode 5.2 additions 306 Script_TaiTham, 307 Script_TaiViet, 308 Script_Avestan, 309 Script_EgyptianHieroglyphs, 310 Script_Samaritan, 311 Script_Lisu, 312 Script_Bamum, 313 Script_Javanese, 314 Script_MeeteiMayek, 315 Script_ImperialAramaic, 316 Script_OldSouthArabian, 317 Script_InscriptionalParthian, 318 Script_InscriptionalPahlavi, 319 Script_OldTurkic, 320 Script_Kaithi, 321 322 // Unicode 6.0 additions 323 Script_Batak, 324 Script_Brahmi, 325 Script_Mandaic, 326 327 // Unicode 6.1 additions 328 Script_Chakma, 329 Script_MeroiticCursive, 330 Script_MeroiticHieroglyphs, 331 Script_Miao, 332 Script_Sharada, 333 Script_SoraSompeng, 334 Script_Takri, 335 336 // Unicode 7.0 additions 337 Script_CaucasianAlbanian, 338 Script_BassaVah, 339 Script_Duployan, 340 Script_Elbasan, 341 Script_Grantha, 342 Script_PahawhHmong, 343 Script_Khojki, 344 Script_LinearA, 345 Script_Mahajani, 346 Script_Manichaean, 347 Script_MendeKikakui, 348 Script_Modi, 349 Script_Mro, 350 Script_OldNorthArabian, 351 Script_Nabataean, 352 Script_Palmyrene, 353 Script_PauCinHau, 354 Script_OldPermic, 355 Script_PsalterPahlavi, 356 Script_Siddham, 357 Script_Khudawadi, 358 Script_Tirhuta, 359 Script_WarangCiti, 360 361 // Unicode 8.0 additions 362 Script_Ahom, 363 Script_AnatolianHieroglyphs, 364 Script_Hatran, 365 Script_Multani, 366 Script_OldHungarian, 367 Script_SignWriting, 368 369 // Unicode 9.0 additions 370 Script_Adlam, 371 Script_Bhaiksuki, 372 Script_Marchen, 373 Script_Newa, 374 Script_Osage, 375 Script_Tangut, 376 377 // Unicode 10.0 additions 378 Script_MasaramGondi, 379 Script_Nushu, 380 Script_Soyombo, 381 Script_ZanabazarSquare, 382 383 // Unicode 12.1 additions 384 Script_Dogra, 385 Script_GunjalaGondi, 386 Script_HanifiRohingya, 387 Script_Makasar, 388 Script_Medefaidrin, 389 Script_OldSogdian, 390 Script_Sogdian, 391 Script_Elymaic, 392 Script_Nandinagari, 393 Script_NyiakengPuachueHmong, 394 Script_Wancho, 395 396 // Unicode 13.0 additions 397 Script_Chorasmian, 398 Script_DivesAkuru, 399 Script_KhitanSmallScript, 400 Script_Yezidi, 401 402 ScriptCount 403 } 404 405 enum Direction 406 { 407 DirL, DirR, DirEN, DirES, DirET, DirAN, DirCS, DirB, DirS, DirWS, DirON, 408 DirLRE, DirLRO, DirAL, DirRLE, DirRLO, DirPDF, DirNSM, DirBN, 409 DirLRI, DirRLI, DirFSI, DirPDI 410 } 411 412 enum Decomposition 413 { 414 NoDecomposition, 415 Canonical, 416 Font, 417 NoBreak, 418 Initial, 419 Medial, 420 Final, 421 Isolated, 422 Circle, 423 Super, 424 Sub, 425 Vertical, 426 Wide, 427 Narrow, 428 Small, 429 Square, 430 Compat, 431 Fraction 432 } 433 434 enum JoiningType { 435 Joining_None, 436 Joining_Causing, 437 Joining_Dual, 438 Joining_Right, 439 Joining_Left, 440 Joining_Transparent 441 } 442 443 enum CombiningClass 444 { 445 Combining_BelowLeftAttached = 200, 446 Combining_BelowAttached = 202, 447 Combining_BelowRightAttached = 204, 448 Combining_LeftAttached = 208, 449 Combining_RightAttached = 210, 450 Combining_AboveLeftAttached = 212, 451 Combining_AboveAttached = 214, 452 Combining_AboveRightAttached = 216, 453 454 Combining_BelowLeft = 218, 455 Combining_Below = 220, 456 Combining_BelowRight = 222, 457 Combining_Left = 224, 458 Combining_Right = 226, 459 Combining_AboveLeft = 228, 460 Combining_Above = 230, 461 Combining_AboveRight = 232, 462 463 Combining_DoubleBelow = 233, 464 Combining_DoubleAbove = 234, 465 Combining_IotaSubscript = 240 466 } 467 468 enum UnicodeVersion { 469 Unicode_Unassigned, 470 Unicode_1_1, 471 Unicode_2_0, 472 Unicode_2_1_2, 473 Unicode_3_0, 474 Unicode_3_1, 475 Unicode_3_2, 476 Unicode_4_0, 477 Unicode_4_1, 478 Unicode_5_0, 479 Unicode_5_1, 480 Unicode_5_2, 481 Unicode_6_0, 482 Unicode_6_1, 483 Unicode_6_2, 484 Unicode_6_3, 485 Unicode_7_0, 486 Unicode_8_0, 487 Unicode_9_0, 488 Unicode_10_0, 489 Unicode_11_0, 490 Unicode_12_0, 491 Unicode_12_1, 492 Unicode_13_0 493 } 494 495 /+ pragma(inline, true) Category category() const/+ noexcept+/ { return QChar.category(ucs); } 496 pragma(inline, true) Direction direction() const/+ noexcept+/ { return QChar.direction(ucs); } 497 pragma(inline, true) JoiningType joiningType() const/+ noexcept+/ { return QChar.joiningType(ucs); } 498 pragma(inline, true) ubyte combiningClass() const/+ noexcept+/ { return QChar.combiningClass(ucs); } 499 500 pragma(inline, true) QChar mirroredChar() const/+ noexcept+/ { return QChar(cast(uchar)(QChar.mirroredChar(ucs))); } 501 pragma(inline, true) bool hasMirrored() const/+ noexcept+/ { return QChar.hasMirrored(ucs); } 502 503 QString decomposition() const; 504 pragma(inline, true) Decomposition decompositionTag() const/+ noexcept+/ { return QChar.decompositionTag(ucs); } 505 506 pragma(inline, true) int digitValue() const/+ noexcept+/ { return QChar.digitValue(ucs); } 507 pragma(inline, true) QChar toLower() const/+ noexcept+/ { return QChar(cast(uchar)(QChar.toLower(ucs))); } 508 pragma(inline, true) QChar toUpper() const/+ noexcept+/ { return QChar(cast(uchar)(QChar.toUpper(ucs))); } 509 pragma(inline, true) QChar toTitleCase() const/+ noexcept+/ { return QChar(cast(uchar)(QChar.toTitleCase(ucs))); } 510 pragma(inline, true) QChar toCaseFolded() const/+ noexcept+/ { return QChar(cast(uchar)(QChar.toCaseFolded(ucs))); } 511 512 pragma(inline, true) Script script() const/+ noexcept+/ { return QChar.script(ucs); } 513 514 pragma(inline, true) UnicodeVersion unicodeVersion() const/+ noexcept+/ { return QChar.unicodeVersion(ucs); }+/ 515 516 pragma(inline, true) char toLatin1() const/+ noexcept+/ { return ucs > 0xff ? '\0' : cast(char)(ucs); } 517 pragma(inline, true) wchar unicode() const/+ noexcept+/ { return ucs; } 518 pragma(inline, true) ref wchar unicode() return /+ noexcept+/ { return ucs; } 519 520 //static QChar fromLatin1(char c)/+ noexcept+/ { return QLatin1Char(c); } 521 522 pragma(inline, true) bool isNull() const/+ noexcept+/ { return ucs == 0; } 523 524 pragma(inline, true) bool isPrint() const/+ noexcept+/ { return QChar.isPrint(ucs); } 525 pragma(inline, true) bool isSpace() const/+ noexcept+/ { return QChar.isSpace(ucs); } 526 pragma(inline, true) bool isMark() const/+ noexcept+/ { return QChar.isMark(ucs); } 527 pragma(inline, true) bool isPunct() const/+ noexcept+/ { return QChar.isPunct(ucs); } 528 pragma(inline, true) bool isSymbol() const/+ noexcept+/ { return QChar.isSymbol(ucs); } 529 pragma(inline, true) bool isLetter() const/+ noexcept+/ { return QChar.isLetter(ucs); } 530 pragma(inline, true) bool isNumber() const/+ noexcept+/ { return QChar.isNumber(ucs); } 531 pragma(inline, true) bool isLetterOrNumber() const/+ noexcept+/ { return QChar.isLetterOrNumber(ucs); } 532 pragma(inline, true) bool isDigit() const/+ noexcept+/ { return QChar.isDigit(ucs); } 533 pragma(inline, true) bool isLower() const/+ noexcept+/ { return QChar.isLower(ucs); } 534 pragma(inline, true) bool isUpper() const/+ noexcept+/ { return QChar.isUpper(ucs); } 535 pragma(inline, true) bool isTitleCase() const/+ noexcept+/ { return QChar.isTitleCase(ucs); } 536 537 pragma(inline, true) bool isNonCharacter() const/+ noexcept+/ { return QChar.isNonCharacter(ucs); } 538 pragma(inline, true) bool isHighSurrogate() const/+ noexcept+/ { return QChar.isHighSurrogate(ucs); } 539 pragma(inline, true) bool isLowSurrogate() const/+ noexcept+/ { return QChar.isLowSurrogate(ucs); } 540 pragma(inline, true) bool isSurrogate() const/+ noexcept+/ { return QChar.isSurrogate(ucs); } 541 542 pragma(inline, true) uchar cell() const/+ noexcept+/ { return cast(uchar)(ucs & 0xff); } 543 pragma(inline, true) uchar row() const/+ noexcept+/ { return cast(uchar)((ucs>>8)&0xff); } 544 pragma(inline, true) void setCell(uchar acell)/+ noexcept+/ { ucs = cast(wchar)((ucs & 0xff00) + acell); } 545 pragma(inline, true) void setRow(uchar arow)/+ noexcept+/ { ucs = cast(wchar)((wchar(arow)<<8) + (ucs&0xff)); } 546 547 pragma(inline, true) static bool isNonCharacter(dchar ucs4)/+ noexcept+/ 548 { 549 return ucs4 >= 0xfdd0 && (ucs4 <= 0xfdef || (ucs4 & 0xfffe) == 0xfffe); 550 } 551 pragma(inline, true) static bool isHighSurrogate(dchar ucs4)/+ noexcept+/ 552 { 553 return (ucs4 & 0xfffffc00) == 0xd800; // 0xd800 + up to 1023 (0x3ff) 554 } 555 pragma(inline, true) static bool isLowSurrogate(dchar ucs4)/+ noexcept+/ 556 { 557 return (ucs4 & 0xfffffc00) == 0xdc00; // 0xdc00 + up to 1023 (0x3ff) 558 } 559 pragma(inline, true) static bool isSurrogate(dchar ucs4)/+ noexcept+/ 560 { 561 return (ucs4 - 0xd800u < 2048u); 562 } 563 pragma(inline, true) static bool requiresSurrogates(dchar ucs4)/+ noexcept+/ 564 { 565 return (ucs4 >= 0x10000); 566 } 567 pragma(inline, true) static dchar surrogateToUcs4(wchar high, wchar low)/+ noexcept+/ 568 { 569 // 0x010000 through 0x10ffff, provided params are actual high, low surrogates. 570 // 0x010000 + ((high - 0xd800) << 10) + (low - 0xdc00), optimized: 571 return cast(dchar)((dchar(high)<<10) + low - 0x35fdc00); 572 } 573 pragma(inline, true) static dchar surrogateToUcs4(QChar high, QChar low)/+ noexcept+/ 574 { 575 return surrogateToUcs4(high.ucs, low.ucs); 576 } 577 pragma(inline, true) static wchar highSurrogate(dchar ucs4)/+ noexcept+/ 578 { 579 return cast(wchar)((ucs4>>10) + 0xd7c0); 580 } 581 pragma(inline, true) static wchar lowSurrogate(dchar ucs4)/+ noexcept+/ 582 { 583 return cast(wchar)(ucs4%0x400 + 0xdc00); 584 } 585 586 static Category /+ QT_FASTCALL +/ category(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 587 static Direction /+ QT_FASTCALL +/ direction(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 588 static JoiningType /+ QT_FASTCALL +/ joiningType(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 589 static ubyte /+ QT_FASTCALL +/ combiningClass(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 590 591 static dchar /+ QT_FASTCALL +/ mirroredChar(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 592 static bool /+ QT_FASTCALL +/ hasMirrored(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 593 594 static QString /+ QT_FASTCALL +/ decomposition(dchar ucs4); 595 static Decomposition /+ QT_FASTCALL +/ decompositionTag(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 596 597 static int /+ QT_FASTCALL +/ digitValue(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 598 static dchar /+ QT_FASTCALL +/ toLower(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 599 static dchar /+ QT_FASTCALL +/ toUpper(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 600 static dchar /+ QT_FASTCALL +/ toTitleCase(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 601 static dchar /+ QT_FASTCALL +/ toCaseFolded(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 602 603 static Script /+ QT_FASTCALL +/ script(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 604 605 static UnicodeVersion /+ QT_FASTCALL +/ unicodeVersion(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 606 607 static UnicodeVersion /+ QT_FASTCALL +/ currentUnicodeVersion()/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 608 609 static bool /+ QT_FASTCALL +/ isPrint(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 610 pragma(inline, true) static bool isSpace(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/ 611 __attribute__((const))+/ { 612 // note that [0x09..0x0d] + 0x85 are exceptional Cc-s and must be handled explicitly 613 return ucs4 == 0x20 || (ucs4 <= 0x0d && ucs4 >= 0x09) 614 || (ucs4 > 127 && (ucs4 == 0x85 || ucs4 == 0xa0 || QChar.isSpace_helper(ucs4))); 615 } 616 static bool /+ QT_FASTCALL +/ isMark(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 617 static bool /+ QT_FASTCALL +/ isPunct(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 618 static bool /+ QT_FASTCALL +/ isSymbol(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 619 pragma(inline, true) static bool isLetter(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/ 620 __attribute__((const))+/ { 621 return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z')) 622 || (ucs4 > 127 && QChar.isLetter_helper(ucs4)); 623 } 624 pragma(inline, true) static bool isNumber(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/ 625 __attribute__((const))+/ { return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar.isNumber_helper(ucs4)); } 626 pragma(inline, true) static bool isLetterOrNumber(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/ 627 __attribute__((const))+/ { 628 return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z')) 629 || (ucs4 >= '0' && ucs4 <= '9') 630 || (ucs4 > 127 && QChar.isLetterOrNumber_helper(ucs4)); 631 } 632 pragma(inline, true) static bool isDigit(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/ 633 __attribute__((const))+/ { return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar.category(ucs4) == Category.Number_DecimalDigit); } 634 pragma(inline, true) static bool isLower(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/ 635 __attribute__((const))+/ { return (ucs4 <= 'z' && ucs4 >= 'a') || (ucs4 > 127 && QChar.category(ucs4) == Category.Letter_Lowercase); } 636 pragma(inline, true) static bool isUpper(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/ 637 __attribute__((const))+/ { return (ucs4 <= 'Z' && ucs4 >= 'A') || (ucs4 > 127 && QChar.category(ucs4) == Category.Letter_Uppercase); } 638 pragma(inline, true) static bool isTitleCase(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/ 639 __attribute__((const))+/ { return ucs4 > 127 && QChar.category(ucs4) == Category.Letter_Titlecase; } 640 641 /+ friend constexpr inline bool operator==(QChar c1, QChar c2) noexcept { return c1.ucs == c2.ucs; } +/ 642 /+ friend constexpr inline bool operator< (QChar c1, QChar c2) noexcept { return c1.ucs < c2.ucs; } +/ 643 644 /+ friend constexpr inline bool operator!=(QChar c1, QChar c2) noexcept { return !operator==(c1, c2); } +/ 645 /+ friend constexpr inline bool operator>=(QChar c1, QChar c2) noexcept { return !operator< (c1, c2); } +/ 646 /+ friend constexpr inline bool operator> (QChar c1, QChar c2) noexcept { return operator< (c2, c1); } +/ 647 /+ friend constexpr inline bool operator<=(QChar c1, QChar c2) noexcept { return !operator< (c2, c1); } +/ 648 649 /+ friend constexpr inline bool operator==(QChar lhs, std::nullptr_t) noexcept { return lhs.isNull(); } +/ 650 /+ friend constexpr inline bool operator< (QChar, std::nullptr_t) noexcept { return false; } +/ 651 /+ friend constexpr inline bool operator==(std::nullptr_t, QChar rhs) noexcept { return rhs.isNull(); } +/ 652 /+ friend constexpr inline bool operator< (std::nullptr_t, QChar rhs) noexcept { return !rhs.isNull(); } +/ 653 654 /+ friend constexpr inline bool operator!=(QChar lhs, std::nullptr_t) noexcept { return !operator==(lhs, nullptr); } +/ 655 /+ friend constexpr inline bool operator>=(QChar lhs, std::nullptr_t) noexcept { return !operator< (lhs, nullptr); } +/ 656 /+ friend constexpr inline bool operator> (QChar lhs, std::nullptr_t) noexcept { return operator< (nullptr, lhs); } +/ 657 /+ friend constexpr inline bool operator<=(QChar lhs, std::nullptr_t) noexcept { return !operator< (nullptr, lhs); } +/ 658 659 /+ friend constexpr inline bool operator!=(std::nullptr_t, QChar rhs) noexcept { return !operator==(nullptr, rhs); } +/ 660 /+ friend constexpr inline bool operator>=(std::nullptr_t, QChar rhs) noexcept { return !operator< (nullptr, rhs); } +/ 661 /+ friend constexpr inline bool operator> (std::nullptr_t, QChar rhs) noexcept { return operator< (rhs, nullptr); } +/ 662 /+ friend constexpr inline bool operator<=(std::nullptr_t, QChar rhs) noexcept { return !operator< (rhs, nullptr); } +/ 663 664 private: 665 static bool /+ QT_FASTCALL +/ isSpace_helper(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 666 static bool /+ QT_FASTCALL +/ isLetter_helper(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 667 static bool /+ QT_FASTCALL +/ isNumber_helper(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 668 static bool /+ QT_FASTCALL +/ isLetterOrNumber_helper(dchar ucs4)/+ noexcept /+ Q_DECL_CONST_FUNCTION +/__attribute__((const))+/; 669 670 /+ #ifdef QT_NO_CAST_FROM_ASCII +/ 671 //this(char c) /+ = delete +/; 672 //this(uchar c) /+ = delete +/; 673 /+ #endif +/ 674 675 wchar ucs = 0; 676 mixin(CREATE_CONVENIENCE_WRAPPERS); 677 } 678 679 /+ Q_DECLARE_TYPEINFO(QChar, Q_PRIMITIVE_TYPE); 680 681 #ifndef QT_NO_DATASTREAM 682 Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, QChar); 683 Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QChar &); 684 #endif 685 686 687 namespace std { 688 template <> 689 struct hash<QT_PREPEND_NAMESPACE(QChar)> 690 { 691 template <typename = void> // for transparent constexpr tracking 692 constexpr size_t operator()(QT_PREPEND_NAMESPACE(QChar) c) const 693 noexcept(noexcept(std::hash<wchar>{}(u' '))) 694 { 695 return std::hash<wchar>{}(c.unicode()); 696 } 697 }; 698 } +/ // namespace std 699 700 /+ #endif +/ // QCHAR_H 701