Add QUtf8StringView vs QLatin1StringView relational operators
... by using the new comparison helper macros. This allows to remove dummy comparison operators from tst_qstringapisymmetry. This is also a pre-requisite for a follow-up commit that introduces relational operators between QLatin1StringView and QByteArrayView. Task-number: QTBUG-117661 Task-number: QTBUG-108805 Change-Id: I5837b457a777fddff1071bc252982e68d004fa94 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
3a5ee774e8
commit
4c93115504
@ -1141,6 +1141,12 @@ template<bool UseChar8T>
|
|||||||
return QtPrivate::compareStrings(*this, other, cs);
|
return QtPrivate::compareStrings(*this, other, cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <bool UseChar8T>
|
||||||
|
[[nodiscard]] bool QBasicUtf8StringView<UseChar8T>::equal(QLatin1StringView other) const noexcept
|
||||||
|
{
|
||||||
|
return QtPrivate::equalStrings(*this, other);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// QAnyStringView inline members that require QString:
|
// QAnyStringView inline members that require QString:
|
||||||
//
|
//
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <QtCore/qstringfwd.h>
|
#include <QtCore/qstringfwd.h>
|
||||||
#include <QtCore/qarraydata.h> // for QContainerImplHelper
|
#include <QtCore/qarraydata.h> // for QContainerImplHelper
|
||||||
#include <QtCore/qbytearrayview.h>
|
#include <QtCore/qbytearrayview.h>
|
||||||
|
#include <QtCore/qcompare.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
@ -297,6 +298,8 @@ public:
|
|||||||
[[nodiscard]] int compare(QLatin1StringView other,
|
[[nodiscard]] int compare(QLatin1StringView other,
|
||||||
Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
|
Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
|
||||||
|
|
||||||
|
[[nodiscard]] bool equal(QLatin1StringView other) const noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
[[nodiscard]] static inline int compare(QBasicUtf8StringView lhs, QBasicUtf8StringView rhs) noexcept
|
[[nodiscard]] static inline int compare(QBasicUtf8StringView lhs, QBasicUtf8StringView rhs) noexcept
|
||||||
{
|
{
|
||||||
@ -327,6 +330,19 @@ private:
|
|||||||
{ return QBasicUtf8StringView::compare(lhs, rhs) > 0; }
|
{ return QBasicUtf8StringView::compare(lhs, rhs) > 0; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
friend bool
|
||||||
|
comparesEqual(const QBasicUtf8StringView &lhs, const QLatin1StringView &rhs) noexcept
|
||||||
|
{
|
||||||
|
return lhs.equal(rhs);
|
||||||
|
}
|
||||||
|
friend Qt::strong_ordering
|
||||||
|
compareThreeWay(const QBasicUtf8StringView &lhs, const QLatin1StringView &rhs) noexcept
|
||||||
|
{
|
||||||
|
const int res = lhs.compare(rhs);
|
||||||
|
return Qt::compareThreeWay(res, 0);
|
||||||
|
}
|
||||||
|
Q_DECLARE_STRONGLY_ORDERED(QBasicUtf8StringView, QLatin1StringView)
|
||||||
|
|
||||||
Q_ALWAYS_INLINE constexpr void verify([[maybe_unused]] qsizetype pos = 0,
|
Q_ALWAYS_INLINE constexpr void verify([[maybe_unused]] qsizetype pos = 0,
|
||||||
[[maybe_unused]] qsizetype n = 1) const
|
[[maybe_unused]] qsizetype n = 1) const
|
||||||
{
|
{
|
||||||
|
@ -78,7 +78,6 @@ MAKE_ALL(const char*, QUtf8StringView)
|
|||||||
MAKE_ALL(QUtf8StringView, QChar)
|
MAKE_ALL(QUtf8StringView, QChar)
|
||||||
MAKE_ALL(QUtf8StringView, char16_t)
|
MAKE_ALL(QUtf8StringView, char16_t)
|
||||||
MAKE_ALL(QUtf8StringView, QStringView)
|
MAKE_ALL(QUtf8StringView, QStringView)
|
||||||
MAKE_ALL(QUtf8StringView, QLatin1String)
|
|
||||||
|
|
||||||
#undef MAKE_ALL
|
#undef MAKE_ALL
|
||||||
#undef MAKE_RELOP
|
#undef MAKE_RELOP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user