Add back QByteArray's relational operators taking QString
QString still has the overloads of relational operators taking QByteArray. Add back QByteArray's relational operators taking QString for symmetry. See also the comments of d7ccd8cb4565c8643b158891c9de3187c1586dc9 for more details. [ChangeLog][EDITORIAL] Remove the changelog about QString/QByteArray operators being removed. They're back. Change-Id: I22c95e727285cf8a5ef79b3a4f9d45cb66319252 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
fe4b246446
commit
7d35e31efb
@ -2991,6 +2991,90 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba)
|
||||
}
|
||||
#endif // QT_NO_DATASTREAM
|
||||
|
||||
/*! \fn bool QByteArray::operator==(const QString &str) const
|
||||
|
||||
Returns \c true if this byte array is equal to the UTF-8 encoding of \a str;
|
||||
otherwise returns \c false.
|
||||
|
||||
The comparison is case sensitive.
|
||||
|
||||
You can disable this operator by defining \c
|
||||
QT_NO_CAST_FROM_ASCII when you compile your applications. You
|
||||
then need to call QString::fromUtf8(), QString::fromLatin1(),
|
||||
or QString::fromLocal8Bit() explicitly if you want to convert the byte
|
||||
array to a QString before doing the comparison.
|
||||
*/
|
||||
|
||||
/*! \fn bool QByteArray::operator!=(const QString &str) const
|
||||
|
||||
Returns \c true if this byte array is not equal to the UTF-8 encoding of \a
|
||||
str; otherwise returns \c false.
|
||||
|
||||
The comparison is case sensitive.
|
||||
|
||||
You can disable this operator by defining \c
|
||||
QT_NO_CAST_FROM_ASCII when you compile your applications. You
|
||||
then need to call QString::fromUtf8(), QString::fromLatin1(),
|
||||
or QString::fromLocal8Bit() explicitly if you want to convert the byte
|
||||
array to a QString before doing the comparison.
|
||||
*/
|
||||
|
||||
/*! \fn bool QByteArray::operator<(const QString &str) const
|
||||
|
||||
Returns \c true if this byte array is lexically less than the UTF-8 encoding
|
||||
of \a str; otherwise returns \c false.
|
||||
|
||||
The comparison is case sensitive.
|
||||
|
||||
You can disable this operator by defining \c
|
||||
QT_NO_CAST_FROM_ASCII when you compile your applications. You
|
||||
then need to call QString::fromUtf8(), QString::fromLatin1(),
|
||||
or QString::fromLocal8Bit() explicitly if you want to convert the byte
|
||||
array to a QString before doing the comparison.
|
||||
*/
|
||||
|
||||
/*! \fn bool QByteArray::operator>(const QString &str) const
|
||||
|
||||
Returns \c true if this byte array is lexically greater than the UTF-8
|
||||
encoding of \a str; otherwise returns \c false.
|
||||
|
||||
The comparison is case sensitive.
|
||||
|
||||
You can disable this operator by defining \c
|
||||
QT_NO_CAST_FROM_ASCII when you compile your applications. You
|
||||
then need to call QString::fromUtf8(), QString::fromLatin1(),
|
||||
or QString::fromLocal8Bit() explicitly if you want to convert the byte
|
||||
array to a QString before doing the comparison.
|
||||
*/
|
||||
|
||||
/*! \fn bool QByteArray::operator<=(const QString &str) const
|
||||
|
||||
Returns \c true if this byte array is lexically less than or equal to the
|
||||
UTF-8 encoding of \a str; otherwise returns \c false.
|
||||
|
||||
The comparison is case sensitive.
|
||||
|
||||
You can disable this operator by defining \c
|
||||
QT_NO_CAST_FROM_ASCII when you compile your applications. You
|
||||
then need to call QString::fromUtf8(), QString::fromLatin1(),
|
||||
or QString::fromLocal8Bit() explicitly if you want to convert the byte
|
||||
array to a QString before doing the comparison.
|
||||
*/
|
||||
|
||||
/*! \fn bool QByteArray::operator>=(const QString &str) const
|
||||
|
||||
Returns \c true if this byte array is greater than or equal to the UTF-8
|
||||
encoding of \a str; otherwise returns \c false.
|
||||
|
||||
The comparison is case sensitive.
|
||||
|
||||
You can disable this operator by defining \c
|
||||
QT_NO_CAST_FROM_ASCII when you compile your applications. You
|
||||
then need to call QString::fromUtf8(), QString::fromLatin1(),
|
||||
or QString::fromLocal8Bit() explicitly if you want to convert the byte
|
||||
array to a QString before doing the comparison.
|
||||
*/
|
||||
|
||||
/*! \fn bool operator==(const QByteArray &a1, const QByteArray &a2)
|
||||
\relates QByteArray
|
||||
|
||||
|
@ -308,6 +308,15 @@ public:
|
||||
|
||||
Q_REQUIRED_RESULT QByteArray repeated(int times) const;
|
||||
|
||||
#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
|
||||
inline QT_ASCII_CAST_WARN bool operator==(const QString &s2) const;
|
||||
inline QT_ASCII_CAST_WARN bool operator!=(const QString &s2) const;
|
||||
inline QT_ASCII_CAST_WARN bool operator<(const QString &s2) const;
|
||||
inline QT_ASCII_CAST_WARN bool operator>(const QString &s2) const;
|
||||
inline QT_ASCII_CAST_WARN bool operator<=(const QString &s2) const;
|
||||
inline QT_ASCII_CAST_WARN bool operator>=(const QString &s2) const;
|
||||
#endif
|
||||
|
||||
short toShort(bool *ok = nullptr, int base = 10) const;
|
||||
ushort toUShort(bool *ok = nullptr, int base = 10) const;
|
||||
int toInt(bool *ok = nullptr, int base = 10) const;
|
||||
|
@ -1259,6 +1259,18 @@ inline QT_ASCII_CAST_WARN bool QString::operator<=(const QByteArray &s) const
|
||||
inline QT_ASCII_CAST_WARN bool QString::operator>=(const QByteArray &s) const
|
||||
{ return QString::compare_helper(constData(), size(), s.constData(), s.size()) >= 0; }
|
||||
|
||||
inline bool QByteArray::operator==(const QString &s) const
|
||||
{ return QString::compare_helper(s.constData(), s.size(), constData(), qstrnlen(constData(), size())) == 0; }
|
||||
inline bool QByteArray::operator!=(const QString &s) const
|
||||
{ return QString::compare_helper(s.constData(), s.size(), constData(), qstrnlen(constData(), size())) != 0; }
|
||||
inline bool QByteArray::operator<(const QString &s) const
|
||||
{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) > 0; }
|
||||
inline bool QByteArray::operator>(const QString &s) const
|
||||
{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) < 0; }
|
||||
inline bool QByteArray::operator<=(const QString &s) const
|
||||
{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) >= 0; }
|
||||
inline bool QByteArray::operator>=(const QString &s) const
|
||||
{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) <= 0; }
|
||||
#endif // !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
|
||||
|
||||
#if !defined(QT_USE_FAST_OPERATOR_PLUS) && !defined(QT_USE_QSTRINGBUILDER)
|
||||
|
@ -200,6 +200,7 @@ private Q_SLOTS:
|
||||
void compare_QByteArray_char16_t_data() { compare_data(false); }
|
||||
void compare_QByteArray_char16_t() { compare_impl<QByteArray, char16_t>(); }
|
||||
void compare_QByteArray_QString_data() { compare_data(); }
|
||||
void compare_QByteArray_QString() { compare_impl<QByteArray, QString>(); }
|
||||
void compare_QByteArray_QLatin1String_data() { compare_data(); }
|
||||
void compare_QByteArray_QLatin1String() { compare_impl<QByteArray, QLatin1String>(); }
|
||||
void compare_QByteArray_QByteArray_data() { compare_data(); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user