*/
/*!
+ \fn int QChar::digitValue() const
+
Returns the numeric value of the digit, or -1 if the character is not a digit.
*/
-int QChar::digitValue() const
-{
- return qGetProp(ucs)->digitValue;
-}
/*!
\overload
}
/*!
+ \fn QChar::Category QChar::category() const
+
Returns the character's category.
*/
-QChar::Category QChar::category() const
-{
- return (QChar::Category) qGetProp(ucs)->category;
-}
/*!
\overload
/*!
+ \fn QChar::Direction QChar::direction() const
+
Returns the character's direction.
*/
-QChar::Direction QChar::direction() const
-{
- return (QChar::Direction) qGetProp(ucs)->direction;
-}
/*!
\overload
}
/*!
+ \fn QChar::Joining QChar::joining() const
+
Returns information about the joining properties of the character
(needed for certain languages such as Arabic).
*/
-QChar::Joining QChar::joining() const
-{
- return (QChar::Joining) qGetProp(ucs)->joining;
-}
/*!
\overload
*/
/*!
+ \fn QChar QChar::mirroredChar() const
+
Returns the mirrored character if this character is a mirrored
character; otherwise returns the character itself.
\sa hasMirrored()
*/
-QChar QChar::mirroredChar() const
-{
- return ucs + qGetProp(ucs)->mirrorDiff;
-}
/*!
\overload
}
/*!
+ \fn unsigned char QChar::combiningClass() const
+
Returns the combining class for the character as defined in the
Unicode standard. This is mainly useful as a positioning hint for
marks attached to a base character.
The Qt text rendering engine uses this information to correctly
position non-spacing marks around a base character.
*/
-unsigned char QChar::combiningClass() const
-{
- return (unsigned char) qGetProp(ucs)->combiningClass;
-}
/*!
\overload
}
/*!
+ \fn QChar::UnicodeVersion QChar::unicodeVersion() const
+
Returns the Unicode version that introduced this character.
*/
-QChar::UnicodeVersion QChar::unicodeVersion() const
-{
- return (QChar::UnicodeVersion) qGetProp(ucs)->unicodeVersion;
-}
/*!
\overload
return UNICODE_DATA_VERSION;
}
+
+template <typename T>
+static inline T toLowerCase_helper(T uc)
+{
+ const QUnicodeTables::Properties *p = qGetProp(uc);
+ if (!p->lowerCaseSpecial)
+ return uc + p->lowerCaseDiff;
+ return uc;
+}
+
+template <typename T>
+static inline T toUpperCase_helper(T uc)
+{
+ const QUnicodeTables::Properties *p = qGetProp(uc);
+ if (!p->upperCaseSpecial)
+ return uc + p->upperCaseDiff;
+ return uc;
+}
+
+template <typename T>
+static inline T toTitleCase_helper(T uc)
+{
+ const QUnicodeTables::Properties *p = qGetProp(uc);
+ if (!p->titleCaseSpecial)
+ return uc + p->titleCaseDiff;
+ return uc;
+}
+
+template <typename T>
+static inline T toCaseFolded_helper(T uc)
+{
+ return uc + qGetProp(uc)->caseFoldDiff;
+}
+
/*!
+ \fn QChar QChar::toLower() const
+
Returns the lowercase equivalent if the character is uppercase or titlecase;
otherwise returns the character itself.
*/
-QChar QChar::toLower() const
-{
- const QUnicodeTables::Properties *p = qGetProp(ucs);
- if (!p->lowerCaseSpecial)
- return ucs + p->lowerCaseDiff;
- return ucs;
-}
/*!
\overload
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return ucs4;
- const QUnicodeTables::Properties *p = qGetProp(ucs4);
- if (!p->lowerCaseSpecial)
- return ucs4 + p->lowerCaseDiff;
- return ucs4;
+ return toLowerCase_helper<uint>(ucs4);
}
/*!
*/
ushort QChar::toLower(ushort ucs2)
{
- const QUnicodeTables::Properties *p = qGetProp(ucs2);
- if (!p->lowerCaseSpecial)
- return ucs2 + p->lowerCaseDiff;
- return ucs2;
+ return toLowerCase_helper<ushort>(ucs2);
}
/*!
+ \fn QChar QChar::toUpper() const
+
Returns the uppercase equivalent if the character is lowercase or titlecase;
otherwise returns the character itself.
*/
-QChar QChar::toUpper() const
-{
- const QUnicodeTables::Properties *p = qGetProp(ucs);
- if (!p->upperCaseSpecial)
- return ucs + p->upperCaseDiff;
- return ucs;
-}
/*!
\overload
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return ucs4;
- const QUnicodeTables::Properties *p = qGetProp(ucs4);
- if (!p->upperCaseSpecial)
- return ucs4 + p->upperCaseDiff;
- return ucs4;
+ return toUpperCase_helper<uint>(ucs4);
}
/*!
*/
ushort QChar::toUpper(ushort ucs2)
{
- const QUnicodeTables::Properties *p = qGetProp(ucs2);
- if (!p->upperCaseSpecial)
- return ucs2 + p->upperCaseDiff;
- return ucs2;
+ return toUpperCase_helper<ushort>(ucs2);
}
/*!
+ \fn QChar QChar::toTitleCase() const
+
Returns the title case equivalent if the character is lowercase or uppercase;
otherwise returns the character itself.
*/
-QChar QChar::toTitleCase() const
-{
- const QUnicodeTables::Properties *p = qGetProp(ucs);
- if (!p->titleCaseSpecial)
- return ucs + p->titleCaseDiff;
- return ucs;
-}
/*!
\overload
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return ucs4;
- const QUnicodeTables::Properties *p = qGetProp(ucs4);
- if (!p->titleCaseSpecial)
- return ucs4 + p->titleCaseDiff;
- return ucs4;
+ return toTitleCase_helper<uint>(ucs4);
}
/*!
*/
ushort QChar::toTitleCase(ushort ucs2)
{
- const QUnicodeTables::Properties *p = qGetProp(ucs2);
- if (!p->titleCaseSpecial)
- return ucs2 + p->titleCaseDiff;
- return ucs2;
+ return toTitleCase_helper<ushort>(ucs2);
}
-
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 *ch + qGetProp(c)->caseFoldDiff;
+ return toCaseFolded_helper<uint>(c);
}
static inline uint foldCase(uint ch, uint &last)
if (QChar(c).isLowSurrogate() && QChar(last).isHighSurrogate())
c = QChar::surrogateToUcs4(last, c);
last = ch;
- return ch + qGetProp(c)->caseFoldDiff;
+ return toCaseFolded_helper<uint>(c);
}
static inline ushort foldCase(ushort ch)
{
- return ch + qGetProp(ch)->caseFoldDiff;
+ return toCaseFolded_helper<ushort>(ch);
}
/*!
- Returns the case folded equivalent of the character. For most Unicode characters this
- is the same as toLowerCase().
+ \fn QChar QChar::toCaseFolded() const
+
+ Returns the case folded equivalent of the character.
+ For most Unicode characters this is the same as toLowerCase().
*/
-QChar QChar::toCaseFolded() const
-{
- return ucs + qGetProp(ucs)->caseFoldDiff;
-}
/*!
\overload
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return ucs4;
- return ucs4 + qGetProp(ucs4)->caseFoldDiff;
+ return toCaseFolded_helper<uint>(ucs4);
}
/*!
*/
ushort QChar::toCaseFolded(ushort ucs2)
{
- return ucs2 + qGetProp(ucs2)->caseFoldDiff;
+ return toCaseFolded_helper<ushort>(ucs2);
}
/*!
};
// ****** WHEN ADDING FUNCTIONS, CONSIDER ADDING TO QCharRef TOO
- Category category() const;
- Direction direction() const;
- Joining joining() const;
+ inline Category category() const { return QChar::category(ucs); }
+ inline Direction direction() const { return QChar::direction(ucs); }
+ inline Joining joining() const { return QChar::joining(ucs); }
bool hasMirrored() const;
- unsigned char combiningClass() const;
+ inline unsigned char combiningClass() const { return QChar::combiningClass(ucs); }
- QChar mirroredChar() const;
+ inline QChar mirroredChar() const { return QChar::mirroredChar(ucs); }
QString decomposition() const;
Decomposition decompositionTag() const;
- int digitValue() const;
- QChar toLower() const;
- QChar toUpper() const;
- QChar toTitleCase() const;
- QChar toCaseFolded() const;
+ inline int digitValue() const { return QChar::digitValue(ucs); }
+ inline QChar toLower() const { return QChar::toLower(ucs); }
+ inline QChar toUpper() const { return QChar::toUpper(ucs); }
+ inline QChar toTitleCase() const { return QChar::toTitleCase(ucs); }
+ inline QChar toCaseFolded() const { return QChar::toCaseFolded(ucs); }
- UnicodeVersion unicodeVersion() const;
+ inline UnicodeVersion unicodeVersion() const { return QChar::unicodeVersion(ucs); }
inline char toAscii() const;
inline char toLatin1() const;