diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-06-18 09:40:39 +0200 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-06-24 23:39:09 +0200 |
commit | 9eb78ce0faee6d5cba61d662c36e5c59876dc6cc (patch) | |
tree | 3645fbd8bbfb4b1aaa74c219d15ebe22bac53fb4 /src/corelib/text | |
parent | d630478f7a257013e2b7e392e4a727d8612320be (diff) |
Deprecate QByteArray's methods taking QString
Change-Id: I5aba5a91f288173c2d4f1bd3538191757abd3202
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/text')
-rw-r--r-- | src/corelib/text/qbytearray.cpp | 20 | ||||
-rw-r--r-- | src/corelib/text/qbytearray.h | 48 | ||||
-rw-r--r-- | src/corelib/text/qstring.h | 7 |
3 files changed, 56 insertions, 19 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 3da643dc8b..87ca977d91 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -1642,6 +1642,7 @@ void QByteArray::chop(int n) /*! \fn QByteArray &QByteArray::operator+=(const QString &str) \overload + \obsolete Appends the string \a str onto the end of this byte array and returns a reference to this byte array. The Unicode data is @@ -2003,6 +2004,7 @@ QByteArray &QByteArray::append(const QByteArray &ba) /*! \fn QByteArray &QByteArray::append(const QString &str) \overload + \obsolete Appends the string \a str to this byte array. The Unicode data is converted into 8-bit characters using QString::toUtf8(). @@ -2127,6 +2129,7 @@ QByteArray &QByteArray::insert(int i, const QByteArray &ba) \fn QByteArray &QByteArray::insert(int i, const QString &str) \overload + \obsolete Inserts the string \a str at index position \a i in the byte array. The Unicode data is converted into 8-bit characters using @@ -2476,6 +2479,7 @@ QByteArray &QByteArray::replace(const char *before, int bsize, const char *after /*! \fn QByteArray &QByteArray::replace(const QString &before, const QByteArray &after) \overload + \obsolete Replaces every occurrence of the string \a before with the byte array \a after. The Unicode data is converted into 8-bit @@ -2489,6 +2493,7 @@ QByteArray &QByteArray::replace(const char *before, int bsize, const char *after /*! \fn QByteArray &QByteArray::replace(const QString &before, const char *after) \overload + \obsolete Replaces every occurrence of the string \a before with the string \a after. @@ -2519,6 +2524,7 @@ QByteArray &QByteArray::replace(char before, const QByteArray &after) /*! \fn QByteArray &QByteArray::replace(char before, const QString &after) \overload + \obsolete Replaces every occurrence of the character \a before with the string \a after. The Unicode data is converted into 8-bit @@ -2657,6 +2663,7 @@ int QByteArray::indexOf(const QByteArray &ba, int from) const /*! \fn int QByteArray::indexOf(const QString &str, int from) const \overload + \obsolete Returns the index position of the first occurrence of the string \a str in the byte array, searching forward from index position @@ -2781,6 +2788,7 @@ int QByteArray::lastIndexOf(const QByteArray &ba, int from) const /*! \fn int QByteArray::lastIndexOf(const QString &str, int from) const \overload + \obsolete Returns the index position of the last occurrence of the string \a str in the byte array, searching backward from index position \a @@ -3326,6 +3334,8 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba) /*! \fn bool QByteArray::operator==(const QString &str) const + \obsolete + Returns \c true if this byte array is equal to string \a str; otherwise returns \c false. @@ -3343,6 +3353,8 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba) /*! \fn bool QByteArray::operator!=(const QString &str) const + \obsolete + Returns \c true if this byte array is not equal to string \a str; otherwise returns \c false. @@ -3360,6 +3372,8 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba) /*! \fn bool QByteArray::operator<(const QString &str) const + \obsolete + Returns \c true if this byte array is lexically less than string \a str; otherwise returns \c false. @@ -3377,6 +3391,8 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba) /*! \fn bool QByteArray::operator>(const QString &str) const + \obsolete + Returns \c true if this byte array is lexically greater than string \a str; otherwise returns \c false. @@ -3394,6 +3410,8 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba) /*! \fn bool QByteArray::operator<=(const QString &str) const + \obsolete + Returns \c true if this byte array is lexically less than or equal to string \a str; otherwise returns \c false. @@ -3411,6 +3429,8 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba) /*! \fn bool QByteArray::operator>=(const QString &str) const + \obsolete + Returns \c true if this byte array is greater than or equal to string \a str; otherwise returns \c false. diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 2b7d298313..bb4d22e8ca 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -334,24 +334,38 @@ public: Q_REQUIRED_RESULT QByteArray repeated(int times) const; -#ifndef QT_NO_CAST_TO_ASCII - QT_ASCII_CAST_WARN QByteArray &append(const QString &s); - QT_ASCII_CAST_WARN QByteArray &insert(int i, const QString &s); - QT_ASCII_CAST_WARN QByteArray &replace(const QString &before, const char *after); - QT_ASCII_CAST_WARN QByteArray &replace(char c, const QString &after); - QT_ASCII_CAST_WARN QByteArray &replace(const QString &before, const QByteArray &after); - - QT_ASCII_CAST_WARN QByteArray &operator+=(const QString &s); - QT_ASCII_CAST_WARN int indexOf(const QString &s, int from = 0) const; - QT_ASCII_CAST_WARN int lastIndexOf(const QString &s, int from = -1) const; +#if !defined(QT_NO_CAST_TO_ASCII) && QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_VERSION_X_5_15("Use QString's toUtf8(), toLatin1() or toLocal8Bit()") + QByteArray &append(const QString &s); + QT_DEPRECATED_VERSION_X_5_15("Use QString's toUtf8(), toLatin1() or toLocal8Bit()") + QByteArray &insert(int i, const QString &s); + QT_DEPRECATED_VERSION_X_5_15("Use QString's toUtf8(), toLatin1() or toLocal8Bit()") + QByteArray &replace(const QString &before, const char *after); + QT_DEPRECATED_VERSION_X_5_15("Use QString's toUtf8(), toLatin1() or toLocal8Bit()") + QByteArray &replace(char c, const QString &after); + QT_DEPRECATED_VERSION_X_5_15("Use QString's toUtf8(), toLatin1() or toLocal8Bit()") + QByteArray &replace(const QString &before, const QByteArray &after); + + QT_DEPRECATED_VERSION_X_5_15("Use QString's toUtf8(), toLatin1() or toLocal8Bit()") + QByteArray &operator+=(const QString &s); + QT_DEPRECATED_VERSION_X_5_15("Use QString's toUtf8(), toLatin1() or toLocal8Bit()") + int indexOf(const QString &s, int from = 0) const; + QT_DEPRECATED_VERSION_X_5_15("Use QString's toUtf8(), toLatin1() or toLocal8Bit()") + int lastIndexOf(const QString &s, int from = -1) const; #endif -#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; +#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII) && QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_VERSION_X_5_15("Use QString's toUtf8(), toLatin1() or toLocal8Bit()") + inline bool operator==(const QString &s2) const; + QT_DEPRECATED_VERSION_X_5_15("Use QString's toUtf8(), toLatin1() or toLocal8Bit()") + inline bool operator!=(const QString &s2) const; + QT_DEPRECATED_VERSION_X_5_15("Use QString's toUtf8(), toLatin1() or toLocal8Bit()") + inline bool operator<(const QString &s2) const; + QT_DEPRECATED_VERSION_X_5_15("Use QString's toUtf8(), toLatin1() or toLocal8Bit()") + inline bool operator>(const QString &s2) const; + QT_DEPRECATED_VERSION_X_5_15("Use QString's toUtf8(), toLatin1() or toLocal8Bit()") + inline bool operator<=(const QString &s2) const; + QT_DEPRECATED_VERSION_X_5_15("Use QString's toUtf8(), toLatin1() or toLocal8Bit()") + inline bool operator>=(const QString &s2) const; #endif short toShort(bool *ok = nullptr, int base = 10) const; diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index f446c35e40..5cfae878cc 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -1483,6 +1483,7 @@ 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; } +#if QT_DEPRECATED_SINCE(5, 15) 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 @@ -1495,9 +1496,11 @@ 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 // QT_DEPRECATED_SINCE(5, 15) + #endif // !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII) -#ifndef QT_NO_CAST_TO_ASCII +#if !defined(QT_NO_CAST_TO_ASCII) && QT_DEPRECATED_SINCE(5, 15) inline QByteArray &QByteArray::append(const QString &s) { return append(s.toUtf8()); } inline QByteArray &QByteArray::insert(int i, const QString &s) @@ -1514,7 +1517,7 @@ inline int QByteArray::indexOf(const QString &s, int from) const { return indexOf(s.toUtf8(), from); } inline int QByteArray::lastIndexOf(const QString &s, int from) const { return lastIndexOf(s.toUtf8(), from); } -#endif // QT_NO_CAST_TO_ASCII +#endif // !defined(QT_NO_CAST_TO_ASCII) && QT_DEPRECATED_SINCE(5, 15) #if !defined(QT_USE_FAST_OPERATOR_PLUS) && !defined(QT_USE_QSTRINGBUILDER) inline const QString operator+(const QString &s1, const QString &s2) |