Convert QStringView::toWCharArray() to return qsizetype
As requested in a ### Qt6 comment. Task-number: QTBUG-85700 Change-Id: I28a02bf49f4a6455a21a6032179318ce2915b8ca Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
34a095848d
commit
429985b53a
@ -1079,14 +1079,14 @@ inline qsizetype QString::toWCharArray(wchar_t *array) const
|
|||||||
return qToStringViewIgnoringNull(*this).toWCharArray(array);
|
return qToStringViewIgnoringNull(*this).toWCharArray(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
int QStringView::toWCharArray(wchar_t *array) const
|
qsizetype QStringView::toWCharArray(wchar_t *array) const
|
||||||
{
|
{
|
||||||
if (sizeof(wchar_t) == sizeof(QChar)) {
|
if (sizeof(wchar_t) == sizeof(QChar)) {
|
||||||
if (auto src = data())
|
if (auto src = data())
|
||||||
memcpy(array, src, sizeof(QChar) * size());
|
memcpy(array, src, sizeof(QChar) * size());
|
||||||
return int(size()); // ### q6sizetype
|
return size();
|
||||||
} else {
|
} else {
|
||||||
return QString::toUcs4_helper(reinterpret_cast<const ushort *>(data()), int(size()),
|
return QString::toUcs4_helper(reinterpret_cast<const ushort *>(data()), size(),
|
||||||
reinterpret_cast<uint *>(array));
|
reinterpret_cast<uint *>(array));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -358,7 +358,7 @@ public:
|
|||||||
Q_REQUIRED_RESULT Q_CORE_EXPORT float toFloat(bool *ok = nullptr) const;
|
Q_REQUIRED_RESULT Q_CORE_EXPORT float toFloat(bool *ok = nullptr) const;
|
||||||
Q_REQUIRED_RESULT Q_CORE_EXPORT double toDouble(bool *ok = nullptr) const;
|
Q_REQUIRED_RESULT Q_CORE_EXPORT double toDouble(bool *ok = nullptr) const;
|
||||||
|
|
||||||
Q_REQUIRED_RESULT inline int toWCharArray(wchar_t *array) const; // defined in qstring.h
|
Q_REQUIRED_RESULT inline qsizetype toWCharArray(wchar_t *array) const; // defined in qstring.h
|
||||||
|
|
||||||
|
|
||||||
Q_REQUIRED_RESULT Q_CORE_EXPORT
|
Q_REQUIRED_RESULT Q_CORE_EXPORT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user