diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/text/qbytearray.cpp | 84 | ||||
-rw-r--r-- | src/corelib/text/qbytearray.h | 9 | ||||
-rw-r--r-- | src/corelib/text/qstring.h | 12 |
3 files changed, 105 insertions, 0 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index bcbbdc234f..041fb06554 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -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 diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 68945ec6c4..a625b1846f 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -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; diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 1e0d7f480a..7f5e460275 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -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) |