diff options
Diffstat (limited to 'src/corelib/tools/qstring.h')
-rw-r--r-- | src/corelib/tools/qstring.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 0a0a609728..01ddf669f5 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -316,6 +316,7 @@ public: inline bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; inline bool contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + inline bool contains(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; inline bool contains(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; int count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; int count(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; @@ -460,9 +461,24 @@ public: const ushort *utf16() const; +#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) + QByteArray toLatin1() const & Q_REQUIRED_RESULT + { return toLatin1_helper(*this); } + QByteArray toLatin1() && Q_REQUIRED_RESULT + { return toLatin1_helper_inplace(*this); } + QByteArray toUtf8() const & Q_REQUIRED_RESULT + { return toUtf8_helper(*this); } + QByteArray toUtf8() && Q_REQUIRED_RESULT + { return toUtf8_helper(*this); } + QByteArray toLocal8Bit() const & Q_REQUIRED_RESULT + { return toLocal8Bit_helper(constData(), size()); } + QByteArray toLocal8Bit() && Q_REQUIRED_RESULT + { return toLocal8Bit_helper(constData(), size()); } +#else QByteArray toLatin1() const Q_REQUIRED_RESULT; QByteArray toUtf8() const Q_REQUIRED_RESULT; QByteArray toLocal8Bit() const Q_REQUIRED_RESULT; +#endif QVector<uint> toUcs4() const Q_REQUIRED_RESULT; // note - this are all inline so we can benefit from strlen() compile time optimizations @@ -717,6 +733,11 @@ private: static Data *fromAscii_helper(const char *str, int size = -1); static QString fromUtf8_helper(const char *str, int size); static QString fromLocal8Bit_helper(const char *, int size); + static QByteArray toLatin1_helper(const QString &); + static QByteArray toLatin1_helper(const QChar *data, int size); + static QByteArray toLatin1_helper_inplace(QString &); + static QByteArray toUtf8_helper(const QString &); + static QByteArray toLocal8Bit_helper(const QChar *data, int size); static int toUcs4_helper(const ushort *uc, int length, uint *out); void replace_helper(uint *indices, int nIndices, int blen, const QChar *after, int alen); friend class QCharRef; @@ -969,6 +990,8 @@ inline bool QString::contains(const QString &s, Qt::CaseSensitivity cs) const { return indexOf(s, 0, cs) != -1; } inline bool QString::contains(const QStringRef &s, Qt::CaseSensitivity cs) const { return indexOf(s, 0, cs) != -1; } +inline bool QString::contains(QLatin1String s, Qt::CaseSensitivity cs) const +{ return indexOf(s, 0, cs) != -1; } inline bool QString::contains(QChar c, Qt::CaseSensitivity cs) const { return indexOf(c, 0, cs) != -1; } |