summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qchar.h
Commit message (Collapse)AuthorAgeFilesLines
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-11-301-1/+1
| | | | | | | | | | | | | | Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with move semantics, its name is misleading. Q_RELOCATABLE_TYPE was introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE in QtBase. As the two are synonymous, this patch should have no impact on users. Pick-to: 6.0 Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QChar: assert on illegal constructionGiuseppe D'Angelo2020-11-201-2/+2
| | | | | | | | | | | | If the input is out of range for the respective input type, then fire an assert. Remove a redudant bitwise-and. The constructors from char have been left alone: we are documenting that QChar(char) constructs from Latin1 (!), not ASCII/UTF-8, so all values are valid. Change-Id: I55e261015d5efa0699c78c25e454f09bb17a913f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QChar: use =delete instead of privateGiuseppe D'Angelo2020-11-191-2/+2
| | | | | | | Use the idiomatic way to block access to some functions. Change-Id: I6760dac6ce18910bf30b527b313882e394049349 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QChar: get rid of some redundant commentsGiuseppe D'Angelo2020-11-181-4/+4
| | | | | | | We have a proper tag now. Change-Id: Ia5279a82e078d27aa5e09a427f36cf355d959e1f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Centralize the wchar_t == char16_t check on WindowsGiuseppe D'Angelo2020-11-181-3/+0
| | | | | | | | Don't push it onto every TU that includes QChar (... approx. everything that uses Qt). Change-Id: I4a07ce9e38a347b45315db93b0c5b90c20bacdbc Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QChar: make construction from integral explicitGiuseppe D'Angelo2020-11-151-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QChar should not be convertible from any integral type except from char16_t, short and possibly char (since it's a direct superset). David provided the perfect example: if (str == 123) { ~~~ } compiles, with 123 implicitly converted to QChar (str == "123" was meant instead). But similarly one can construct other scenarios where QString(123) gets accidentally used (instead of QString::number(123)), like QString s; s += 123;. Add a macro to revert to the implicit constructors, for backwards compatibility. The breaks are mostly in tests that "abuse" of integers (arithmetic, etc.). Maybe it's time for user-defined literals for QChar/QString, but that is left for another commit. [ChangeLog][Potentially Source-Incompatible Changes][QChar] QChar constructors from integral types are now by default explicit. It is recommended to use explicit conversions, QLatin1Char, QChar::fromUcs4 instead of implicit conversions. The old behavior can be restored by defining the QT_IMPLICIT_QCHAR_CONSTRUCTION macro. Change-Id: I6175f6ab9bcf1956f6f97ab0c9d9d5aaf777296d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove left over friend declarationAllan Sandfeld Jensen2020-10-271-2/+0
| | | | | | | Was not removed when it was inlined above it. Change-Id: Ie81bd9273108920031b235bdf1f13439711e5fec Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make QLatin1Char and QChar comparisons hidden friendsAllan Sandfeld Jensen2020-10-221-38/+44
| | | | | | | Reduces the ADL noise on missing comparisons errors. Change-Id: I16a17d73504917feb25a94053bb54db0b083118b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Long live Q_IMPLICIT!Giuseppe D'Angelo2020-10-141-12/+12
| | | | | | | | | | | | | C++20 will give us explicit(bool). While we can't use it just yet in its full potential, we can introduce a macro to start marking our implicit conversions (aka `explicit(false)`), removing the need for /* implicit */-like comments. Port a few usages to it. Change-Id: I336d5e4c8d51d8329627900d1059e59062c5cafd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Purge Q_{STDLIB,COMPILER}_UNICODE_STRINGSEdward Welbourne2020-09-141-3/+1
| | | | | | | | | These were now always defined, hence redundant. Leave the #define in place so that we can verify we actually do always define it, in a #else of an existing #if check on it. Change-Id: Iea4c3dbc8f9982268bcf81da5ef17fe2ebf5c462 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use checked string iteration in case conversionsEdward Welbourne2020-08-291-2/+4
| | | | | | | | | | | | | | | | | | The Unicode table code can only be safely called on valid code-points. So code that calls it must only pass it valid Unicode data. The string iterator's Unchecked Unchecked methods only provide this guarantee when the string being iterated is guaranteed to be valid UTF-16; while client code should only use QString, QStringView and friends on valid UTF-16 data, we have no way to be sure they have respected that. So take the few extra cycles to actually check validity in the course of iterating strings, when the resulting code-points are to be passed to the Unicode table look-ups. Add tests that case mapping doesn't access Unicode tables out of range (it'll trigger the new assertion). Added some comments to qchar.h that helped me understand surrogates. Change-Id: Iec2c3106bf1a875bdaa1d622f6cf94d7007e281e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace Qt CONSTEXPR defines with constexprAllan Sandfeld Jensen2020-08-141-88/+88
| | | | | | | | Both normal and relaxed constexpr are required by our new minimum of C++17. Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QChar: purge deprecated APIEdward Welbourne2020-07-201-31/+0
| | | | | | | | Since 5.3 joining() and old Joining type Replaced by JoiningType joiningType() Change-Id: Iefee50aaf94cec6d67b5fc004b3e68357b2015c5 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Port Q_STATIC_ASSERT(_X) to static_assertGiuseppe D'Angelo2020-06-191-1/+1
| | | | | | | | | | | | | | | | | There is no reason for keep using our macro now that we have C++17. The macro itself is left in for the moment being, as well as its detection logic, because it's needed for C code (not everything supports C11 yet). A few more cleanups will arrive in the next few patches. Note that this is a mere search/replace; some places were using double braces to work around the presence of commas in a macro, no attempt has been done to fix those. tst_qglobal had just some minor changes to keep testing the macro. Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QChar: add fromUcs{2,4}()Marc Mutz2020-05-091-0/+6
| | | | | | | | | | | | | | | | | | | | The fromUcs2() named ctor is designed to replace all the non-char integral-type constructors of QChar which make it very hard to control the implicit QChar conversions, which have caused a few bugs in Qt itself. As a classical named contructor, it simply returns QChar. The fromUcs4() named "ctor", however, needs to expand surrogate pairs, and thus can't just return QChar. Instead, it returns a small struct that contains one or two char16_t's, can be iterated over and be implicitly converted to QStringView. To avoid bikeshedding the name (FromUcs4Result, of course :), it's defined inline and thus can't be named outside the function. This function replaces most uses of QChar::requiresSurrogates() in QtBase. [ChangeLog][QtCore][QChar] Added fromUcs2(), fromUcs4(). Change-Id: I803708c14001040f75cb599e33c24a3fb8d2579c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QChar: finish port to char16_tMarc Mutz2020-05-081-16/+16
| | | | | | Change-Id: If38405da34543f836e674474c05f2d98ed610a23 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QChar: fix missing warning for construction from char/ucharMarc Mutz2020-05-051-2/+2
| | | | | | | | | | | | Commit eea219732ed79fde65c1074832fb80fdf62d4c30 added the explicit keyword to the QT_ASCII_CAST_WARN constructors of QChar, essentially disabling the intended warning for the char/uchar case, because the compiler would just pick another of the QChar ctors. Fix by removing the explicit keyword again. Change-Id: I65466426cfa471d44c3537fc47620ec8f0fcffcd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QChar: make std::hash'ableMarc Mutz2020-05-051-0/+15
| | | | | Change-Id: I2164df19cd17ab96a39020de66a3fe9fec838a36 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QChar: port low-level functions from uint/ushort to char32/16_tMarc Mutz2020-04-241-44/+44
| | | | | | | | | | | | | | | | | | Now that the standard gives us proper types for UTF-16 and UTF-32 characters, use them. Will eventually make the code much easier to read than today, where uint could be an index as well as a char32_t. It also ensures that the result of e.g. QChar::highSurrogate() can still be implicitly converted to a QChar now that the QChar(non-characater-integral-types) ctors are being made explicit. [ChangeLog][QtCore][QChar] All low-level functions (e.g. highSurrogate()) now take and return char16_t instead of ushort and char32_t instead of uint. Change-Id: I9cd8ebf6fb998fe1075dae96c7c4484a057f0b91 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Merge remote-tracking branch 'origin/5.15' into devSimon Hausmann2020-03-161-1/+8
|\ | | | | | | | | | | | | Conflicts: src/corelib/kernel/qmetatype.cpp Change-Id: I88eb0d3e9c9a38abf7241a51e370c655ae74e38a
| * Update UCD to Revision 26Edward Welbourne2020-03-141-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Include WordBreakTest.html, since a test uses sample strings from it, albeit without actually reading the file. Had to comment out more of the new tests, as at Revision 24, pending an update to harfbuzz and the text boundary detection code. Task-number: QTBUG-79631 Task-number: QTBUG-79418 Task-number: QTBUG-82747 Change-Id: I0082294b09d67ffdc6a9b5c15acf77ad3b86f65f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Get rid of QCharRef and QByteRefLars Knoll2019-12-081-1/+0
|/ | | | | | | | | | We already detach immediately since change c2d2757bccc68e1b981df059786c2e76f2969530. That basically removes the main purpose of having QChar/ByteRef, and we can just as well get rid of those classes for Qt 6. Change-Id: I8dc566a1948ddc29c0cb8a77ec7310654a7219a4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add missing docs for UCD additions at 5.15Edward Welbourne2019-11-281-1/+1
| | | | | | | | | Also remove two stray commas pointed out in code-review and some others noticed on checking for similar. This amends commit c3eb521a0f10112df6b61d2592351c4eef2e1f9b. Change-Id: If20c5146b740defe8d25ff61d399031b5c66ded1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Update UCD data to Unicode 12.1.0's Revision 24Edward Welbourne2019-10-301-2/+18
| | | | | | | | | | | | | | | | Had to teach the update program to accept category Lm as for Joining_Transparent, for the sake of a new ArabicShaping.txt entry. Added three new Unicode versions, several new scripts and a new word-break class. Updated UCD's test data for tst_QTextBoundaryFinder. This left 57 tests failing; I have commented out the data rows for those tests, pending someone with more knowledge addressing this. Task-number: QTBUG-79631 Task-number: QTBUG-79418 Change-Id: Ic33d3b3551195d47a84d98e84020f57a68f0b201 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QChar: add FormFeed (FF) special characterThiago Macieira2019-08-121-0/+1
| | | | | | | | [ChangeLog][QtCore][QChar] Added FormFeed (FF) special character. Fixes: QTBUG-77089 Change-Id: I1024ee42da0c4323953afffd15b245a508f545f0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Move text-related code out of corelib/tools/ to corelib/text/Edward Welbourne2019-07-101-0/+644
This includes byte array, string, char, unicode, locale, collation and regular expressions. Change-Id: I8b125fa52c8c513eb57a0f1298b91910e5a0d786 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>