QString: deprecate fromUtf16(ushort*)/fromUcs4(uint*)

... in favor of existing char16_t* and char32_t* versions.

Swap the implementations around so the deprecated version is inline.

[ChangeLog][QtCore][QString] The fromUtf16(const ushort*) and
fromUcs4(const uint*) functions have been deprecated in favor of
the char16_t and char32_t versions, resp.

Change-Id: I94ff63ae98d190267da0b1c943d3d9c4e825ef10
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Marc Mutz 2020-05-08 23:54:50 +02:00
parent 46fb39ef5a
commit f5a56cf9bb
2 changed files with 23 additions and 37 deletions

View File

@ -5448,6 +5448,7 @@ QString QString::fromUtf8_helper(const char *str, int size)
}
/*!
\since 5.3
Returns a QString initialized with the first \a size characters
of the Unicode string \a unicode (ISO-10646-UTF-16 encoded).
@ -5463,7 +5464,7 @@ QString QString::fromUtf8_helper(const char *str, int size)
\sa utf16(), setUtf16(), fromStdU16String()
*/
QString QString::fromUtf16(const ushort *unicode, int size)
QString QString::fromUtf16(const char16_t *unicode, int size)
{
if (!unicode)
return QString();
@ -5476,39 +5477,22 @@ QString QString::fromUtf16(const ushort *unicode, int size)
}
/*!
\fn QString QString::fromUtf16(const char16_t *str, int size)
\since 5.3
\fn QString QString::fromUtf16(const ushort *str, int size)
\obsolete
Returns a QString initialized with the first \a size characters
of the Unicode string \a str (ISO-10646-UTF-16 encoded).
If \a size is -1 (default), \a str must be \\0'-terminated.
This function checks for a Byte Order Mark (BOM). If it is missing,
host byte order is assumed.
This function is slow compared to the other Unicode conversions.
Use QString(const QChar *, int) or QString(const QChar *) if possible.
QString makes a deep copy of the Unicode data.
\sa utf16(), setUtf16(), fromStdU16String()
*/
/*!
\fn QString QString::fromUcs4(const char32_t *str, int size)
\since 5.3
Returns a QString initialized with the first \a size characters
of the Unicode string \a str (ISO-10646-UCS-4 encoded).
If \a size is -1 (default), \a str must be \\0'-terminated.
\sa toUcs4(), fromUtf16(), utf16(), setUtf16(), fromWCharArray(), fromStdU32String()
Use the \c char16_t overload.
*/
/*!
\fn QString QString::fromUcs4(const uint *str, int size)
\since 4.2
\obsolete
Use the \c char32_t overload instead.
*/
/*!
\since 5.3
Returns a QString initialized with the first \a size characters
of the Unicode string \a unicode (ISO-10646-UCS-4 encoded).
@ -5517,7 +5501,7 @@ QString QString::fromUtf16(const ushort *unicode, int size)
\sa toUcs4(), fromUtf16(), utf16(), setUtf16(), fromWCharArray(), fromStdU32String()
*/
QString QString::fromUcs4(const uint *unicode, int size)
QString QString::fromUcs4(const char32_t *unicode, int size)
{
if (!unicode)
return QString();

View File

@ -720,15 +720,17 @@ public:
{ return str.isNull() ? QString() : fromUtf8(str.data(), qstrnlen(str.constData(), str.size())); }
static inline QString fromLocal8Bit(const QByteArray &str)
{ return str.isNull() ? QString() : fromLocal8Bit(str.data(), qstrnlen(str.constData(), str.size())); }
static QString fromUtf16(const ushort *, int size = -1);
static QString fromUcs4(const uint *, int size = -1);
static QString fromUtf16(const char16_t *, int size = -1);
static QString fromUcs4(const char32_t *, int size = -1);
static QString fromRawData(const QChar *, int size);
#if defined(Q_COMPILER_UNICODE_STRINGS)
static QString fromUtf16(const char16_t *str, int size = -1)
{ return fromUtf16(reinterpret_cast<const ushort *>(str), size); }
static QString fromUcs4(const char32_t *str, int size = -1)
{ return fromUcs4(reinterpret_cast<const uint *>(str), size); }
#if QT_DEPRECATED_SINCE(6, 0)
QT_DEPRECATED_VERSION_X_6_0("Use char16_t* overload.")
static QString fromUtf16(const ushort *str, int size = -1)
{ return fromUtf16(reinterpret_cast<const char16_t *>(str), size); }
QT_DEPRECATED_VERSION_X_6_0("Use char32_t* overload.")
static QString fromUcs4(const uint *str, int size = -1)
{ return fromUcs4(reinterpret_cast<const char32_t *>(str), size); }
#endif
inline int toWCharArray(wchar_t *array) const;