diff options
| author | Ahmad Samir <a.samirh78@gmail.com> | 2024-10-16 12:36:33 +0300 |
|---|---|---|
| committer | Ahmad Samir <a.samirh78@gmail.com> | 2025-01-21 01:18:36 +0200 |
| commit | be3bf632e1cf80b16475f8353e4753b38317626b (patch) | |
| tree | b783d10521f0cad27a9f65200aeaa277208ccefa /src/corelib | |
| parent | 6b7c354f5af65f263dc8526f1e2362aeb0eedfeb (diff) | |
QString: add {setUtf16,setUnicode}(const char16_t*) overloads
This is a first step for adding QT_NO_INTEGRAL_STRINGS in the next
commit.
Mark setUtf16(const ushort *) as obsolete.
Use the weak overload workaround, so that the call isn't ambiguous if
it's called on a nullptr.
[ChangeLog][QtCore][QString] Added setUtf16(const char16_t *) and
setUnicode(const char16_t *) overloads.
Pick-to: 6.9
Task-number: QTBUG-125871
Change-Id: I25d12c19876466c235c0d9928aae6fd332836bf5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
| -rw-r--r-- | src/corelib/text/qstring.cpp | 20 | ||||
| -rw-r--r-- | src/corelib/text/qstring.h | 14 |
2 files changed, 28 insertions, 6 deletions
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 935b7363cf4..1d1485d20f6 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -6143,7 +6143,16 @@ QString& QString::setUnicode(const QChar *unicode, qsizetype size) } /*! - \fn QString &QString::setUtf16(const ushort *unicode, qsizetype size) + \fn QString::setUnicode(const char16_t *unicode, qsizetype size) + \overload + \since 6.9 + + \sa unicode(), setUtf16() +*/ + +/*! + \fn QString::setUtf16(const char16_t *unicode, qsizetype size) + \since 6.9 Resizes the string to \a size characters and copies \a unicode into the string. @@ -6158,6 +6167,11 @@ QString& QString::setUnicode(const QChar *unicode, qsizetype size) */ /*! + \fn QString &QString::setUtf16(const ushort *unicode, qsizetype size) + \obsolete Use the \c char16_t overload instead. +*/ + +/*! \fn QString QString::simplified() const Returns a string that has whitespace removed from the start @@ -7586,8 +7600,8 @@ QString QString::vasprintf(const char *cformat, va_list ap) } case 's': { if (length_mod == lm_l) { - const ushort *buff = va_arg(ap, const ushort*); - const ushort *ch = buff; + const char16_t *buff = va_arg(ap, const char16_t*); + const auto *ch = buff; while (precision != 0 && *ch != 0) { ++ch; --precision; diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index f3759718bc8..0cf01ff2c3a 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -768,7 +768,17 @@ public: QString &setRawData(const QChar *unicode, qsizetype size); QString &setUnicode(const QChar *unicode, qsizetype size); - inline QString &setUtf16(const ushort *utf16, qsizetype size); // ### Qt 7 char16_t + Q_WEAK_OVERLOAD + QString &setUnicode(const char16_t *utf16, qsizetype size) + { return setUnicode(reinterpret_cast<const QChar *>(utf16), size); } + QString &setUtf16(const char16_t *utf16, qsizetype size) + { return setUnicode(reinterpret_cast<const QChar *>(utf16), size); } + +#if !QT_CORE_REMOVED_SINCE(6, 9) + Q_WEAK_OVERLOAD +#endif + QString &setUtf16(const ushort *autf16, qsizetype asize) + { return setUnicode(reinterpret_cast<const QChar *>(autf16), asize); } int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; int compare(QLatin1StringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; @@ -1417,8 +1427,6 @@ void QString::squeeze() d.clearFlag(Data::CapacityReserved); } -QString &QString::setUtf16(const ushort *autf16, qsizetype asize) -{ return setUnicode(reinterpret_cast<const QChar *>(autf16), asize); } QChar &QString::operator[](qsizetype i) { verify(i, 1); return data()[i]; } QChar &QString::front() { return operator[](0); } |
