diff options
Diffstat (limited to 'src/corelib/tools/qchar.cpp')
-rw-r--r-- | src/corelib/tools/qchar.cpp | 311 |
1 files changed, 155 insertions, 156 deletions
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 33b2c0bc82..138c3a69ee 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -477,20 +477,36 @@ QT_BEGIN_NAMESPACE */ /*! + \fn bool QChar::isPrint() const + Returns true if the character is a printable character; otherwise returns false. This is any character not of category Other_*. Note that this gives no indication of whether the character is available in a particular font. */ -bool QChar::isPrint() const + +/*! + \overload + \since 5.0 + + Returns true if the UCS-4-encoded character specified by \a ucs4 is + a printable character; otherwise returns false. + This is any character not of category Other_*. + + Note that this gives no indication of whether the character is + available in a particular font. +*/ +bool QChar::isPrint(uint ucs4) { + if (ucs4 > UNICODE_LAST_CODEPOINT) + return false; const int test = FLAG(Other_Control) | FLAG(Other_Format) | FLAG(Other_Surrogate) | FLAG(Other_PrivateUse) | FLAG(Other_NotAssigned); - return !(FLAG(qGetProp(ucs)->category) & test); + return !(FLAG(qGetProp(ucs4)->category) & test); } /*! @@ -502,37 +518,72 @@ bool QChar::isPrint() const */ /*! - \internal + \fn bool QChar::isSpace(uint ucs4) \overload + \since 5.0 + + Returns true if the UCS-4-encoded character specified by \a ucs4 is + a separator character (Separator_* categories or certain code points + from Other_Control category); otherwise returns false. +*/ + +/*! + \internal */ -bool QChar::isSpace(ushort ucs2) +bool QT_FASTCALL QChar::isSpace_helper(uint ucs4) { + if (ucs4 > UNICODE_LAST_CODEPOINT) + return false; const int test = FLAG(Separator_Space) | FLAG(Separator_Line) | FLAG(Separator_Paragraph); - return FLAG(qGetProp(ucs2)->category) & test; + return FLAG(qGetProp(ucs4)->category) & test; } /*! + \fn bool QChar::isMark() const + Returns true if the character is a mark (Mark_* categories); otherwise returns false. See QChar::Category for more information regarding marks. */ -bool QChar::isMark() const + +/*! + \overload + \since 5.0 + + Returns true if the UCS-4-encoded character specified by \a ucs4 is + a mark (Mark_* categories); otherwise returns false. +*/ +bool QChar::isMark(uint ucs4) { + if (ucs4 > UNICODE_LAST_CODEPOINT) + return false; const int test = FLAG(Mark_NonSpacing) | FLAG(Mark_SpacingCombining) | FLAG(Mark_Enclosing); - return FLAG(qGetProp(ucs)->category) & test; + return FLAG(qGetProp(ucs4)->category) & test; } /*! + \fn bool QChar::isPunct() const + Returns true if the character is a punctuation mark (Punctuation_* categories); otherwise returns false. */ -bool QChar::isPunct() const + +/*! + \overload + \since 5.0 + + Returns true if the UCS-4-encoded character specified by \a ucs4 is + a punctuation mark (Punctuation_* categories); otherwise returns false. +*/ +bool QChar::isPunct(uint ucs4) { + if (ucs4 > UNICODE_LAST_CODEPOINT) + return false; const int test = FLAG(Punctuation_Connector) | FLAG(Punctuation_Dash) | FLAG(Punctuation_Open) | @@ -540,7 +591,32 @@ bool QChar::isPunct() const FLAG(Punctuation_InitialQuote) | FLAG(Punctuation_FinalQuote) | FLAG(Punctuation_Other); - return FLAG(qGetProp(ucs)->category) & test; + return FLAG(qGetProp(ucs4)->category) & test; +} + +/*! + \fn bool QChar::isSymbol() const + + Returns true if the character is a symbol (Symbol_* categories); + otherwise returns false. +*/ + +/*! + \overload + \since 5.0 + + Returns true if the UCS-4-encoded character specified by \a ucs4 is + a symbol (Symbol_* categories); otherwise returns false. +*/ +bool QChar::isSymbol(uint ucs4) +{ + if (ucs4 > UNICODE_LAST_CODEPOINT) + return false; + const int test = FLAG(Symbol_Math) | + FLAG(Symbol_Currency) | + FLAG(Symbol_Modifier) | + FLAG(Symbol_Other); + return FLAG(qGetProp(ucs4)->category) & test; } /*! @@ -551,17 +627,27 @@ bool QChar::isPunct() const */ /*! - \internal + \fn bool QChar::isLetter(uint ucs4) \overload + \since 5.0 + + Returns true if the UCS-4-encoded character specified by \a ucs4 is + a letter (Letter_* categories); otherwise returns false. +*/ + +/*! + \internal */ -bool QChar::isLetter(ushort ucs2) +bool QT_FASTCALL QChar::isLetter_helper(uint ucs4) { + if (ucs4 > UNICODE_LAST_CODEPOINT) + return false; const int test = FLAG(Letter_Uppercase) | FLAG(Letter_Lowercase) | FLAG(Letter_Titlecase) | FLAG(Letter_Modifier) | FLAG(Letter_Other); - return FLAG(qGetProp(ucs2)->category) & test; + return FLAG(qGetProp(ucs4)->category) & test; } /*! @@ -574,15 +660,27 @@ bool QChar::isLetter(ushort ucs2) */ /*! - \internal + \fn bool QChar::isNumber(uint ucs4) \overload + \since 5.0 + + Returns true if the UCS-4-encoded character specified by \a ucs4 is + a number (Number_* categories, not just 0-9); otherwise returns false. + + \sa isDigit() */ -bool QChar::isNumber(ushort ucs2) + +/*! + \internal +*/ +bool QT_FASTCALL QChar::isNumber_helper(uint ucs4) { + if (ucs4 > UNICODE_LAST_CODEPOINT) + return false; const int test = FLAG(Number_DecimalDigit) | FLAG(Number_Letter) | FLAG(Number_Other); - return FLAG(qGetProp(ucs2)->category) & test; + return FLAG(qGetProp(ucs4)->category) & test; } /*! @@ -593,11 +691,21 @@ bool QChar::isNumber(ushort ucs2) */ /*! - \internal + \fn bool QChar::isLetterOrNumber(uint ucs4) \overload + \since 5.0 + + Returns true if the UCS-4-encoded character specified by \a ucs4 is + a letter or number (Letter_* or Number_* categories); otherwise returns false. +*/ + +/*! + \internal */ -bool QChar::isLetterOrNumber(ushort ucs2) +bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) { + if (ucs4 > UNICODE_LAST_CODEPOINT) + return false; const int test = FLAG(Letter_Uppercase) | FLAG(Letter_Lowercase) | FLAG(Letter_Titlecase) | @@ -606,7 +714,7 @@ bool QChar::isLetterOrNumber(ushort ucs2) FLAG(Number_DecimalDigit) | FLAG(Number_Letter) | FLAG(Number_Other); - return FLAG(qGetProp(ucs2)->category) & test; + return FLAG(qGetProp(ucs4)->category) & test; } /*! @@ -614,29 +722,20 @@ bool QChar::isLetterOrNumber(ushort ucs2) Returns true if the character is a decimal digit (Number_DecimalDigit); otherwise returns false. + + \sa isNumber() */ /*! - \internal + \fn bool QChar::isDigit(uint ucs4) \overload -*/ -bool QChar::isDigit(ushort ucs2) -{ - return (qGetProp(ucs2)->category == Number_DecimalDigit); -} + \since 5.0 -/*! - Returns true if the character is a symbol (Symbol_* categories); - otherwise returns false. + Returns true if the UCS-4-encoded character specified by \a ucs4 is + a decimal digit (Number_DecimalDigit); otherwise returns false. + + \sa isNumber() */ -bool QChar::isSymbol() const -{ - const int test = FLAG(Symbol_Math) | - FLAG(Symbol_Currency) | - FLAG(Symbol_Modifier) | - FLAG(Symbol_Other); - return FLAG(qGetProp(ucs)->category) & test; -} /*! \fn bool QChar::isHighSurrogate() const @@ -714,16 +813,6 @@ bool QChar::isSymbol() const /*! \overload - Returns the numeric value of the digit, specified by the UCS-2-encoded - character, \a ucs2, or -1 if the character is not a digit. -*/ -int QChar::digitValue(ushort ucs2) -{ - return qGetProp(ucs2)->digitValue; -} - -/*! - \overload 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. */ @@ -752,16 +841,6 @@ QChar::Category QChar::category(uint ucs4) } /*! - \overload - Returns the category of the UCS-2-encoded character specified by \a ucs2. -*/ -QChar::Category QChar::category(ushort ucs2) -{ - return (QChar::Category) qGetProp(ucs2)->category; -} - - -/*! \fn QChar::Direction QChar::direction() const Returns the character's direction. @@ -779,15 +858,6 @@ QChar::Direction QChar::direction(uint ucs4) } /*! - \overload - Returns the direction of the UCS-2-encoded character specified by \a ucs2. -*/ -QChar::Direction QChar::direction(ushort ucs2) -{ - return (QChar::Direction) qGetProp(ucs2)->direction; -} - -/*! \fn QChar::Joining QChar::joining() const Returns information about the joining properties of the character @@ -807,26 +877,32 @@ QChar::Joining QChar::joining(uint ucs4) } /*! - \overload - Returns information about the joining properties of the UCS-2-encoded - character specified by \a ucs2 (needed for certain languages such as Arabic). -*/ -QChar::Joining QChar::joining(ushort ucs2) -{ - return (QChar::Joining) qGetProp(ucs2)->joining; -} + \fn bool QChar::hasMirrored() const -/*! Returns true if the character should be reversed if the text direction is reversed; otherwise returns false. - Same as (ch.mirroredChar() != ch). + A bit faster equivalent of (ch.mirroredChar() != ch). \sa mirroredChar() */ -bool QChar::hasMirrored() const + +/*! + \overload + \since 5.0 + + Returns true if the UCS-4-encoded character specified by \a ucs4 + should be reversed if the text direction is reversed; otherwise returns false. + + A bit faster equivalent of (QChar::mirroredChar(ucs4) != ucs4). + + \sa mirroredChar() +*/ +bool QChar::hasMirrored(uint ucs4) { - return qGetProp(ucs)->mirrorDiff != 0; + if (ucs4 > UNICODE_LAST_CODEPOINT) + return false; + return qGetProp(ucs4)->mirrorDiff != 0; } /*! @@ -879,18 +955,6 @@ uint QChar::mirroredChar(uint ucs4) return ucs4 + qGetProp(ucs4)->mirrorDiff; } -/*! - \overload - Returns the mirrored character if the UCS-2-encoded character specified - by \a ucs2 is a mirrored character; otherwise returns the character itself. - - \sa hasMirrored() -*/ -ushort QChar::mirroredChar(ushort ucs2) -{ - return ucs2 + qGetProp(ucs2)->mirrorDiff; -} - // constants for Hangul (de)composition, see UAX #15 enum { @@ -939,7 +1003,7 @@ static const unsigned short * QT_FASTCALL decompositionHelper */ QString QChar::decomposition() const { - return decomposition(ucs); + return QChar::decomposition(ucs); } /*! @@ -957,13 +1021,11 @@ QString QChar::decomposition(uint ucs4) } /*! + \fn QChar::Decomposition QChar::decompositionTag() const + Returns the tag defining the composition of the character. Returns QChar::NoDecomposition if no decomposition exists. */ -QChar::Decomposition QChar::decompositionTag() const -{ - return decompositionTag(ucs); -} /*! \overload @@ -1004,16 +1066,6 @@ unsigned char QChar::combiningClass(uint ucs4) } /*! - \overload - Returns the combining class for the UCS-2-encoded character specified by - \a ucs2, as defined in the Unicode standard. -*/ -unsigned char QChar::combiningClass(ushort ucs2) -{ - return (unsigned char) qGetProp(ucs2)->combiningClass; -} - -/*! \fn QChar::UnicodeVersion QChar::unicodeVersion() const Returns the Unicode version that introduced this character. @@ -1032,16 +1084,6 @@ QChar::UnicodeVersion QChar::unicodeVersion(uint ucs4) } /*! - \overload - Returns the Unicode version that introduced the character specified in - its UCS-2-encoded form as \a ucs2. -*/ -QChar::UnicodeVersion QChar::unicodeVersion(ushort ucs2) -{ - return (QChar::UnicodeVersion) qGetProp(ucs2)->unicodeVersion; -} - -/*! Returns the most recent supported Unicode version. */ QChar::UnicodeVersion QChar::currentUnicodeVersion() @@ -1119,17 +1161,6 @@ uint QChar::toLower(uint ucs4) } /*! - \overload - Returns the lowercase equivalent of the UCS-2-encoded character specified - by \a ucs2 if the character is uppercase or titlecase; otherwise returns - the character itself. -*/ -ushort QChar::toLower(ushort ucs2) -{ - return toLowerCase_helper<ushort>(ucs2); -} - -/*! \fn QChar QChar::toUpper() const Returns the uppercase equivalent if the character is lowercase or titlecase; @@ -1150,17 +1181,6 @@ uint QChar::toUpper(uint ucs4) } /*! - \overload - Returns the uppercase equivalent of the UCS-2-encoded character specified - by \a ucs2 if the character is lowercase or titlecase; otherwise returns - the character itself. -*/ -ushort QChar::toUpper(ushort ucs2) -{ - return toUpperCase_helper<ushort>(ucs2); -} - -/*! \fn QChar QChar::toTitleCase() const Returns the title case equivalent if the character is lowercase or uppercase; @@ -1180,17 +1200,6 @@ uint QChar::toTitleCase(uint ucs4) return toTitleCase_helper<uint>(ucs4); } -/*! - \overload - Returns the title case equivalent of the UCS-2-encoded character specified - by \a ucs2 if the character is lowercase or uppercase; otherwise returns - the character itself. -*/ -ushort QChar::toTitleCase(ushort ucs2) -{ - return toTitleCase_helper<ushort>(ucs2); -} - static inline uint foldCase(const ushort *ch, const ushort *start) { uint c = *ch; @@ -1233,16 +1242,6 @@ uint QChar::toCaseFolded(uint ucs4) } /*! - \overload - Returns the case folded equivalent of the UCS-2-encoded character specified - by \a ucs2. For most Unicode characters this is the same as toLowerCase(). -*/ -ushort QChar::toCaseFolded(ushort ucs2) -{ - return toCaseFolded_helper<ushort>(ucs2); -} - -/*! \fn char QChar::toLatin1() const Returns the Latin-1 character equivalent to the QChar, or 0. This |