diff --git a/src/corelib/text/qlatin1stringview.h b/src/corelib/text/qlatin1stringview.h index 4a1cd9774bf..e46bcad3281 100644 --- a/src/corelib/text/qlatin1stringview.h +++ b/src/corelib/text/qlatin1stringview.h @@ -312,28 +312,9 @@ private: public: #if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII) - QT_ASCII_CAST_WARN inline bool operator==(const char *s) const; - QT_ASCII_CAST_WARN inline bool operator!=(const char *s) const; - QT_ASCII_CAST_WARN inline bool operator<(const char *s) const; - QT_ASCII_CAST_WARN inline bool operator>(const char *s) const; - QT_ASCII_CAST_WARN inline bool operator<=(const char *s) const; - QT_ASCII_CAST_WARN inline bool operator>=(const char *s) const; - - QT_ASCII_CAST_WARN inline bool operator==(const QByteArray &s) const; - QT_ASCII_CAST_WARN inline bool operator!=(const QByteArray &s) const; - QT_ASCII_CAST_WARN inline bool operator<(const QByteArray &s) const; - QT_ASCII_CAST_WARN inline bool operator>(const QByteArray &s) const; - QT_ASCII_CAST_WARN inline bool operator<=(const QByteArray &s) const; - QT_ASCII_CAST_WARN inline bool operator>=(const QByteArray &s) const; - Q_DECLARE_STRONGLY_ORDERED(QLatin1StringView, QByteArrayView, QT_ASCII_CAST_WARN) - - QT_ASCII_CAST_WARN friend bool operator==(const char *s1, QLatin1StringView s2) { return compare_helper(s2, s1) == 0; } - QT_ASCII_CAST_WARN friend bool operator!=(const char *s1, QLatin1StringView s2) { return compare_helper(s2, s1) != 0; } - QT_ASCII_CAST_WARN friend bool operator< (const char *s1, QLatin1StringView s2) { return compare_helper(s2, s1) > 0; } - QT_ASCII_CAST_WARN friend bool operator> (const char *s1, QLatin1StringView s2) { return compare_helper(s2, s1) < 0; } - QT_ASCII_CAST_WARN friend bool operator<=(const char *s1, QLatin1StringView s2) { return compare_helper(s2, s1) >= 0; } - QT_ASCII_CAST_WARN friend bool operator>=(const char *s1, QLatin1StringView s2) { return compare_helper(s2, s1) <= 0; } + Q_DECLARE_STRONGLY_ORDERED(QLatin1StringView, QByteArray, QT_ASCII_CAST_WARN) + Q_DECLARE_STRONGLY_ORDERED(QLatin1StringView, const char *, QT_ASCII_CAST_WARN) #endif // !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII) private: diff --git a/src/corelib/text/qlatin1stringview.qdoc b/src/corelib/text/qlatin1stringview.qdoc index c9fd17c3ce6..a7983448cdd 100644 --- a/src/corelib/text/qlatin1stringview.qdoc +++ b/src/corelib/text/qlatin1stringview.qdoc @@ -840,14 +840,13 @@ */ /*! - \fn bool QLatin1StringView::operator==(const char *other) const + \fn bool QLatin1StringView::operator==(const QLatin1StringView &lhs, const char * const &rhs) \since 4.3 - Returns \c true if the string is equal to const char pointer \a other; + Returns \c true if the string \a lhs is equal to const char pointer \a rhs; otherwise returns \c false. - The \a other const char pointer is converted to a QString using - the QString::fromUtf8() function. + The \a rhs const char pointer is converted to a QUtf8StringView. You can disable this operator by defining \l QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -858,12 +857,11 @@ */ /*! - \fn bool QLatin1StringView::operator==(const QByteArray &other) const + \fn bool QLatin1StringView::operator==(const QLatin1StringView &lhs, const QByteArray &rhs) \since 5.0 \overload - The \a other byte array is converted to a QString using - the QString::fromUtf8() function. + The \a rhs byte array is converted to a QUtf8StringView. You can disable this operator by defining \l QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -872,14 +870,13 @@ */ /*! - \fn bool QLatin1StringView::operator!=(const char *other) const + \fn bool QLatin1StringView::operator!=(const QLatin1StringView &lhs, const char * const &rhs) \since 4.3 - Returns \c true if this string is not equal to const char pointer \a other; + Returns \c true if the string \a lhs is not equal to const char pointer \a rhs; otherwise returns \c false. - The \a other const char pointer is converted to a QString using - the QString::fromUtf8() function. + The \a rhs const char pointer is converted to a QUtf8StringView. You can disable this operator by defining \l QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -890,12 +887,11 @@ */ /*! - \fn bool QLatin1StringView::operator!=(const QByteArray &other) const + \fn bool QLatin1StringView::operator!=(const QLatin1StringView &lhs, const QByteArray &rhs) \since 5.0 \overload operator!=() - The \a other byte array is converted to a QString using - the QString::fromUtf8() function. + The \a rhs byte array is converted to a QUtf8StringView. You can disable this operator by defining \l QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -904,14 +900,13 @@ */ /*! - \fn bool QLatin1StringView::operator>(const char *other) const + \fn bool QLatin1StringView::operator>(const QLatin1StringView &lhs, const char * const &rhs) \since 4.3 - Returns \c true if this string is lexically greater than const char pointer - \a other; otherwise returns \c false. + Returns \c true if the string \a lhs is lexically greater than const char pointer + \a rhs; otherwise returns \c false. - The \a other const char pointer is converted to a QString using - the QString::fromUtf8() function. + The \a rhs const char pointer is converted to a QUtf8StringView. You can disable this operator by defining \l QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want @@ -922,12 +917,11 @@ */ /*! - \fn bool QLatin1StringView::operator>(const QByteArray &other) const + \fn bool QLatin1StringView::operator>(const QLatin1StringView &lhs, const QByteArray &rhs) \since 5.0 \overload - The \a other byte array is converted to a QString using - the QString::fromUtf8() function. + The \a rhs byte array is converted to a QUtf8StringView. You can disable this operator by defining \l QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want @@ -936,14 +930,13 @@ */ /*! - \fn bool QLatin1StringView::operator<(const char *other) const + \fn bool QLatin1StringView::operator<(const QLatin1StringView &lhs, const char * const &rhs) \since 4.3 - Returns \c true if this string is lexically less than const char pointer - \a other; otherwise returns \c false. + Returns \c true if the string \a lhs is lexically less than const char pointer + \a rhs; otherwise returns \c false. - The \a other const char pointer is converted to a QString using - the QString::fromUtf8() function. + The \a rhs const char pointer is converted to a QUtf8StringView. You can disable this operator by defining \l QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -954,12 +947,11 @@ */ /*! - \fn bool QLatin1StringView::operator<(const QByteArray &other) const + \fn bool QLatin1StringView::operator<(const QLatin1StringView &lhs, const QByteArray &rhs) \since 5.0 \overload - The \a other byte array is converted to a QString using - the QString::fromUtf8() function. + The \a rhs byte array is converted to a QUtf8StringView. You can disable this operator by defining \l QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -968,14 +960,13 @@ */ /*! - \fn bool QLatin1StringView::operator>=(const char *other) const + \fn bool QLatin1StringView::operator>=(const QLatin1StringView &lhs, const char * const &rhs) \since 4.3 - Returns \c true if this string is lexically greater than or equal to - const char pointer \a other; otherwise returns \c false. + Returns \c true if the string \a lhs is lexically greater than or equal to + const char pointer \a rhs; otherwise returns \c false. - The \a other const char pointer is converted to a QString using - the QString::fromUtf8() function. + The \a rhs const char pointer is converted to a QUtf8StringView. You can disable this operator by defining \l QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -986,12 +977,11 @@ */ /*! - \fn bool QLatin1StringView::operator>=(const QByteArray &other) const + \fn bool QLatin1StringView::operator>=(const QLatin1StringView &lhs, const QByteArray &rhs) \since 5.0 \overload - The \a other byte array is converted to a QString using - the QString::fromUtf8() function. + The \a rhs byte array is converted to a QUtf8StringView. You can disable this operator by defining \l QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -1000,14 +990,13 @@ */ /*! - \fn bool QLatin1StringView::operator<=(const char *other) const + \fn bool QLatin1StringView::operator<=(const QLatin1StringView &lhs, const char * const &rhs) \since 4.3 - Returns \c true if this string is lexically less than or equal to - const char pointer \a other; otherwise returns \c false. + Returns \c true if the string \a lhs is lexically less than or equal to + const char pointer \a rhs; otherwise returns \c false. - The \a other const char pointer is converted to a QString using - the QString::fromUtf8() function. + The \a rhs const char pointer is converted to a QUtf8StringView. You can disable this operator by defining \l QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -1018,12 +1007,11 @@ */ /*! - \fn bool QLatin1StringView::operator<=(const QByteArray &other) const + \fn bool QLatin1StringView::operator<=(const QLatin1StringView &lhs, const QByteArray &rhs) \since 5.0 \overload - The \a other byte array is converted to a QString using - the QString::fromUtf8() function. + The \a rhs byte array is converted to a QUtf8StringView. You can disable this operator by defining \l QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -1185,35 +1173,35 @@ string view \a s2; otherwise returns \c false. */ -/*! \fn bool QLatin1StringView::operator==(const char *s1, QLatin1StringView s2) +/*! \fn bool QLatin1StringView::operator==(const char * const &lhs, const QLatin1StringView &rhs) - Returns \c true if const char pointer \a s1 is lexically equal to - string \a s2; otherwise returns \c false. + Returns \c true if const char pointer \a lhs is lexically equal to + string \a rhs; otherwise returns \c false. */ -/*! \fn bool QLatin1StringView::operator<(const char *s1, QLatin1StringView s2) +/*! \fn bool QLatin1StringView::operator<(const char * const &lhs, const QLatin1StringView &rhs) - Returns \c true if const char pointer \a s1 is lexically less than - string \a s2; otherwise returns \c false. + Returns \c true if const char pointer \a lhs is lexically less than + string \a rhs; otherwise returns \c false. */ -/*! \fn bool QLatin1StringView::operator>(const char *s1, QLatin1StringView s2) +/*! \fn bool QLatin1StringView::operator>(const char * const &lhs, const QLatin1StringView &rhs) - Returns \c true if const char pointer \a s1 is lexically greater than - string \a s2; otherwise returns \c false. + Returns \c true if const char pointer \a lhs is lexically greater than + string \a rhs; otherwise returns \c false. */ -/*! \fn bool QLatin1StringView::operator!=(const char *s1, QLatin1StringView s2) +/*! \fn bool QLatin1StringView::operator!=(const char * const &lhs, const QLatin1StringView &rhs) - Returns \c true if const char pointer \a s1 is lexically not equal to - string \a s2; otherwise returns \c false. + Returns \c true if const char pointer \a lhs is lexically not equal to + string \a rhs; otherwise returns \c false. */ -/*! \fn bool QLatin1StringView::operator<=(const char *s1, QLatin1StringView s2) +/*! \fn bool QLatin1StringView::operator<=(const char * const &lhs, const QLatin1StringView &rhs) - Returns \c true if const char pointer \a s1 is lexically less than or - equal to string \a s2; otherwise returns \c false. + Returns \c true if const char pointer \a lhs is lexically less than or + equal to string \a rhs; otherwise returns \c false. */ -/*! \fn bool QLatin1StringView::operator>=(const char *s1, QLatin1StringView s2) +/*! \fn bool QLatin1StringView::operator>=(const char * const &lhs, const QLatin1StringView &rhs) - Returns \c true if const char pointer \a s1 is lexically greater than or - equal to string \a s2; otherwise returns \c false. + Returns \c true if const char pointer \a lhs is lexically greater than or + equal to string \a rhs; otherwise returns \c false. */ /*! diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 84f95d28a7b..780b3090c16 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -1336,35 +1336,6 @@ bool QString::operator<=(const char *s) const bool QString::operator>=(const char *s) const { return QString::compare_helper(constData(), size(), s, -1) >= 0; } -// -// QLatin1StringView inline members that require QString: -// -QT_ASCII_CAST_WARN bool QLatin1StringView::operator==(const char *s) const -{ return QString::fromUtf8(s) == *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator!=(const char *s) const -{ return QString::fromUtf8(s) != *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator<(const char *s) const -{ return QString::fromUtf8(s) > *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator>(const char *s) const -{ return QString::fromUtf8(s) < *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator<=(const char *s) const -{ return QString::fromUtf8(s) >= *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator>=(const char *s) const -{ return QString::fromUtf8(s) <= *this; } - -QT_ASCII_CAST_WARN bool QLatin1StringView::operator==(const QByteArray &s) const -{ return QString::fromUtf8(s) == *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator!=(const QByteArray &s) const -{ return QString::fromUtf8(s) != *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator<(const QByteArray &s) const -{ return QString::fromUtf8(s) > *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator>(const QByteArray &s) const -{ return QString::fromUtf8(s) < *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator<=(const QByteArray &s) const -{ return QString::fromUtf8(s) >= *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator>=(const QByteArray &s) const -{ return QString::fromUtf8(s) <= *this; } - QT_ASCII_CAST_WARN bool QString::operator==(const QByteArray &s) const { return QString::compare_helper(constData(), size(), s.constData(), s.size()) == 0; } QT_ASCII_CAST_WARN bool QString::operator!=(const QByteArray &s) const diff --git a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp index 7d742534075..927af3a47e3 100644 --- a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp +++ b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp @@ -61,7 +61,6 @@ constexpr bool is_fake_comparator_v = false; /*end*/ MAKE_ALL(QByteArray, QChar) -MAKE_ALL(QByteArray, QLatin1String) MAKE_ALL(QByteArray, char16_t) MAKE_ALL(char16_t, QByteArray)