Deprecate _qs and _qba literal operators in favor of _s and _ba

[ChangeLog][QtCore] Deprecated _qs and _qba literal operators
for QString and QByteArray in favor of _s and _ba in the
Qt::Literals::StringLiterals namespace.

Task-number: QTBUG-101408
Change-Id: I26aee0055e3b4c1860de6eda8e0eb857c5b3e11a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Sona Kurazyan 2022-03-21 14:44:21 +01:00
parent 651ba6535c
commit 34242f843e
6 changed files with 22 additions and 2 deletions

View File

@ -4779,11 +4779,13 @@ QByteArray QByteArray::toPercentEncoding(const QByteArray &exclude, const QByteA
\sa QStringLiteral
*/
#if QT_DEPRECATED_SINCE(6, 8)
/*!
\fn QtLiterals::operator""_qba(const char *str, size_t size)
\relates QByteArray
\since 6.2
\deprecated [6.8] Use \c _ba from Qt::StringLiterals namespace instead.
Literal operator that creates a QByteArray out of the first \a size characters
in the char string literal \a str.
@ -4801,6 +4803,7 @@ QByteArray QByteArray::toPercentEncoding(const QByteArray &exclude, const QByteA
\sa QByteArrayLiteral, QtLiterals::operator""_qs(const char16_t *str, size_t size)
*/
#endif // QT_DEPRECATED_SINCE(6, 8)
/*!
\fn Qt::Literals::StringLiterals::operator""_ba(const char *str, size_t size)

View File

@ -704,10 +704,15 @@ inline QByteArray operator"" _ba(const char *str, size_t size) noexcept
} // Qt
inline namespace QtLiterals {
#if QT_DEPRECATED_SINCE(6, 8)
QT_DEPRECATED_VERSION_X_6_8("Use _ba from Qt::StringLiterals namespace instead.")
inline QByteArray operator"" _qba(const char *str, size_t size) noexcept
{
return Qt::StringLiterals::operator""_ba(str, size);
}
#endif // QT_DEPRECATED_SINCE(6, 8)
} // QtLiterals
QT_END_NAMESPACE

View File

@ -10987,11 +10987,13 @@ QString QString::toHtmlEscaped() const
\sa QByteArrayLiteral
*/
#if QT_DEPRECATED_SINCE(6, 8)
/*!
\fn QtLiterals::operator""_qs(const char16_t *str, size_t size)
\relates QString
\since 6.2
\deprecated [6.8] Use \c _s from Qt::StringLiterals namespace instead.
Literal operator that creates a QString out of the first \a size characters in
the char16_t string literal \a str.
@ -11009,6 +11011,7 @@ QString QString::toHtmlEscaped() const
\sa QStringLiteral, QtLiterals::operator""_qba(const char *str, size_t size)
*/
#endif // QT_DEPRECATED_SINCE(6, 8)
/*!
\fn Qt::Literals::StringLiterals::operator""_s(const char16_t *str, size_t size)

View File

@ -1677,10 +1677,15 @@ inline QString operator"" _s(const char16_t *str, size_t size) noexcept
} // Qt
inline namespace QtLiterals {
#if QT_DEPRECATED_SINCE(6, 8)
QT_DEPRECATED_VERSION_X_6_8("Use _s from Qt::StringLiterals namespace instead.")
inline QString operator"" _qs(const char16_t *str, size_t size) noexcept
{
return Qt::StringLiterals::operator""_s(str, size);
}
#endif // QT_DEPRECATED_SINCE(6, 8)
} // QtLiterals
QT_END_NAMESPACE

View File

@ -2238,8 +2238,9 @@ void tst_QByteArray::userDefinedLiterals()
QVERIFY(str2.capacity() >= str2.length());
}
#if QT_DEPRECATED_SINCE(6, 8)
{
QByteArray str = "abcd"_qba;
QT_IGNORE_DEPRECATIONS(QByteArray str = "abcd"_qba;)
QVERIFY(str.length() == 4);
QCOMPARE(str.capacity(), 0);
@ -2259,6 +2260,7 @@ void tst_QByteArray::userDefinedLiterals()
QVERIFY(str2.data() != s);
QVERIFY(str2.capacity() >= str2.length());
}
#endif // QT_DEPRECATED_SINCE(6, 8)
}
void tst_QByteArray::toUpperLower_data()

View File

@ -7053,8 +7053,9 @@ void tst_QString::userDefinedLiterals()
QVERIFY(str2.capacity() >= str2.length());
}
#if QT_DEPRECATED_SINCE(6, 8)
{
QString str = u"abcd"_qs;
QT_IGNORE_DEPRECATIONS(QString str = u"abcd"_qs;)
QVERIFY(str.length() == 4);
QCOMPARE(str.capacity(), 0);
@ -7074,6 +7075,7 @@ void tst_QString::userDefinedLiterals()
QVERIFY(str2.data() != s);
QVERIFY(str2.capacity() >= str2.length());
}
#endif // QT_DEPRECATED_SINCE(6, 8)
}
void tst_QString::eightBitLiterals_data()