summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qchar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qchar.cpp')
-rw-r--r--src/corelib/tools/qchar.cpp134
1 files changed, 56 insertions, 78 deletions
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp
index 014d91162a..78fa0bccf0 100644
--- a/src/corelib/tools/qchar.cpp
+++ b/src/corelib/tools/qchar.cpp
@@ -178,8 +178,10 @@ QT_BEGIN_NAMESPACE
\value Unicode_6_1 Version 6.1
\value Unicode_6_2 Version 6.2
\value Unicode_6_3 Version 6.3 Since Qt 5.3
+ \value Unicode_7_0 Version 7.0 Since Qt 5.5
+ \value Unicode_8_0 Version 8.0 Since Qt 5.6
\value Unicode_Unassigned The value is not assigned to any character
- in version 6.3 of Unicode.
+ in version 8.0 of Unicode.
\sa unicodeVersion(), currentUnicodeVersion()
*/
@@ -400,6 +402,12 @@ QT_BEGIN_NAMESPACE
\value Script_Khudawadi
\value Script_Tirhuta
\value Script_WarangCiti
+ \value Script_Ahom
+ \value Script_AnatolianHieroglyphs
+ \value Script_Hatran
+ \value Script_Multani
+ \value Script_OldHungarian
+ \value Script_SignWriting
\omitvalue ScriptCount
@@ -691,7 +699,7 @@ QT_BEGIN_NAMESPACE
Note that this gives no indication of whether the character is
available in a particular font.
*/
-bool QChar::isPrint(uint ucs4)
+bool QChar::isPrint(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -724,7 +732,7 @@ bool QChar::isPrint(uint ucs4)
/*!
\internal
*/
-bool QT_FASTCALL QChar::isSpace_helper(uint ucs4)
+bool QT_FASTCALL QChar::isSpace_helper(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -750,7 +758,7 @@ bool QT_FASTCALL QChar::isSpace_helper(uint ucs4)
Returns \c true if the UCS-4-encoded character specified by \a ucs4 is
a mark (Mark_* categories); otherwise returns \c false.
*/
-bool QChar::isMark(uint ucs4)
+bool QChar::isMark(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -774,7 +782,7 @@ bool QChar::isMark(uint ucs4)
Returns \c true if the UCS-4-encoded character specified by \a ucs4 is
a punctuation mark (Punctuation_* categories); otherwise returns \c false.
*/
-bool QChar::isPunct(uint ucs4)
+bool QChar::isPunct(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -802,7 +810,7 @@ bool QChar::isPunct(uint ucs4)
Returns \c true if the UCS-4-encoded character specified by \a ucs4 is
a symbol (Symbol_* categories); otherwise returns \c false.
*/
-bool QChar::isSymbol(uint ucs4)
+bool QChar::isSymbol(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -832,7 +840,7 @@ bool QChar::isSymbol(uint ucs4)
/*!
\internal
*/
-bool QT_FASTCALL QChar::isLetter_helper(uint ucs4)
+bool QT_FASTCALL QChar::isLetter_helper(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -867,7 +875,7 @@ bool QT_FASTCALL QChar::isLetter_helper(uint ucs4)
/*!
\internal
*/
-bool QT_FASTCALL QChar::isNumber_helper(uint ucs4)
+bool QT_FASTCALL QChar::isNumber_helper(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -896,7 +904,7 @@ bool QT_FASTCALL QChar::isNumber_helper(uint ucs4)
/*!
\internal
*/
-bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4)
+bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -1059,7 +1067,7 @@ bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4)
Returns the numeric value of the digit specified by the UCS-4-encoded
character, \a ucs4, or -1 if the character is not a digit.
*/
-int QChar::digitValue(uint ucs4)
+int QChar::digitValue(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return -1;
@@ -1076,7 +1084,7 @@ int QChar::digitValue(uint ucs4)
\overload
Returns the category of the UCS-4-encoded character specified by \a ucs4.
*/
-QChar::Category QChar::category(uint ucs4)
+QChar::Category QChar::category(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return QChar::Other_NotAssigned;
@@ -1093,7 +1101,7 @@ QChar::Category QChar::category(uint ucs4)
\overload
Returns the direction of the UCS-4-encoded character specified by \a ucs4.
*/
-QChar::Direction QChar::direction(uint ucs4)
+QChar::Direction QChar::direction(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return QChar::DirL;
@@ -1116,7 +1124,7 @@ QChar::Direction QChar::direction(uint ucs4)
character specified by \a ucs4
(needed for certain languages such as Arabic or Syriac).
*/
-QChar::JoiningType QChar::joiningType(uint ucs4)
+QChar::JoiningType QChar::joiningType(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return QChar::Joining_None;
@@ -1139,7 +1147,7 @@ QChar::JoiningType QChar::joiningType(uint ucs4)
Returns information about the joining properties of the UCS-4-encoded
character specified by \a ucs4 (needed for certain languages such as Arabic).
*/
-QChar::Joining QChar::joining(uint ucs4)
+QChar::Joining QChar::joining(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return QChar::OtherJoining;
@@ -1175,7 +1183,7 @@ QChar::Joining QChar::joining(uint ucs4)
\sa mirroredChar()
*/
-bool QChar::hasMirrored(uint ucs4)
+bool QChar::hasMirrored(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return false;
@@ -1257,7 +1265,7 @@ bool QChar::hasMirrored(uint ucs4)
\sa hasMirrored()
*/
-uint QChar::mirroredChar(uint ucs4)
+uint QChar::mirroredChar(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return ucs4;
@@ -1341,7 +1349,7 @@ QString QChar::decomposition(uint ucs4)
Returns the tag defining the composition of the UCS-4-encoded character
specified by \a ucs4. Returns QChar::NoDecomposition if no decomposition exists.
*/
-QChar::Decomposition QChar::decompositionTag(uint ucs4)
+QChar::Decomposition QChar::decompositionTag(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 >= Hangul_SBase && ucs4 < Hangul_SBase + Hangul_SCount)
return QChar::Canonical;
@@ -1367,7 +1375,7 @@ QChar::Decomposition QChar::decompositionTag(uint ucs4)
Returns the combining class for the UCS-4-encoded character specified by
\a ucs4, as defined in the Unicode standard.
*/
-unsigned char QChar::combiningClass(uint ucs4)
+unsigned char QChar::combiningClass(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return 0;
@@ -1388,7 +1396,7 @@ unsigned char QChar::combiningClass(uint ucs4)
Returns the Unicode script property value for the character specified in
its UCS-4-encoded form as \a ucs4.
*/
-QChar::Script QChar::script(uint ucs4)
+QChar::Script QChar::script(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return QChar::Script_Unknown;
@@ -1406,7 +1414,7 @@ QChar::Script QChar::script(uint ucs4)
Returns the Unicode version that introduced the character specified in
its UCS-4-encoded form as \a ucs4.
*/
-QChar::UnicodeVersion QChar::unicodeVersion(uint ucs4)
+QChar::UnicodeVersion QChar::unicodeVersion(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return QChar::Unicode_Unassigned;
@@ -1416,54 +1424,24 @@ QChar::UnicodeVersion QChar::unicodeVersion(uint ucs4)
/*!
Returns the most recent supported Unicode version.
*/
-QChar::UnicodeVersion QChar::currentUnicodeVersion()
+QChar::UnicodeVersion QChar::currentUnicodeVersion() Q_DECL_NOTHROW
{
return UNICODE_DATA_VERSION;
}
-template <typename T>
-Q_DECL_CONST_FUNCTION static inline T toLowerCase_helper(T uc)
+template <typename Traits, typename T>
+Q_DECL_CONST_FUNCTION static inline T convertCase_helper(T uc) Q_DECL_NOTHROW
{
- const QUnicodeTables::Properties *p = qGetProp(uc);
- if (p->lowerCaseSpecial) {
- const ushort *specialCase = specialCaseMap + p->lowerCaseDiff;
- return (*specialCase == 1) ? specialCase[1] : uc;
- }
- return uc + p->lowerCaseDiff;
-}
-
-template <typename T>
-Q_DECL_CONST_FUNCTION static inline T toUpperCase_helper(T uc)
-{
- const QUnicodeTables::Properties *p = qGetProp(uc);
- if (p->upperCaseSpecial) {
- const ushort *specialCase = specialCaseMap + p->upperCaseDiff;
- return (*specialCase == 1) ? specialCase[1] : uc;
- }
- return uc + p->upperCaseDiff;
-}
+ const QUnicodeTables::Properties *prop = qGetProp(uc);
-template <typename T>
-Q_DECL_CONST_FUNCTION static inline T toTitleCase_helper(T uc)
-{
- const QUnicodeTables::Properties *p = qGetProp(uc);
- if (p->titleCaseSpecial) {
- const ushort *specialCase = specialCaseMap + p->titleCaseDiff;
- return (*specialCase == 1) ? specialCase[1] : uc;
+ if (Q_UNLIKELY(Traits::caseSpecial(prop))) {
+ const ushort *specialCase = specialCaseMap + Traits::caseDiff(prop);
+ // so far, there are no special cases beyond BMP (guaranteed by the qunicodetables generator)
+ return *specialCase == 1 ? specialCase[1] : uc;
}
- return uc + p->titleCaseDiff;
-}
-template <typename T>
-Q_DECL_CONST_FUNCTION static inline T toCaseFolded_helper(T uc)
-{
- const QUnicodeTables::Properties *p = qGetProp(uc);
- if (p->caseFoldSpecial) {
- const ushort *specialCase = specialCaseMap + p->caseFoldDiff;
- return (*specialCase == 1) ? specialCase[1] : uc;
- }
- return uc + p->caseFoldDiff;
+ return uc + Traits::caseDiff(prop);
}
/*!
@@ -1479,11 +1457,11 @@ Q_DECL_CONST_FUNCTION static inline T toCaseFolded_helper(T uc)
by \a ucs4 if the character is uppercase or titlecase; otherwise returns
the character itself.
*/
-uint QChar::toLower(uint ucs4)
+uint QChar::toLower(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return ucs4;
- return toLowerCase_helper<uint>(ucs4);
+ return convertCase_helper<QUnicodeTables::LowercaseTraits>(ucs4);
}
/*!
@@ -1499,11 +1477,11 @@ uint QChar::toLower(uint ucs4)
by \a ucs4 if the character is lowercase or titlecase; otherwise returns
the character itself.
*/
-uint QChar::toUpper(uint ucs4)
+uint QChar::toUpper(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return ucs4;
- return toUpperCase_helper<uint>(ucs4);
+ return convertCase_helper<QUnicodeTables::UppercaseTraits>(ucs4);
}
/*!
@@ -1519,33 +1497,33 @@ uint QChar::toUpper(uint ucs4)
by \a ucs4 if the character is lowercase or uppercase; otherwise returns
the character itself.
*/
-uint QChar::toTitleCase(uint ucs4)
+uint QChar::toTitleCase(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return ucs4;
- return toTitleCase_helper<uint>(ucs4);
+ return convertCase_helper<QUnicodeTables::TitlecaseTraits>(ucs4);
}
static inline uint foldCase(const ushort *ch, const ushort *start)
{
- uint c = *ch;
- if (QChar(c).isLowSurrogate() && ch > start && QChar(*(ch - 1)).isHighSurrogate())
- c = QChar::surrogateToUcs4(*(ch - 1), c);
- return toCaseFolded_helper<uint>(c);
+ uint ucs4 = *ch;
+ if (QChar::isLowSurrogate(ucs4) && ch > start && QChar::isHighSurrogate(*(ch - 1)))
+ ucs4 = QChar::surrogateToUcs4(*(ch - 1), ucs4);
+ return convertCase_helper<QUnicodeTables::CasefoldTraits>(ucs4);
}
-static inline uint foldCase(uint ch, uint &last)
+static inline uint foldCase(uint ch, uint &last) Q_DECL_NOTHROW
{
- uint c = ch;
- if (QChar(c).isLowSurrogate() && QChar(last).isHighSurrogate())
- c = QChar::surrogateToUcs4(last, c);
+ uint ucs4 = ch;
+ if (QChar::isLowSurrogate(ucs4) && QChar::isHighSurrogate(last))
+ ucs4 = QChar::surrogateToUcs4(last, ucs4);
last = ch;
- return toCaseFolded_helper<uint>(c);
+ return convertCase_helper<QUnicodeTables::CasefoldTraits>(ucs4);
}
-static inline ushort foldCase(ushort ch)
+static inline ushort foldCase(ushort ch) Q_DECL_NOTHROW
{
- return toCaseFolded_helper<ushort>(ch);
+ return convertCase_helper<QUnicodeTables::CasefoldTraits>(ch);
}
/*!
@@ -1560,11 +1538,11 @@ static inline ushort foldCase(ushort ch)
Returns the case folded equivalent of the UCS-4-encoded character specified
by \a ucs4. For most Unicode characters this is the same as toLower().
*/
-uint QChar::toCaseFolded(uint ucs4)
+uint QChar::toCaseFolded(uint ucs4) Q_DECL_NOTHROW
{
if (ucs4 > LastValidCodePoint)
return ucs4;
- return toCaseFolded_helper<uint>(ucs4);
+ return convertCase_helper<QUnicodeTables::CasefoldTraits>(ucs4);
}
/*!