Move CasexTraits from qstring.cpp to qunicodetables_p.h

and implement TitlecaseTraits as well,
to be re-used in the following commit.

Change-Id: I5c0bff42fe3b9bc9c2454cc16916cc2be87f604f
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
This commit is contained in:
Konstantin Ritt 2015-11-05 11:03:28 +04:00
parent 4d5b57825a
commit c267646867
3 changed files with 64 additions and 24 deletions

View File

@ -5666,30 +5666,6 @@ QString QString::rightJustified(int width, QChar fill, bool truncate) const
*/
namespace QUnicodeTables {
struct LowercaseTraits
{
static signed short caseDiff(const Properties *prop)
{ return prop->lowerCaseDiff; }
static bool caseSpecial(const Properties *prop)
{ return prop->lowerCaseSpecial; }
};
struct UppercaseTraits
{
static signed short caseDiff(const Properties *prop)
{ return prop->upperCaseDiff; }
static bool caseSpecial(const Properties *prop)
{ return prop->upperCaseSpecial; }
};
struct CasefoldTraits
{
static signed short caseDiff(const Properties *prop)
{ return prop->caseFoldDiff; }
static bool caseSpecial(const Properties *prop)
{ return prop->caseFoldSpecial; }
};
template <typename Traits, typename T>
Q_NEVER_INLINE
static QString detachAndConvertCase(T &str, QStringIterator it)

View File

@ -82,6 +82,38 @@ struct Properties {
Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) Q_DECL_NOTHROW;
Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) Q_DECL_NOTHROW;
struct LowercaseTraits
{
static inline signed short caseDiff(const Properties *prop)
{ return prop->lowerCaseDiff; }
static inline bool caseSpecial(const Properties *prop)
{ return prop->lowerCaseSpecial; }
};
struct UppercaseTraits
{
static inline signed short caseDiff(const Properties *prop)
{ return prop->upperCaseDiff; }
static inline bool caseSpecial(const Properties *prop)
{ return prop->upperCaseSpecial; }
};
struct TitlecaseTraits
{
static inline signed short caseDiff(const Properties *prop)
{ return prop->titleCaseDiff; }
static inline bool caseSpecial(const Properties *prop)
{ return prop->titleCaseSpecial; }
};
struct CasefoldTraits
{
static inline signed short caseDiff(const Properties *prop)
{ return prop->caseFoldDiff; }
static inline bool caseSpecial(const Properties *prop)
{ return prop->caseFoldSpecial; }
};
enum GraphemeBreakClass {
GraphemeBreak_Other,
GraphemeBreak_CR,

View File

@ -765,6 +765,38 @@ static const char *property_string =
"};\n\n"
"Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) Q_DECL_NOTHROW;\n"
"Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) Q_DECL_NOTHROW;\n"
"\n"
"struct LowercaseTraits\n"
"{\n"
" static inline signed short caseDiff(const Properties *prop)\n"
" { return prop->lowerCaseDiff; }\n"
" static inline bool caseSpecial(const Properties *prop)\n"
" { return prop->lowerCaseSpecial; }\n"
"};\n"
"\n"
"struct UppercaseTraits\n"
"{\n"
" static inline signed short caseDiff(const Properties *prop)\n"
" { return prop->upperCaseDiff; }\n"
" static inline bool caseSpecial(const Properties *prop)\n"
" { return prop->upperCaseSpecial; }\n"
"};\n"
"\n"
"struct TitlecaseTraits\n"
"{\n"
" static inline signed short caseDiff(const Properties *prop)\n"
" { return prop->titleCaseDiff; }\n"
" static inline bool caseSpecial(const Properties *prop)\n"
" { return prop->titleCaseSpecial; }\n"
"};\n"
"\n"
"struct CasefoldTraits\n"
"{\n"
" static inline signed short caseDiff(const Properties *prop)\n"
" { return prop->caseFoldDiff; }\n"
" static inline bool caseSpecial(const Properties *prop)\n"
" { return prop->caseFoldSpecial; }\n"
"};\n"
"\n";
static const char *methods =