diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-07-29 18:06:51 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2014-08-19 03:39:47 +0200 |
commit | 19dd9a0ebd570ac134e115f2339912a1015ecde5 (patch) | |
tree | a6eb385853c1c83e3e2e7269b38b118e8176af68 /src/corelib/tools/qstring.h | |
parent | 3888f5a251d6230cc290ec0ada211a6b45307615 (diff) |
Add rvalue-ref qualified QString::to{Upper,Lower,CaseFolded}
This is even more common than the QByteArray equivalents.
Qt Qt Creator
const & && const & &&
toLower 71 50 45 26
toUpper 35 8 46 35
Change-Id: I8b797d2321b22ce414c23656c5f1709ac649c423
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/tools/qstring.h')
-rw-r--r-- | src/corelib/tools/qstring.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index dfb98ffaa2..a6e13e37b5 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -377,9 +377,34 @@ public: QString leftJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const Q_REQUIRED_RESULT; QString rightJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const Q_REQUIRED_RESULT; +#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) +# if defined(Q_CC_GNU) + // required due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61941 +# pragma push_macro("Q_REQUIRED_RESULT") +# undef Q_REQUIRED_RESULT +# define Q_REQUIRED_RESULT +# define Q_REQUIRED_RESULT_pushed +# endif + QString toLower() const & Q_REQUIRED_RESULT + { return toLower_helper(*this); } + QString toLower() && Q_REQUIRED_RESULT + { return toLower_helper(*this); } + QString toUpper() const & Q_REQUIRED_RESULT + { return toUpper_helper(*this); } + QString toUpper() && Q_REQUIRED_RESULT + { return toUpper_helper(*this); } + QString toCaseFolded() const & Q_REQUIRED_RESULT + { return toCaseFolded_helper(*this); } + QString toCaseFolded() && Q_REQUIRED_RESULT + { return toCaseFolded_helper(*this); } +# ifdef Q_REQUIRED_RESULT_pushed +# pragma pop_macro("Q_REQUIRED_RESULT") +# endif +#else QString toLower() const Q_REQUIRED_RESULT; QString toUpper() const Q_REQUIRED_RESULT; QString toCaseFolded() const Q_REQUIRED_RESULT; +#endif QString trimmed() const Q_REQUIRED_RESULT; QString simplified() const Q_REQUIRED_RESULT; @@ -742,6 +767,12 @@ private: Qt::CaseSensitivity cs = Qt::CaseSensitive); static int localeAwareCompare_helper(const QChar *data1, int length1, const QChar *data2, int length2); + static QString toLower_helper(const QString &str); + static QString toLower_helper(QString &str); + static QString toUpper_helper(const QString &str); + static QString toUpper_helper(QString &str); + static QString toCaseFolded_helper(const QString &str); + static QString toCaseFolded_helper(QString &str); static Data *fromLatin1_helper(const char *str, int size = -1); static Data *fromAscii_helper(const char *str, int size = -1); static QString fromUtf8_helper(const char *str, int size); |