178 typedef QTypedArrayData<
char16_t> Data;
180 friend class ::tst_QString;
182 template <
typename Iterator>
183 static constexpr bool is_contiguous_iterator_v =
188 std::is_pointer_v<Iterator>;
190 template <
typename Char>
191 using is_compatible_char_helper = std::disjunction<
192 QtPrivate::IsCompatibleCharType<Char>,
193 QtPrivate::IsCompatibleChar32Type<Char>,
194 QtPrivate::IsCompatibleChar8Type<Char>,
195 std::is_same<Char, QLatin1Char>
198 template <
typename T>
199 using is_string_like = std::conjunction<
200 std::negation<QtPrivate::treat_as_integral_arg<std::remove_cv_t<T>>>,
201 std::is_convertible<T, QAnyStringView>
204 template <
typename T>
205 using if_string_like = std::enable_if_t<is_string_like<T>::value,
bool>;
207 template <
typename T>
208 using is_floating_point_like = std::disjunction<
209 #if QFLOAT16_IS_NATIVE
210 std::is_same<q20::remove_cvref_t<T>, QtPrivate::NativeFloat16Type>,
212 std::is_same<q20::remove_cvref_t<T>, qfloat16>,
213 std::is_floating_point<T>
216 template <
typename T>
217 using if_floating_point = std::enable_if_t<is_floating_point_like<T>::value,
bool>;
219 template <
typename T>
220 using if_integral_non_char = std::enable_if_t<std::conjunction_v<
225 std::negation<q23::is_scoped_enum<T>>
228 std::negation<is_floating_point_like<T>>,
229 std::negation<is_string_like<T>>
232 template <
typename Iterator>
233 static constexpr bool is_compatible_iterator_v = std::conjunction_v<
235 typename std::iterator_traits<Iterator>::iterator_category,
236 std::input_iterator_tag
238 is_compatible_char_helper<
typename std::iterator_traits<Iterator>::value_type>
241 template <
typename Iterator>
242 using if_compatible_iterator = std::enable_if_t<is_compatible_iterator_v<Iterator>,
bool>;
245 typedef QStringPrivate DataPointer;
247 constexpr QString()
noexcept =
default;
248 explicit QString(
const QChar *unicode, qsizetype size = -1);
250 QString(qsizetype size, QChar c);
251 inline QString(QLatin1StringView latin1);
252 explicit QString(QStringView sv) : QString(sv.data(), sv.size()) {}
253#if defined(__cpp_char8_t) || defined(Q_QDOC)
255 inline QString(
const char8_t *str)
256 : QString(fromUtf8(str))
259 Q_DECL_CONSTEXPR_DTOR QString(
const QString &other)
noexcept : d(other.d) {}
260#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
) && !defined(QT_BOOTSTRAPPED)
261 Q_DECL_CONSTEXPR_DTOR ~QString() =
default;
263 QString &operator=(QChar c);
264 QT_CORE_CONSTEXPR_DTOR_INLINE_SINCE(6, 13)
265 QString &operator=(
const QString &)
noexcept;
266 QString &operator=(QLatin1StringView latin1);
267 Q_DECL_CONSTEXPR_DTOR QString(QString &&other)
noexcept =
default;
268 Q_DECL_CONSTEXPR_DTOR
269 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QString)
270 constexpr void swap(QString &other)
noexcept { d.swap(other.d); }
272 static constexpr qsizetype maxSize()
noexcept
275 return Data::maxSize() - 1;
277 constexpr qsizetype size()
const noexcept
279 constexpr size_t MaxSize = maxSize();
280 Q_PRESUME(size_t(d.size) <= MaxSize);
283#if QT_DEPRECATED_SINCE(6
, 4
)
284 QT_DEPRECATED_VERSION_X_6_4(
"Use size() or length() instead.")
285 constexpr qsizetype count()
const {
return size(); }
287 constexpr qsizetype length()
const noexcept {
return size(); }
288 constexpr bool isEmpty()
const noexcept {
return size() == 0; }
289 void resize(qsizetype size);
290 void resize(qsizetype size, QChar fillChar);
291 void resizeForOverwrite(qsizetype size);
293 QString &fill(QChar ch);
294 QString &fill(QChar c, qsizetype size);
295 void truncate(qsizetype pos);
296 void chop(qsizetype n);
298 QString &slice(qsizetype pos)
299 { verify(pos, 0);
return remove(0, pos); }
300 QString &slice(qsizetype pos, qsizetype n)
306 return remove(0, pos);
309 inline qsizetype capacity()
const;
310 inline void reserve(qsizetype size);
311 inline void squeeze();
313 inline const QChar *unicode()
const;
314 inline QChar *data();
315 inline const QChar *data()
const;
316 inline const QChar *constData()
const;
318 inline void detach();
319 inline bool isDetached()
const;
320 inline bool isSharedWith(
const QString &other)
const {
return d.isSharedWith(other.d); }
321 Q_DECL_CONSTEXPR_DTOR
void clear();
323 constexpr inline const QChar at(qsizetype i)
const;
324 constexpr inline const QChar operator[](qsizetype i)
const;
325 [[nodiscard]]
inline QChar &operator[](qsizetype i);
327 [[nodiscard]]
constexpr inline QChar front()
const {
return at(0); }
328 [[nodiscard]]
inline QChar &front();
329 [[nodiscard]]
constexpr inline QChar back()
const {
return at(size() - 1); }
330 [[nodiscard]]
inline QChar &back();
332#if QT_CORE_REMOVED_SINCE(6
, 9
)
333 [[nodiscard]] QString arg(qlonglong a,
int fieldwidth=0,
int base=10,
334 QChar fillChar = u' ')
const;
335 [[nodiscard]] QString arg(qulonglong a,
int fieldwidth=0,
int base=10,
336 QChar fillChar = u' ')
const;
337 [[nodiscard]]
inline QString arg(
long a,
int fieldwidth=0,
int base=10,
338 QChar fillChar = u' ')
const;
339 [[nodiscard]]
inline QString arg(ulong a,
int fieldwidth=0,
int base=10,
340 QChar fillChar = u' ')
const;
341 [[nodiscard]]
inline QString arg(
int a,
int fieldWidth = 0,
int base = 10,
342 QChar fillChar = u' ')
const;
343 [[nodiscard]]
inline QString arg(uint a,
int fieldWidth = 0,
int base = 10,
344 QChar fillChar = u' ')
const;
345 [[nodiscard]]
inline QString arg(
short a,
int fieldWidth = 0,
int base = 10,
346 QChar fillChar = u' ')
const;
347 [[nodiscard]]
inline QString arg(ushort a,
int fieldWidth = 0,
int base = 10,
348 QChar fillChar = u' ')
const;
349 [[nodiscard]] QString arg(
double a,
int fieldWidth = 0,
char format =
'g',
int precision = -1,
350 QChar fillChar = u' ')
const;
351 [[nodiscard]] QString arg(
char a,
int fieldWidth = 0,
352 QChar fillChar = u' ')
const;
353 [[nodiscard]] QString arg(QChar a,
int fieldWidth = 0,
354 QChar fillChar = u' ')
const;
355 [[nodiscard]] QString arg(
const QString &a,
int fieldWidth = 0,
356 QChar fillChar = u' ')
const;
357 [[nodiscard]] QString arg(QStringView a,
int fieldWidth = 0,
358 QChar fillChar = u' ')
const;
359 [[nodiscard]] QString arg(QLatin1StringView a,
int fieldWidth = 0,
360 QChar fillChar = u' ')
const;
363 template <
typename T, if_integral_non_char<T> =
true>
364 [[nodiscard]] QString arg(T a,
int fieldWidth = 0,
int base = 10,
365 QChar fillChar = u' ')
const
367 using U =
typename std::conditional<
369 std::is_enum_v<T>, std::underlying_type<T>,
370 q20::type_identity<T>
372 if constexpr (std::is_signed_v<U>)
373 return arg_impl(qlonglong(a), fieldWidth, base, fillChar);
375 return arg_impl(qulonglong(a), fieldWidth, base, fillChar);
378 template <
typename T, if_floating_point<T> =
true>
379 [[nodiscard]] QString arg(T a,
int fieldWidth = 0,
char format =
'g',
int precision = -1,
380 QChar fillChar = u' ')
const
381 {
return arg_impl(
double(a), fieldWidth, format, precision, fillChar); }
383 template <
typename T, if_string_like<T> =
true>
384 [[nodiscard]] QString arg(
const T &a,
int fieldWidth = 0, QChar fillChar = u' ')
const
385 {
return arg_impl(QAnyStringView(a), fieldWidth, fillChar); }
388 QString arg_impl(qlonglong a,
int fieldwidth,
int base, QChar fillChar)
const;
389 QString arg_impl(qulonglong a,
int fieldwidth,
int base, QChar fillChar)
const;
390 QString arg_impl(
double a,
int fieldWidth,
char format,
int precision, QChar fillChar)
const;
391 QString arg_impl(QAnyStringView a,
int fieldWidth, QChar fillChar)
const;
394 template <
typename...Args>
399 typename std::enable_if<
400 sizeof...(Args) >= 2 && std::conjunction_v<is_string_like<Args>...>,
404 arg(Args &&...args)
const
405 {
return qToStringViewIgnoringNull(*
this).arg(std::forward<Args>(args)...); }
407 static QString vasprintf(
const char *format, va_list ap) Q_ATTRIBUTE_FORMAT_PRINTF(1, 0);
408 static QString asprintf(
const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(1, 2);
410 [[nodiscard]] QT_CORE_INLINE_SINCE(6, 8)
411 qsizetype indexOf(QChar c, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
412 [[nodiscard]] QT_CORE_INLINE_SINCE(6, 12)
413 qsizetype indexOf(QLatin1StringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
414 [[nodiscard]] QT_CORE_INLINE_SINCE(6, 12)
415 qsizetype indexOf(
const QString &s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
416 [[nodiscard]] qsizetype indexOf(QStringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept
417 {
return QStringView(begin(), size()).indexOf(s, from, cs); }
418 [[nodiscard]] qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept
419 {
return lastIndexOf(c, -1, cs); }
420 [[nodiscard]] QT_CORE_INLINE_SINCE(6, 8)
421 qsizetype lastIndexOf(QChar c, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
422 [[nodiscard]] qsizetype lastIndexOf(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const
423 {
return lastIndexOf(s, size(), cs); }
424 [[nodiscard]] QT_CORE_INLINE_SINCE(6, 12)
425 qsizetype lastIndexOf(QLatin1StringView s, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
426 [[nodiscard]] qsizetype lastIndexOf(
const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const
427 {
return lastIndexOf(s, size(), cs); }
428 [[nodiscard]] QT_CORE_INLINE_SINCE(6, 12)
429 qsizetype lastIndexOf(
const QString &s, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
431 [[nodiscard]] qsizetype lastIndexOf(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept
432 {
return lastIndexOf(s, size(), cs); }
433 [[nodiscard]] qsizetype lastIndexOf(QStringView s, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept
434 {
return QStringView(begin(), size()).lastIndexOf(s, from, cs); }
436 [[nodiscard]]
inline bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
437 [[nodiscard]]
inline bool contains(
const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
438 [[nodiscard]]
inline bool contains(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
439 [[nodiscard]]
inline bool contains(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept;
440 [[nodiscard]] qsizetype count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
441 [[nodiscard]] qsizetype count(
const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
442 [[nodiscard]] qsizetype count(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
444#if QT_CONFIG(regularexpression)
445 [[nodiscard]] qsizetype indexOf(
const QRegularExpression &re, qsizetype from = 0,
446 QRegularExpressionMatch *rmatch =
nullptr)
const;
448 [[nodiscard]] qsizetype lastIndexOf(
const QRegularExpression &re, QRegularExpressionMatch *rmatch =
nullptr)
const;
451 template <
typename T = QRegularExpressionMatch, std::enable_if_t<std::is_same_v<T, QRegularExpressionMatch>,
bool> =
false>
452 [[nodiscard]] qsizetype lastIndexOf(
const QRegularExpression &re, T *rmatch =
nullptr)
const
453 {
return lastIndexOf(re, size(), rmatch); }
455 [[nodiscard]] qsizetype lastIndexOf(
const QRegularExpression &re, qsizetype from,
456 QRegularExpressionMatch *rmatch =
nullptr)
const;
457 [[nodiscard]]
bool contains(
const QRegularExpression &re, QRegularExpressionMatch *rmatch =
nullptr)
const;
458 [[nodiscard]] qsizetype count(
const QRegularExpression &re)
const;
462 SectionDefault = 0x00,
463 SectionSkipEmpty = 0x01,
464 SectionIncludeLeadingSep = 0x02,
465 SectionIncludeTrailingSep = 0x04,
466 SectionCaseInsensitiveSeps = 0x08
468 Q_DECLARE_FLAGS(SectionFlags, SectionFlag)
470 [[nodiscard]]
inline QString section(QChar sep, qsizetype start, qsizetype end = -1, SectionFlags flags = SectionDefault)
const;
471 [[nodiscard]] QString section(
const QString &in_sep, qsizetype start, qsizetype end = -1, SectionFlags flags = SectionDefault)
const;
472#if QT_CONFIG(regularexpression)
473 [[nodiscard]] QString section(
const QRegularExpression &re, qsizetype start, qsizetype end = -1, SectionFlags flags = SectionDefault)
const;
476#if QT_CORE_REMOVED_SINCE(6
, 7
)
477 QString left(qsizetype n)
const;
478 QString right(qsizetype n)
const;
479 QString mid(qsizetype position, qsizetype n = -1)
const;
481 QString first(qsizetype n)
const;
482 QString last(qsizetype n)
const;
483 QString sliced(qsizetype pos)
const;
484 QString sliced(qsizetype pos, qsizetype n)
const;
485 QString chopped(qsizetype n)
const;
487 [[nodiscard]] QString left(qsizetype n)
const &
489 if (size_t(n) >= size_t(size()))
493 [[nodiscard]] QString left(qsizetype n) &&
495 if (size_t(n) >= size_t(size()))
496 return std::move(*
this);
497 return std::move(*
this).first(n);
499 [[nodiscard]] QString right(qsizetype n)
const &
501 if (size_t(n) >= size_t(size()))
505 [[nodiscard]] QString right(qsizetype n) &&
507 if (size_t(n) >= size_t(size()))
508 return std::move(*
this);
509 return std::move(*
this).last(n);
511 [[nodiscard]] QString mid(qsizetype position, qsizetype n = -1)
const &;
512 [[nodiscard]] QString mid(qsizetype position, qsizetype n = -1) &&;
514 [[nodiscard]] QString first(qsizetype n)
const &
515 { verify(0, n);
return sliced(0, n); }
516 [[nodiscard]] QString last(qsizetype n)
const &
517 { verify(0, n);
return sliced(size() - n, n); }
518 [[nodiscard]] QString sliced(qsizetype pos)
const &
519 { verify(pos, 0);
return sliced(pos, size() - pos); }
520 [[nodiscard]] QString sliced(qsizetype pos, qsizetype n)
const &
521 { verify(pos, n);
return QString(begin() + pos, n); }
522 [[nodiscard]] QString chopped(qsizetype n)
const &
523 { verify(0, n);
return sliced(0, size() - n); }
525 [[nodiscard]] QString first(qsizetype n) &&
529 return std::move(*
this);
531 [[nodiscard]] QString last(qsizetype n) &&
532 { verify(0, n);
return sliced_helper(*
this, size() - n, n); }
533 [[nodiscard]] QString sliced(qsizetype pos) &&
534 { verify(pos, 0);
return sliced_helper(*
this, pos, size() - pos); }
535 [[nodiscard]] QString sliced(qsizetype pos, qsizetype n) &&
536 { verify(pos, n);
return sliced_helper(*
this, pos, n); }
537 [[nodiscard]] QString chopped(qsizetype n) &&
538 { verify(0, n); chop(n);
return std::move(*
this); }
540 bool startsWith(
const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
541 [[nodiscard]]
bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept
542 {
return QStringView(begin(), size()).startsWith(s, cs); }
543 bool startsWith(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
544 bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
546 bool endsWith(
const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
547 [[nodiscard]]
bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept
548 {
return QStringView(begin(), size()).endsWith(s, cs); }
549 bool endsWith(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
550 bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
552 bool isUpper()
const;
553 bool isLower()
const;
555 [[nodiscard]] QString leftJustified(qsizetype width, QChar fill = u' ',
bool trunc =
false)
const;
556 [[nodiscard]] QString rightJustified(qsizetype width, QChar fill = u' ',
bool trunc =
false)
const;
559 [[nodiscard]] QString toLower()
const &
560 {
return toLower_helper(*
this); }
561 [[nodiscard]] QString toLower() &&
562 {
return toLower_helper(*
this); }
563 [[nodiscard]] QString toUpper()
const &
564 {
return toUpper_helper(*
this); }
565 [[nodiscard]] QString toUpper() &&
566 {
return toUpper_helper(*
this); }
567 [[nodiscard]] QString toCaseFolded()
const &
568 {
return toCaseFolded_helper(*
this); }
569 [[nodiscard]] QString toCaseFolded() &&
570 {
return toCaseFolded_helper(*
this); }
571 [[nodiscard]] QString trimmed()
const &
572 {
return trimmed_helper(*
this); }
573 [[nodiscard]] QString trimmed() &&
574 {
return trimmed_helper(*
this); }
575 [[nodiscard]] QString simplified()
const &
576 {
return simplified_helper(*
this); }
577 [[nodiscard]] QString simplified() &&
578 {
return simplified_helper(*
this); }
580 [[nodiscard]] QString toLower()
const;
581 [[nodiscard]] QString toUpper()
const;
582 [[nodiscard]] QString toCaseFolded()
const;
583 [[nodiscard]] QString trimmed()
const;
584 [[nodiscard]] QString simplified()
const;
586 [[nodiscard]] QString toHtmlEscaped()
const;
588 QString &insert(qsizetype i, QChar c);
589 QString &insert(qsizetype i,
const QChar *uc, qsizetype len);
590 inline QString &insert(qsizetype i,
const QString &s) {
return insert(i, s.constData(), s.size()); }
591 inline QString &insert(qsizetype i, QStringView v) {
return insert(i, v.data(), v.size()); }
592 QString &insert(qsizetype i, QLatin1StringView s);
593 QString &insert(qsizetype i, QUtf8StringView s);
595 QString &append(QChar c);
596 QString &append(
const QChar *uc, qsizetype len);
597 QString &append(
const QString &s);
598 inline QString &append(QStringView v) {
return append(v.data(), v.size()); }
599 QString &append(QLatin1StringView s);
600 QString &append(QUtf8StringView s);
602 inline QString &prepend(QChar c) {
return insert(0, c); }
603 inline QString &prepend(
const QChar *uc, qsizetype len) {
return insert(0, uc, len); }
604 inline QString &prepend(
const QString &s) {
return insert(0, s); }
605 inline QString &prepend(QStringView v) {
return prepend(v.data(), v.size()); }
606 inline QString &prepend(QLatin1StringView s) {
return insert(0, s); }
607 QString &prepend(QUtf8StringView s) {
return insert(0, s); }
609 QString &assign(QAnyStringView s);
610 inline QString &assign(qsizetype n, QChar c)
613 resizeForOverwrite(n);
616 template <
typename InputIterator, if_compatible_iterator<InputIterator> =
true>
617 QString &assign(InputIterator first, InputIterator last)
619 using V =
typename std::iterator_traits<InputIterator>::value_type;
620 constexpr bool IsL1C = std::is_same_v<std::remove_cv_t<V>, QLatin1Char>;
621 constexpr bool IsFwdIt = std::is_convertible_v<
622 typename std::iterator_traits<InputIterator>::iterator_category,
623 std::forward_iterator_tag
626 if constexpr (is_contiguous_iterator_v<InputIterator>) {
627 const auto p = q20::to_address(first);
628 const auto len = qsizetype(last - first);
631 return assign(QLatin1StringView(
reinterpret_cast<
const char*>(p), len));
632 else if constexpr (
sizeof(V) == 4)
633 return assign_helper(p, len);
635 return assign(QAnyStringView(p, len));
636 }
else if constexpr (
sizeof(V) == 4) {
638 if constexpr (IsFwdIt) {
641 const qsizetype requiredCapacity = 2 * std::distance(first, last);
642 reserve(requiredCapacity);
644 while (first != last) {
645 append(QChar::fromUcs4(*first));
649 }
else if constexpr (QtPrivate::IsCompatibleChar8Type<V>::value) {
650 assign_helper_char8(first, last);
652 d.data()[d.size] = u'\0';
655 d->assign(first, last, [](QChar ch)
noexcept ->
char16_t {
return ch.unicode(); });
657 d.data()[d.size] = u'\0';
662 inline QString &operator+=(QChar c) {
return append(c); }
664 inline QString &operator+=(
const QString &s) {
return append(s); }
665 inline QString &operator+=(QStringView v) {
return append(v); }
666 inline QString &operator+=(QLatin1StringView s) {
return append(s); }
667 QString &operator+=(QUtf8StringView s) {
return append(s); }
669#if defined(QT_RESTRICTED_CAST_FROM_ASCII)
670 template <qsizetype N>
671 QString &insert(qsizetype i,
const char (&ch)[N]) {
return insert(i, QUtf8StringView(ch)); }
672 template <qsizetype N>
673 QString &append(
const char (&ch)[N]) {
return append(QUtf8StringView(ch)); }
674 template <qsizetype N>
675 QString &prepend(
const char (&ch)[N]) {
return prepend(QUtf8StringView(ch)); }
676 template <qsizetype N>
677 QString &operator+=(
const char (&ch)[N]) {
return append(QUtf8StringView(ch)); }
680 QString &remove(qsizetype i, qsizetype len);
681 QString &remove(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive);
682 QString &remove(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive);
683 QString &remove(
const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive);
685 QString &removeAt(qsizetype pos)
686 {
return size_t(pos) < size_t(size()) ? remove(pos, 1) : *
this; }
687 QString &removeFirst() {
return !isEmpty() ? remove(0, 1) : *
this; }
688 QString &removeLast() {
return !isEmpty() ? remove(size() - 1, 1) : *
this; }
690 template <
typename Predicate>
691 QString &removeIf(Predicate pred)
693 removeIf_helper(pred);
697 QString &replace(qsizetype i, qsizetype len, QChar after);
698 QString &replace(qsizetype i, qsizetype len,
const QChar *s, qsizetype slen);
699 QString &replace(qsizetype i, qsizetype len,
const QString &after);
700 QString &replace(QChar before, QChar after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
701 QString &replace(
const QChar *before, qsizetype blen,
const QChar *after, qsizetype alen, Qt::CaseSensitivity cs = Qt::CaseSensitive);
702 QString &replace(QLatin1StringView before, QLatin1StringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
703 QString &replace(QLatin1StringView before,
const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
704 QString &replace(
const QString &before, QLatin1StringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
705 QString &replace(
const QString &before,
const QString &after,
706 Qt::CaseSensitivity cs = Qt::CaseSensitive);
707 QString &replace(QChar c,
const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
708 QString &replace(QChar c, QLatin1StringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
709#if QT_CONFIG(regularexpression)
710 QString &replace(
const QRegularExpression &re,
const QString &after);
711 inline QString &remove(
const QRegularExpression &re)
712 {
return replace(re, QString()); }
717 QStringList split(
const QString &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
718 Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
720 QStringList split(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
721 Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
722#ifndef QT_NO_REGULAREXPRESSION
724 QStringList split(
const QRegularExpression &sep,
725 Qt::SplitBehavior behavior = Qt::KeepEmptyParts)
const;
728 template <
typename Needle,
typename...Flags>
729 [[nodiscard]]
inline auto tokenize(Needle &&needle, Flags...flags)
const &
730 noexcept(
noexcept(qTokenize(std::declval<
const QString &>(), std::forward<Needle>(needle), flags...)))
731 ->
decltype(qTokenize(*
this, std::forward<Needle>(needle), flags...))
732 {
return qTokenize(qToStringViewIgnoringNull(*
this), std::forward<Needle>(needle), flags...); }
734 template <
typename Needle,
typename...Flags>
735 [[nodiscard]]
inline auto tokenize(Needle &&needle, Flags...flags)
const &&
736 noexcept(
noexcept(qTokenize(std::declval<
const QString>(), std::forward<Needle>(needle), flags...)))
737 ->
decltype(qTokenize(std::move(*
this), std::forward<Needle>(needle), flags...))
738 {
return qTokenize(std::move(*
this), std::forward<Needle>(needle), flags...); }
740 template <
typename Needle,
typename...Flags>
741 [[nodiscard]]
inline auto tokenize(Needle &&needle, Flags...flags) &&
742 noexcept(
noexcept(qTokenize(std::declval<QString>(), std::forward<Needle>(needle), flags...)))
743 ->
decltype(qTokenize(std::move(*
this), std::forward<Needle>(needle), flags...))
744 {
return qTokenize(std::move(*
this), std::forward<Needle>(needle), flags...); }
747 enum NormalizationForm {
750 NormalizationForm_KD,
753 [[nodiscard]] QString normalized(NormalizationForm mode, QChar::UnicodeVersion version = QChar::Unicode_Unassigned)
const;
755 [[nodiscard]] QString repeated(qsizetype times)
const;
757 const ushort *utf16()
const;
758 [[nodiscard]] QString nullTerminated()
const &;
759 [[nodiscard]] QString nullTerminated() &&;
760 QString &nullTerminate();
763 [[nodiscard]] QByteArray toLatin1()
const &
764 {
return toLatin1_helper(*
this); }
765 [[nodiscard]] QByteArray toLatin1() &&
766 {
return toLatin1_helper_inplace(*
this); }
767 [[nodiscard]] QByteArray toUtf8()
const &
768 {
return toUtf8_helper(*
this); }
769 [[nodiscard]] QByteArray toUtf8() &&
770 {
return toUtf8_helper(*
this); }
771 [[nodiscard]] QByteArray toLocal8Bit()
const &
772 {
return toLocal8Bit_helper(isNull() ?
nullptr : constData(), size()); }
773 [[nodiscard]] QByteArray toLocal8Bit() &&
774 {
return toLocal8Bit_helper(isNull() ?
nullptr : constData(), size()); }
776 [[nodiscard]] QByteArray toLatin1()
const;
777 [[nodiscard]] QByteArray toUtf8()
const;
778 [[nodiscard]] QByteArray toLocal8Bit()
const;
780 [[nodiscard]] QList<uint> toUcs4()
const;
783 static QString fromLatin1(QByteArrayView ba);
785 static inline QString fromLatin1(
const QByteArray &ba) {
return fromLatin1(QByteArrayView(ba)); }
786 static inline QString fromLatin1(
const char *str, qsizetype size)
788 return fromLatin1(QByteArrayView(str, !str || size < 0 ? qstrlen(str) : size));
790 static QString fromUtf8(QByteArrayView utf8);
792 static inline QString fromUtf8(
const QByteArray &ba) {
return fromUtf8(QByteArrayView(ba)); }
793 static inline QString fromUtf8(
const char *utf8, qsizetype size)
795 return fromUtf8(QByteArrayView(utf8, !utf8 || size < 0 ? qstrlen(utf8) : size));
797#if defined(__cpp_char8_t) || defined(Q_QDOC)
799 static inline QString fromUtf8(
const char8_t *str)
800 {
return fromUtf8(
reinterpret_cast<
const char *>(str)); }
802 static inline QString fromUtf8(
const char8_t *str, qsizetype size)
803 {
return fromUtf8(
reinterpret_cast<
const char *>(str), size); }
805 static QString fromLocal8Bit(QByteArrayView ba);
807 static inline QString fromLocal8Bit(
const QByteArray &ba) {
return fromLocal8Bit(QByteArrayView(ba)); }
808 static inline QString fromLocal8Bit(
const char *str, qsizetype size)
810 return fromLocal8Bit(QByteArrayView(str, !str || size < 0 ? qstrlen(str) : size));
812 static QString fromUtf16(
const char16_t *, qsizetype size = -1);
813 static QString fromUcs4(
const char32_t *, qsizetype size = -1);
814 static QString fromRawData(
const char16_t *unicode, qsizetype size)
816 return QString(DataPointer::fromRawData(unicode, size));
818 QT_CORE_INLINE_SINCE(6, 10)
819 static QString fromRawData(
const QChar *, qsizetype size);
821#if QT_DEPRECATED_SINCE(6
, 0
)
822 QT_DEPRECATED_VERSION_X_6_0(
"Use char16_t* overload.")
823 static QString fromUtf16(
const ushort *str, qsizetype size = -1)
824 {
return fromUtf16(
reinterpret_cast<
const char16_t *>(str), size); }
825 QT_DEPRECATED_VERSION_X_6_0(
"Use char32_t* overload.")
826 static QString fromUcs4(
const uint *str, qsizetype size = -1)
827 {
return fromUcs4(
reinterpret_cast<
const char32_t *>(str), size); }
830 inline qsizetype toWCharArray(
wchar_t *array)
const;
831 [[nodiscard]]
static inline QString fromWCharArray(
const wchar_t *string, qsizetype size = -1);
833 QString &setRawData(
const QChar *unicode, qsizetype size);
834 QString &setUnicode(
const QChar *unicode, qsizetype size);
836 QString &setUnicode(
const char16_t *utf16, qsizetype size)
837 {
return setUnicode(
reinterpret_cast<
const QChar *>(utf16), size); }
838 QString &setUtf16(
const char16_t *utf16, qsizetype size)
839 {
return setUnicode(
reinterpret_cast<
const QChar *>(utf16), size); }
841#if !QT_CORE_REMOVED_SINCE(6
, 9
)
844 QString &setUtf16(
const ushort *autf16, qsizetype asize)
845 {
return setUnicode(
reinterpret_cast<
const QChar *>(autf16), asize); }
847 int compare(
const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept;
848 int compare(QLatin1StringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept;
849 inline int compare(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept;
850 int compare(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept
851 {
return compare(QStringView{&ch, 1}, cs); }
853 static inline int compare(
const QString &s1,
const QString &s2,
854 Qt::CaseSensitivity cs = Qt::CaseSensitive)
noexcept
855 {
return s1.compare(s2, cs); }
857 static inline int compare(
const QString &s1, QLatin1StringView s2,
858 Qt::CaseSensitivity cs = Qt::CaseSensitive)
noexcept
859 {
return s1.compare(s2, cs); }
860 static inline int compare(QLatin1StringView s1,
const QString &s2,
861 Qt::CaseSensitivity cs = Qt::CaseSensitive)
noexcept
862 {
return -s2.compare(s1, cs); }
863 static int compare(
const QString &s1, QStringView s2, Qt::CaseSensitivity cs = Qt::CaseSensitive)
noexcept
864 {
return s1.compare(s2, cs); }
865 static int compare(QStringView s1,
const QString &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive)
noexcept
866 {
return -s2.compare(s1, cs); }
868 int localeAwareCompare(
const QString& s)
const;
869 inline int localeAwareCompare(QStringView s)
const;
870 static int localeAwareCompare(
const QString& s1,
const QString& s2)
871 {
return s1.localeAwareCompare(s2); }
873 static inline int localeAwareCompare(QStringView s1, QStringView s2);
875 short toShort(
bool *ok=
nullptr,
int base=10)
const
876 {
return toIntegral_helper<
short>(*
this, ok, base); }
877 ushort toUShort(
bool *ok=
nullptr,
int base=10)
const
878 {
return toIntegral_helper<ushort>(*
this, ok, base); }
879 int toInt(
bool *ok=
nullptr,
int base=10)
const
880 {
return toIntegral_helper<
int>(*
this, ok, base); }
881 uint toUInt(
bool *ok=
nullptr,
int base=10)
const
882 {
return toIntegral_helper<uint>(*
this, ok, base); }
883 long toLong(
bool *ok=
nullptr,
int base=10)
const
884 {
return toIntegral_helper<
long>(*
this, ok, base); }
885 ulong toULong(
bool *ok=
nullptr,
int base=10)
const
886 {
return toIntegral_helper<ulong>(*
this, ok, base); }
887 QT_CORE_INLINE_SINCE(6, 5)
888 qlonglong toLongLong(
bool *ok=
nullptr,
int base=10)
const;
889 QT_CORE_INLINE_SINCE(6, 5)
890 qulonglong toULongLong(
bool *ok=
nullptr,
int base=10)
const;
891 float toFloat(
bool *ok=
nullptr)
const;
892 double toDouble(
bool *ok=
nullptr)
const;
894 inline QString &setNum(
short,
int base=10);
895 inline QString &setNum(ushort,
int base=10);
896 inline QString &setNum(
int,
int base=10);
897 inline QString &setNum(uint,
int base=10);
898 inline QString &setNum(
long,
int base=10);
899 inline QString &setNum(ulong,
int base=10);
900 QString &setNum(qlonglong,
int base=10);
901 QString &setNum(qulonglong,
int base=10);
902 inline QString &setNum(
float,
char format=
'g',
int precision=6);
903 QString &setNum(
double,
char format=
'g',
int precision=6);
905 static QString number(
int,
int base=10);
906 static QString number(uint,
int base=10);
907 static QString number(
long,
int base=10);
908 static QString number(ulong,
int base=10);
909 static QString number(qlonglong,
int base=10);
910 static QString number(qulonglong,
int base=10);
911 static QString number(
double,
char format=
'g',
int precision=6);
913 friend bool comparesEqual(
const QString &s1,
const QString &s2)
noexcept
914 {
return comparesEqual(QStringView(s1), QStringView(s2)); }
915 friend Qt::strong_ordering compareThreeWay(
const QString &s1,
const QString &s2)
noexcept
916 {
return compareThreeWay(QStringView(s1), QStringView(s2)); }
917 Q_DECLARE_STRONGLY_ORDERED(QString)
920 friend bool comparesEqual(
const QString &s1, QUtf8StringView s2)
noexcept
921 {
return QtPrivate::equalStrings(s1, s2); }
923 friend Qt::strong_ordering compareThreeWay(
const QString &s1, QUtf8StringView s2)
noexcept
925 const int res = QtPrivate::compareStrings(s1, s2, Qt::CaseSensitive);
926 return Qt::compareThreeWay(res, 0);
928 Q_DECLARE_STRONGLY_ORDERED(QString, QUtf8StringView, Q_WEAK_OVERLOAD)
931 friend bool comparesEqual(
const QString &s1,
const char8_t *s2)
noexcept
932 {
return comparesEqual(s1, QUtf8StringView(s2)); }
933 friend Qt::strong_ordering compareThreeWay(
const QString &s1,
const char8_t *s2)
noexcept
934 {
return compareThreeWay(s1, QUtf8StringView(s2)); }
935 Q_DECLARE_STRONGLY_ORDERED(QString,
const char8_t *)
938 friend bool comparesEqual(
const QString &s1, QLatin1StringView s2)
noexcept
939 {
return (s1.size() == s2.size()) && QtPrivate::equalStrings(s1, s2); }
940 friend Qt::strong_ordering
941 compareThreeWay(
const QString &s1, QLatin1StringView s2)
noexcept
943 const int res = QtPrivate::compareStrings(s1, s2, Qt::CaseSensitive);
944 return Qt::compareThreeWay(res, 0);
946 Q_DECLARE_STRONGLY_ORDERED(QString, QLatin1StringView)
949 friend bool comparesEqual(
const QString &s1, std::nullptr_t)
noexcept
950 {
return s1.isEmpty(); }
951 friend Qt::strong_ordering compareThreeWay(
const QString &s1, std::nullptr_t)
noexcept
952 {
return s1.isEmpty() ? Qt::strong_ordering::equivalent : Qt::strong_ordering::greater; }
953 Q_DECLARE_STRONGLY_ORDERED(QString, std::nullptr_t)
955 friend bool comparesEqual(
const QString &s1,
const char16_t *s2)
noexcept
956 {
return comparesEqual(s1, QStringView(s2)); }
957 friend Qt::strong_ordering compareThreeWay(
const QString &s1,
const char16_t *s2)
noexcept
958 {
return compareThreeWay(s1, QStringView(s2)); }
959 Q_DECLARE_STRONGLY_ORDERED(QString,
const char16_t *)
962 friend bool comparesEqual(
const QString &lhs, QChar rhs)
noexcept
963 {
return lhs.size() == 1 && rhs == lhs.front(); }
964 friend Qt::strong_ordering compareThreeWay(
const QString &lhs, QChar rhs)
noexcept
966 const int res = compare_helper(lhs.data(), lhs.size(), &rhs, 1);
967 return Qt::compareThreeWay(res, 0);
969 Q_DECLARE_STRONGLY_ORDERED(QString, QChar)
972#if defined(QT_RESTRICTED_CAST_FROM_ASCII)
973 template <qsizetype N>
974 inline QString(
const char (&ch)[N])
975 : QString(fromUtf8(ch))
977 template <qsizetype N>
978 QString(
char (&)[N]) =
delete;
979 template <qsizetype N>
980 inline QString &operator=(
const char (&ch)[N])
981 {
return (*
this = fromUtf8(ch, N - 1)); }
982 template <qsizetype N>
983 QString &operator=(
char (&)[N]) =
delete;
985#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
986 QT_ASCII_CAST_WARN
inline QString(
const char *ch)
987 : QString(fromUtf8(ch))
989 QT_ASCII_CAST_WARN
inline QString(
const QByteArray &a)
990 : QString(fromUtf8(a))
992 QT_ASCII_CAST_WARN
inline QString &operator=(
const char *ch)
1000 QT_ASCII_CAST_WARN
inline QString &operator=(
const QByteArray &a)
1009 QT_ASCII_CAST_WARN
inline QString &prepend(
const char *s)
1010 {
return prepend(QUtf8StringView(s)); }
1011 QT_ASCII_CAST_WARN
inline QString &prepend(
const QByteArray &s)
1012 {
return prepend(QUtf8StringView(s)); }
1013 QT_ASCII_CAST_WARN
inline QString &append(
const char *s)
1014 {
return append(QUtf8StringView(s)); }
1015 QT_ASCII_CAST_WARN
inline QString &append(
const QByteArray &s)
1016 {
return append(QUtf8StringView(s)); }
1017 QT_ASCII_CAST_WARN
inline QString &insert(qsizetype i,
const char *s)
1018 {
return insert(i, QUtf8StringView(s)); }
1019 QT_ASCII_CAST_WARN
inline QString &insert(qsizetype i,
const QByteArray &s)
1020 {
return insert(i, QUtf8StringView(s)); }
1021 QT_ASCII_CAST_WARN
inline QString &operator+=(
const char *s)
1022 {
return append(QUtf8StringView(s)); }
1023 QT_ASCII_CAST_WARN
inline QString &operator+=(
const QByteArray &s)
1024 {
return append(QUtf8StringView(s)); }
1026#if QT_CORE_REMOVED_SINCE(6
, 8
)
1027 QT_ASCII_CAST_WARN
inline bool operator==(
const char *s)
const;
1028 QT_ASCII_CAST_WARN
inline bool operator!=(
const char *s)
const;
1029 QT_ASCII_CAST_WARN
inline bool operator<(
const char *s)
const;
1030 QT_ASCII_CAST_WARN
inline bool operator<=(
const char *s)
const;
1031 QT_ASCII_CAST_WARN
inline bool operator>(
const char *s)
const;
1032 QT_ASCII_CAST_WARN
inline bool operator>=(
const char *s)
const;
1034 QT_ASCII_CAST_WARN
inline bool operator==(
const QByteArray &s)
const;
1035 QT_ASCII_CAST_WARN
inline bool operator!=(
const QByteArray &s)
const;
1036 QT_ASCII_CAST_WARN
inline bool operator<(
const QByteArray &s)
const;
1037 QT_ASCII_CAST_WARN
inline bool operator>(
const QByteArray &s)
const;
1038 QT_ASCII_CAST_WARN
inline bool operator<=(
const QByteArray &s)
const;
1039 QT_ASCII_CAST_WARN
inline bool operator>=(
const QByteArray &s)
const;
1041 friend bool comparesEqual(
const QString &lhs, QByteArrayView rhs)
noexcept
1043 return QString::compare_helper(lhs.constData(), lhs.size(),
1044 rhs.constData(), rhs.size()) == 0;
1046 friend Qt::strong_ordering
1047 compareThreeWay(
const QString &lhs, QByteArrayView rhs)
noexcept
1049 const int res = QString::compare_helper(lhs.constData(), lhs.size(),
1050 rhs.constData(), rhs.size());
1051 return Qt::compareThreeWay(res, 0);
1053 Q_DECLARE_STRONGLY_ORDERED(QString, QByteArrayView, QT_ASCII_CAST_WARN)
1055 friend bool comparesEqual(
const QString &lhs,
const QByteArray &rhs)
noexcept
1056 {
return comparesEqual(lhs, QByteArrayView(rhs)); }
1057 friend Qt::strong_ordering
1058 compareThreeWay(
const QString &lhs,
const QByteArray &rhs)
noexcept
1060 return compareThreeWay(lhs, QByteArrayView(rhs));
1062 Q_DECLARE_STRONGLY_ORDERED(QString, QByteArray, QT_ASCII_CAST_WARN)
1064 friend bool comparesEqual(
const QString &lhs,
const char *rhs)
noexcept
1065 {
return comparesEqual(lhs, QByteArrayView(rhs)); }
1066 friend Qt::strong_ordering
1067 compareThreeWay(
const QString &lhs,
const char *rhs)
noexcept
1069 return compareThreeWay(lhs, QByteArrayView(rhs));
1071 Q_DECLARE_STRONGLY_ORDERED(QString,
const char *, QT_ASCII_CAST_WARN)
1076 typedef QChar *iterator;
1077 typedef const QChar *const_iterator;
1078 typedef iterator Iterator;
1079 typedef const_iterator ConstIterator;
1080 typedef std::reverse_iterator<iterator> reverse_iterator;
1081 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
1082 inline iterator begin();
1083 inline const_iterator begin()
const;
1084 inline const_iterator cbegin()
const;
1085 inline const_iterator constBegin()
const;
1086 inline iterator end();
1087 inline const_iterator end()
const;
1088 inline const_iterator cend()
const;
1089 inline const_iterator constEnd()
const;
1090 reverse_iterator rbegin() {
return reverse_iterator(end()); }
1091 reverse_iterator rend() {
return reverse_iterator(begin()); }
1092 const_reverse_iterator rbegin()
const {
return const_reverse_iterator(end()); }
1093 const_reverse_iterator rend()
const {
return const_reverse_iterator(begin()); }
1094 const_reverse_iterator crbegin()
const {
return const_reverse_iterator(end()); }
1095 const_reverse_iterator crend()
const {
return const_reverse_iterator(begin()); }
1098 typedef qsizetype size_type;
1099 typedef qptrdiff difference_type;
1100 typedef const QChar & const_reference;
1101 typedef QChar & reference;
1102 typedef QChar *pointer;
1103 typedef const QChar *const_pointer;
1104 typedef QChar value_type;
1105 inline void push_back(QChar c) { append(c); }
1106 inline void push_back(
const QString &s) { append(s); }
1107 inline void push_front(QChar c) { prepend(c); }
1108 inline void push_front(
const QString &s) { prepend(s); }
1109 void shrink_to_fit() { squeeze(); }
1110 iterator erase(const_iterator first, const_iterator last);
1111 inline iterator erase(const_iterator it) {
return erase(it, it + 1); }
1112 constexpr qsizetype max_size()
const noexcept
1117 static inline QString fromStdString(
const std::string &s);
1118 std::string toStdString()
const;
1119 static inline QString fromStdWString(
const std::wstring &s);
1120 inline std::wstring toStdWString()
const;
1122 static inline QString fromStdU16String(
const std::u16string &s);
1123 inline std::u16string toStdU16String()
const;
1124 static inline QString fromStdU32String(
const std::u32string &s);
1125 inline std::u32string toStdU32String()
const;
1127 constexpr Q_IMPLICIT
inline operator std::u16string_view()
const noexcept;
1129#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
1130 static QString fromCFString(CFStringRef string);
1131 CFStringRef toCFString()
const Q_DECL_CF_RETURNS_RETAINED;
1132 static QString fromNSString(
const NSString *string);
1133 NSString *toNSString()
const Q_DECL_NS_RETURNS_AUTORELEASED;
1136#if defined(Q_OS_WASM) || defined(Q_QDOC)
1137 static QString fromEcmaString(emscripten::val jsString);
1138 emscripten::val toEcmaString()
const;
1141 constexpr bool isNull()
const {
return d.isNull(); }
1143 bool isRightToLeft()
const;
1144 [[nodiscard]]
bool isValidUtf16()
const noexcept
1145 {
return QStringView(*
this).isValidUtf16(); }
1147 QString(qsizetype size, Qt::Initialization);
1148 Q_DECL_CONSTEXPR_DTOR
1149 explicit QString(DataPointer &&dd) : d(std::move(dd)) {}
1152#if defined(QT_NO_CAST_FROM_ASCII)
1153#define QSTRING_DECL_DELETED_ASCII_OP Q_DECL_EQ_DELETE_X("This function is not available under QT_NO_CAST_FROM_ASCII")
1154 QString &operator+=(
const char *s) QSTRING_DECL_DELETED_ASCII_OP;
1155 QString &operator+=(
const QByteArray &s) QSTRING_DECL_DELETED_ASCII_OP;
1156 QString(
const char *ch) QSTRING_DECL_DELETED_ASCII_OP;
1157 QString(
const QByteArray &a) QSTRING_DECL_DELETED_ASCII_OP;
1158 QString &operator=(
const char *ch) QSTRING_DECL_DELETED_ASCII_OP;
1159 QString &operator=(
const QByteArray &a) QSTRING_DECL_DELETED_ASCII_OP;
1160#undef QSTRING_DECL_DELETED_ASCII_OP
1164 static const char16_t _empty;
1166 void reallocData(qsizetype alloc, QArrayData::AllocationOption option);
1167 void reallocGrowData(qsizetype n);
1169 QString &assign_helper(
const char32_t *data, qsizetype len);
1171 template <
typename InputIterator>
1172 void assign_helper_char8(InputIterator first, InputIterator last);
1173 static int compare_helper(
const QChar *data1, qsizetype length1,
1174 const QChar *data2, qsizetype length2,
1175 Qt::CaseSensitivity cs = Qt::CaseSensitive)
noexcept;
1176 static int compare_helper(
const QChar *data1, qsizetype length1,
1177 const char *data2, qsizetype length2,
1178 Qt::CaseSensitivity cs = Qt::CaseSensitive)
noexcept;
1179 static int localeAwareCompare_helper(
const QChar *data1, qsizetype length1,
1180 const QChar *data2, qsizetype length2);
1181 static QString sliced_helper(QString &str, qsizetype pos, qsizetype n);
1182 static QString toLower_helper(
const QString &str);
1183 static QString toLower_helper(QString &str);
1184 static QString toUpper_helper(
const QString &str);
1185 static QString toUpper_helper(QString &str);
1186 static QString toCaseFolded_helper(
const QString &str);
1187 static QString toCaseFolded_helper(QString &str);
1188 static QString trimmed_helper(
const QString &str);
1189 static QString trimmed_helper(QString &str);
1190 static QString simplified_helper(
const QString &str);
1191 static QString simplified_helper(QString &str);
1192 static QByteArray toLatin1_helper(
const QString &);
1193 static QByteArray toLatin1_helper_inplace(QString &);
1194 static QByteArray toUtf8_helper(
const QString &);
1195 static QByteArray toLocal8Bit_helper(
const QChar *data, qsizetype size);
1196#if QT_CORE_REMOVED_SINCE(6
, 6
)
1197 static qsizetype toUcs4_helper(
const ushort *uc, qsizetype length, uint *out);
1199 static qsizetype toUcs4_helper(
const char16_t *uc, qsizetype length,
char32_t *out);
1200 static qlonglong toIntegral_helper(QStringView string,
bool *ok,
int base);
1201 static qulonglong toIntegral_helper(QStringView string,
bool *ok, uint base);
1202 template <
typename Predicate>
1203 qsizetype removeIf_helper(Predicate pred)
1205 const qsizetype result = d->eraseIf(pred);
1207 d.data()[d.size] = u'\0';
1211 friend class QStringView;
1212 friend class QByteArray;
1213 friend struct QAbstractConcatenable;
1214 template <
typename T>
friend qsizetype erase(QString &s,
const T &t);
1215 template <
typename Predicate>
friend qsizetype erase_if(QString &s, Predicate pred);
1217 template <
typename T>
static
1218 T toIntegral_helper(QStringView string,
bool *ok,
int base)
1220 using Int64 =
typename std::conditional<std::is_unsigned<T>::value, qulonglong, qlonglong>::type;
1221 using Int32 =
typename std::conditional<std::is_unsigned<T>::value, uint,
int>::type;
1224 Int64 val = toIntegral_helper(string, ok, Int32(base));
1225 if (T(val) != val) {
1233 Q_ALWAYS_INLINE
constexpr void verify([[maybe_unused]] qsizetype pos = 0,
1234 [[maybe_unused]] qsizetype n = 1)
const
1237 Q_ASSERT(pos <= d.size);
1239 Q_ASSERT(n <= d.size - pos);
1243 inline DataPointer &data_ptr() {
return d; }
1244 inline const DataPointer &data_ptr()
const {
return d; }