Add missing QUtf8StringView relational operators
Add QU8SV vs QSV, QU8SV vs QChar, and QU8SV vs char16_t relational operators. This allows to get rid of the dummy relational operators in tst_qstringapisymmetry. Task-number: QTBUG-117661 Change-Id: If95d7418efd13c505ed0e3bef748b86ff55e623a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
e2e21bcb2d
commit
3d0eaf863e
|
|
@ -1141,12 +1141,29 @@ ushort QStringView::toUShort(bool *ok, int base) const
|
|||
// QUtf8StringView inline members that require QStringView:
|
||||
//
|
||||
|
||||
template <bool UseChar8T>
|
||||
int QBasicUtf8StringView<UseChar8T>::compare(QChar other, Qt::CaseSensitivity cs) const noexcept
|
||||
{
|
||||
return QtPrivate::compareStrings(*this, QStringView(&other, 1), cs);
|
||||
}
|
||||
|
||||
template <bool UseChar8T>
|
||||
int QBasicUtf8StringView<UseChar8T>::compare(QStringView other, Qt::CaseSensitivity cs) const noexcept
|
||||
{
|
||||
return QtPrivate::compareStrings(*this, other, cs);
|
||||
}
|
||||
|
||||
template <bool UseChar8T>
|
||||
[[nodiscard]] bool QBasicUtf8StringView<UseChar8T>::equal(QChar other) const noexcept
|
||||
{
|
||||
return QtPrivate::equalStrings(*this, QStringView(&other, 1));
|
||||
}
|
||||
|
||||
template <bool UseChar8T>
|
||||
[[nodiscard]] bool QBasicUtf8StringView<UseChar8T>::equal(QStringView other) const noexcept
|
||||
{
|
||||
return QtPrivate::equalStrings(*this, other);
|
||||
}
|
||||
|
||||
//
|
||||
// QUtf8StringView inline members that require QString, QL1SV or QBA:
|
||||
|
|
|
|||
|
|
@ -293,6 +293,8 @@ public:
|
|||
return QtPrivate::compareStrings(*this, other, cs);
|
||||
}
|
||||
|
||||
[[nodiscard]] int compare(QChar other,
|
||||
Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
|
||||
[[nodiscard]] int compare(QStringView other,
|
||||
Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
|
||||
[[nodiscard]] int compare(QLatin1StringView other,
|
||||
|
|
@ -300,6 +302,8 @@ public:
|
|||
[[nodiscard]] int compare(const QByteArray &other,
|
||||
Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
|
||||
|
||||
[[nodiscard]] bool equal(QChar other) const noexcept;
|
||||
[[nodiscard]] bool equal(QStringView other) const noexcept;
|
||||
[[nodiscard]] bool equal(QLatin1StringView other) const noexcept;
|
||||
[[nodiscard]] bool equal(const QByteArray &other) const noexcept;
|
||||
|
||||
|
|
@ -346,6 +350,28 @@ private:
|
|||
}
|
||||
Q_DECLARE_STRONGLY_ORDERED(QBasicUtf8StringView, QLatin1StringView)
|
||||
|
||||
friend bool
|
||||
comparesEqual(const QBasicUtf8StringView &lhs, const QStringView &rhs) noexcept
|
||||
{ return lhs.equal(rhs); }
|
||||
friend Qt::strong_ordering
|
||||
compareThreeWay(const QBasicUtf8StringView &lhs, const QStringView &rhs) noexcept
|
||||
{
|
||||
const int res = lhs.compare(rhs);
|
||||
return Qt::compareThreeWay(res, 0);
|
||||
}
|
||||
Q_DECLARE_STRONGLY_ORDERED(QBasicUtf8StringView, QStringView)
|
||||
|
||||
friend bool comparesEqual(const QBasicUtf8StringView &lhs, const QChar &rhs) noexcept
|
||||
{ return lhs.equal(rhs); }
|
||||
friend Qt::strong_ordering
|
||||
compareThreeWay(const QBasicUtf8StringView &lhs, const QChar &rhs) noexcept
|
||||
{
|
||||
const int res = lhs.compare(rhs);
|
||||
return Qt::compareThreeWay(res, 0);
|
||||
}
|
||||
Q_DECLARE_STRONGLY_ORDERED(QBasicUtf8StringView, QChar)
|
||||
Q_DECLARE_STRONGLY_ORDERED(QBasicUtf8StringView, char16_t)
|
||||
|
||||
#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
|
||||
friend bool
|
||||
comparesEqual(const QBasicUtf8StringView &lhs, const QByteArrayView &rhs) noexcept
|
||||
|
|
|
|||
|
|
@ -11,6 +11,14 @@
|
|||
\ingroup tools
|
||||
\ingroup string-processing
|
||||
|
||||
\compares strong
|
||||
\compareswith strong char16_t QChar {const char16_t *} QString QStringView \
|
||||
QLatin1StringView
|
||||
\endcompareswith
|
||||
\compareswith strong {const char *} QByteArray QByteArrayView
|
||||
The contents of byte arrays is interpreted as utf-8.
|
||||
\endcompareswith
|
||||
|
||||
A QUtf8StringView references a contiguous portion of a UTF-8
|
||||
string it does not own. It acts as an interface type to all kinds
|
||||
of UTF-8 string, without the need to construct a QString or
|
||||
|
|
|
|||
|
|
@ -68,10 +68,6 @@ MAKE_ALL(const char*, QChar)
|
|||
|
||||
MAKE_ALL(QChar, QByteArray)
|
||||
MAKE_ALL(QChar, const char*)
|
||||
MAKE_ALL(QChar, QUtf8StringView)
|
||||
|
||||
MAKE_ALL(QUtf8StringView, QChar)
|
||||
MAKE_ALL(QUtf8StringView, char16_t)
|
||||
|
||||
#undef MAKE_ALL
|
||||
#undef MAKE_RELOP
|
||||
|
|
@ -224,10 +220,8 @@ private Q_SLOTS:
|
|||
void compare_QStringView_QString() { compare_impl<QStringView, QString>(); }
|
||||
void compare_QStringView_QStringView_data() { compare_data(); }
|
||||
void compare_QStringView_QStringView() { compare_impl<QStringView, QStringView>(); }
|
||||
#ifdef NOT_YET_IMPLEMENTED
|
||||
void compare_QStringView_QUtf8StringView_data() { compare_data(); }
|
||||
void compare_QStringView_QUtf8StringView() { compare_impl<QStringView, QUtf8StringView>(); }
|
||||
#endif
|
||||
void compare_QStringView_QLatin1String_data() { compare_data(); }
|
||||
void compare_QStringView_QLatin1String() { compare_impl<QStringView, QLatin1String>(); }
|
||||
void compare_QStringView_QByteArray_data() { compare_data(); }
|
||||
|
|
|
|||
Loading…
Reference in New Issue