diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2020-03-11 01:00:56 +0100 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-03-11 15:34:21 +0100 |
commit | 865afac25036d58b18794384e37d42931b2164c5 (patch) | |
tree | e18d31138f1a8b9200764fd3648e58b9dd6b124f /src/corelib/text/qstring.h | |
parent | 01bacdf7abb071198d843acdfb22ce1701766be8 (diff) | |
parent | 52de905d0ec6159d3a1e7ad63fed018b5c6973d2 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: Ibee5acec72a1a1769d4bc5f23f56c7dc8d4cf3cb
Diffstat (limited to 'src/corelib/text/qstring.h')
-rw-r--r-- | src/corelib/text/qstring.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index f4d6fc24a5..d5101b7ff3 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -110,6 +110,15 @@ public: Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QLatin1Char front() const { return at(0); } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QLatin1Char back() const { return at(size() - 1); } + Q_REQUIRED_RESULT int compare(QStringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept + { return QtPrivate::compareStrings(*this, other, cs); } + Q_REQUIRED_RESULT int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept + { return QtPrivate::compareStrings(*this, other, cs); } + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR int compare(QChar c) const noexcept + { return isEmpty() || front() == c ? size() - 1 : uchar(m_data[0]) - c.unicode() ; } + Q_REQUIRED_RESULT int compare(QChar c, Qt::CaseSensitivity cs) const noexcept + { return QtPrivate::compareStrings(*this, QStringView(&c, 1), cs); } + Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::startsWith(*this, s, cs); } Q_REQUIRED_RESULT bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept @@ -232,6 +241,8 @@ Q_DECL_CONSTEXPR bool QtPrivate::isLatin1(QLatin1String) noexcept // // QStringView members that require QLatin1String: // +int QStringView::compare(QLatin1String s, Qt::CaseSensitivity cs) const noexcept +{ return QtPrivate::compareStrings(*this, s, cs); } bool QStringView::startsWith(QLatin1String s, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::startsWith(*this, s, cs); } bool QStringView::endsWith(QLatin1String s, Qt::CaseSensitivity cs) const noexcept @@ -729,6 +740,8 @@ public: #endif int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; inline int compare(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + int compare(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept + { return compare(QStringView{&ch, 1}, cs); } static inline int compare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept @@ -1615,6 +1628,8 @@ public: int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + int compare(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept + { return QtPrivate::compareStrings(*this, QStringView(&c, 1), cs); } int compare(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; #if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII) int compare(const QByteArray &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |