diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2021-06-02 16:16:39 +0200 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2021-06-11 20:25:05 +0200 |
commit | 1c164ec7f21a78025475c561a70b94d1e3dd6bb6 (patch) | |
tree | 518f8fe967e9675e837df34dac6fde96472e0fc1 /src/corelib/text/qstring.h | |
parent | aabdf87657e6f14e7f6713702f97a2129890611e (diff) |
QLatin1String: Add overloads taking QLatin1Char
Without the overloads using QLatin1Char in QL1S member functions results
in the QL1Char being converted to QChar and QL1String being converted to
QString.
Change-Id: Ic19545539a207f025a6293f0b2d929de475dc166
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text/qstring.h')
-rw-r--r-- | src/corelib/text/qstring.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 5e215625c6..e17bcbfbf6 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -117,6 +117,8 @@ public: { return isEmpty() || front() == c ? size() - 1 : uchar(m_data[0]) - c.unicode() ; } [[nodiscard]] int compare(QChar c, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::compareStrings(*this, QStringView(&c, 1), cs); } + [[nodiscard]] int compare(QLatin1Char c, Qt::CaseSensitivity cs) const noexcept + { char ch = c.toLatin1(); return QtPrivate::compareStrings(*this, QLatin1String(&ch, 1), cs); } [[nodiscard]] bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::startsWith(*this, s, cs); } @@ -126,6 +128,8 @@ public: { return !isEmpty() && front() == c; } [[nodiscard]] inline bool startsWith(QChar c, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::startsWith(*this, QStringView(&c, 1), cs); } + [[nodiscard]] inline bool startsWith(QLatin1Char c, Qt::CaseSensitivity cs) const noexcept + { char ch = c.toLatin1(); return QtPrivate::startsWith(*this, QLatin1String(&ch, 1), cs); } [[nodiscard]] bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::endsWith(*this, s, cs); } @@ -135,6 +139,8 @@ public: { return !isEmpty() && back() == c; } [[nodiscard]] inline bool endsWith(QChar c, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::endsWith(*this, QStringView(&c, 1), cs); } + [[nodiscard]] inline bool endsWith(QLatin1Char c, Qt::CaseSensitivity cs) const noexcept + { char ch = c.toLatin1(); return QtPrivate::endsWith(*this, QLatin1String(&ch, 1), cs); } [[nodiscard]] qsizetype indexOf(QStringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::findString(*this, from, s, cs); } @@ -142,6 +148,8 @@ public: { return QtPrivate::findString(*this, from, s, cs); } [[nodiscard]] qsizetype indexOf(QChar c, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::findString(*this, from, QStringView(&c, 1), cs); } + [[nodiscard]] qsizetype indexOf(QLatin1Char c, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept + { char ch = c.toLatin1(); return QtPrivate::findString(*this, from, QLatin1String(&ch, 1), cs); } [[nodiscard]] bool contains(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return indexOf(s, 0, cs) != -1; } @@ -149,6 +157,8 @@ public: { return indexOf(s, 0, cs) != -1; } [[nodiscard]] inline bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return indexOf(QStringView(&c, 1), 0, cs) != -1; } + [[nodiscard]] inline bool contains(QLatin1Char c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept + { char ch = c.toLatin1(); return indexOf(QLatin1String(&ch, 1), 0, cs) != -1; } [[nodiscard]] qsizetype lastIndexOf(QStringView s, qsizetype from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::lastIndexOf(*this, from, s, cs); } @@ -156,6 +166,8 @@ public: { return QtPrivate::lastIndexOf(*this, from, s, cs); } [[nodiscard]] qsizetype lastIndexOf(QChar c, qsizetype from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::lastIndexOf(*this, from, QStringView(&c, 1), cs); } + [[nodiscard]] qsizetype lastIndexOf(QLatin1Char c, qsizetype from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept + { char ch = c.toLatin1(); return QtPrivate::lastIndexOf(*this, from, QLatin1String(&ch, 1), cs); } using value_type = const char; using reference = value_type&; |