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 c, qsizetype size = -1);
294 void truncate(qsizetype pos);
295 void chop(qsizetype n);
297 QString &slice(qsizetype pos)
298 { verify(pos, 0);
return remove(0, pos); }
299 QString &slice(qsizetype pos, qsizetype n)
305 return remove(0, pos);
308 inline qsizetype capacity()
const;
309 inline void reserve(qsizetype size);
310 inline void squeeze();
312 inline const QChar *unicode()
const;
313 inline QChar *data();
314 inline const QChar *data()
const;
315 inline const QChar *constData()
const;
317 inline void detach();
318 inline bool isDetached()
const;
319 inline bool isSharedWith(
const QString &other)
const {
return d.isSharedWith(other.d); }
320 Q_DECL_CONSTEXPR_DTOR
void clear();
322 constexpr inline const QChar at(qsizetype i)
const;
323 constexpr inline const QChar operator[](qsizetype i)
const;
324 [[nodiscard]]
inline QChar &operator[](qsizetype i);
326 [[nodiscard]]
constexpr inline QChar front()
const {
return at(0); }
327 [[nodiscard]]
inline QChar &front();
328 [[nodiscard]]
constexpr inline QChar back()
const {
return at(size() - 1); }
329 [[nodiscard]]
inline QChar &back();
331#if QT_CORE_REMOVED_SINCE(6
, 9
)
332 [[nodiscard]] QString arg(qlonglong a,
int fieldwidth=0,
int base=10,
333 QChar fillChar = u' ')
const;
334 [[nodiscard]] QString arg(qulonglong a,
int fieldwidth=0,
int base=10,
335 QChar fillChar = u' ')
const;
336 [[nodiscard]]
inline QString arg(
long a,
int fieldwidth=0,
int base=10,
337 QChar fillChar = u' ')
const;
338 [[nodiscard]]
inline QString arg(ulong a,
int fieldwidth=0,
int base=10,
339 QChar fillChar = u' ')
const;
340 [[nodiscard]]
inline QString arg(
int a,
int fieldWidth = 0,
int base = 10,
341 QChar fillChar = u' ')
const;
342 [[nodiscard]]
inline QString arg(uint a,
int fieldWidth = 0,
int base = 10,
343 QChar fillChar = u' ')
const;
344 [[nodiscard]]
inline QString arg(
short a,
int fieldWidth = 0,
int base = 10,
345 QChar fillChar = u' ')
const;
346 [[nodiscard]]
inline QString arg(ushort a,
int fieldWidth = 0,
int base = 10,
347 QChar fillChar = u' ')
const;
348 [[nodiscard]] QString arg(
double a,
int fieldWidth = 0,
char format =
'g',
int precision = -1,
349 QChar fillChar = u' ')
const;
350 [[nodiscard]] QString arg(
char a,
int fieldWidth = 0,
351 QChar fillChar = u' ')
const;
352 [[nodiscard]] QString arg(QChar a,
int fieldWidth = 0,
353 QChar fillChar = u' ')
const;
354 [[nodiscard]] QString arg(
const QString &a,
int fieldWidth = 0,
355 QChar fillChar = u' ')
const;
356 [[nodiscard]] QString arg(QStringView a,
int fieldWidth = 0,
357 QChar fillChar = u' ')
const;
358 [[nodiscard]] QString arg(QLatin1StringView a,
int fieldWidth = 0,
359 QChar fillChar = u' ')
const;
362 template <
typename T, if_integral_non_char<T> =
true>
363 [[nodiscard]] QString arg(T a,
int fieldWidth = 0,
int base = 10,
364 QChar fillChar = u' ')
const
366 using U =
typename std::conditional<
368 std::is_enum_v<T>, std::underlying_type<T>,
369 q20::type_identity<T>
371 if constexpr (std::is_signed_v<U>)
372 return arg_impl(qlonglong(a), fieldWidth, base, fillChar);
374 return arg_impl(qulonglong(a), fieldWidth, base, fillChar);
377 template <
typename T, if_floating_point<T> =
true>
378 [[nodiscard]] QString arg(T a,
int fieldWidth = 0,
char format =
'g',
int precision = -1,
379 QChar fillChar = u' ')
const
380 {
return arg_impl(
double(a), fieldWidth, format, precision, fillChar); }
382 template <
typename T, if_string_like<T> =
true>
383 [[nodiscard]] QString arg(
const T &a,
int fieldWidth = 0, QChar fillChar = u' ')
const
384 {
return arg_impl(QAnyStringView(a), fieldWidth, fillChar); }
387 QString arg_impl(qlonglong a,
int fieldwidth,
int base, QChar fillChar)
const;
388 QString arg_impl(qulonglong a,
int fieldwidth,
int base, QChar fillChar)
const;
389 QString arg_impl(
double a,
int fieldWidth,
char format,
int precision, QChar fillChar)
const;
390 QString arg_impl(QAnyStringView a,
int fieldWidth, QChar fillChar)
const;
393 template <
typename...Args>
398 typename std::enable_if<
399 sizeof...(Args) >= 2 && std::conjunction_v<is_string_like<Args>...>,
403 arg(Args &&...args)
const
404 {
return qToStringViewIgnoringNull(*
this).arg(std::forward<Args>(args)...); }
406 static QString vasprintf(
const char *format, va_list ap) Q_ATTRIBUTE_FORMAT_PRINTF(1, 0);
407 static QString asprintf(
const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(1, 2);
409 [[nodiscard]] QT_CORE_INLINE_SINCE(6, 8)
410 qsizetype indexOf(QChar c, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
411 [[nodiscard]] QT_CORE_INLINE_SINCE(6, 12)
412 qsizetype indexOf(QLatin1StringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
413 [[nodiscard]] QT_CORE_INLINE_SINCE(6, 12)
414 qsizetype indexOf(
const QString &s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
415 [[nodiscard]] qsizetype indexOf(QStringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept
416 {
return QStringView(begin(), size()).indexOf(s, from, cs); }
417 [[nodiscard]] qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept
418 {
return lastIndexOf(c, -1, cs); }
419 [[nodiscard]] QT_CORE_INLINE_SINCE(6, 8)
420 qsizetype lastIndexOf(QChar c, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
421 [[nodiscard]] qsizetype lastIndexOf(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const
422 {
return lastIndexOf(s, size(), cs); }
423 [[nodiscard]] QT_CORE_INLINE_SINCE(6, 12)
424 qsizetype lastIndexOf(QLatin1StringView s, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
425 [[nodiscard]] qsizetype lastIndexOf(
const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const
426 {
return lastIndexOf(s, size(), cs); }
427 [[nodiscard]] QT_CORE_INLINE_SINCE(6, 12)
428 qsizetype lastIndexOf(
const QString &s, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
430 [[nodiscard]] qsizetype lastIndexOf(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept
431 {
return lastIndexOf(s, size(), cs); }
432 [[nodiscard]] qsizetype lastIndexOf(QStringView s, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept
433 {
return QStringView(begin(), size()).lastIndexOf(s, from, cs); }
435 [[nodiscard]]
inline bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
436 [[nodiscard]]
inline bool contains(
const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
437 [[nodiscard]]
inline bool contains(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
438 [[nodiscard]]
inline bool contains(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept;
439 [[nodiscard]] qsizetype count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
440 [[nodiscard]] qsizetype count(
const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
441 [[nodiscard]] qsizetype count(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
443#if QT_CONFIG(regularexpression)
444 [[nodiscard]] qsizetype indexOf(
const QRegularExpression &re, qsizetype from = 0,
445 QRegularExpressionMatch *rmatch =
nullptr)
const;
447 [[nodiscard]] qsizetype lastIndexOf(
const QRegularExpression &re, QRegularExpressionMatch *rmatch =
nullptr)
const;
450 template <
typename T = QRegularExpressionMatch, std::enable_if_t<std::is_same_v<T, QRegularExpressionMatch>,
bool> =
false>
451 [[nodiscard]] qsizetype lastIndexOf(
const QRegularExpression &re, T *rmatch =
nullptr)
const
452 {
return lastIndexOf(re, size(), rmatch); }
454 [[nodiscard]] qsizetype lastIndexOf(
const QRegularExpression &re, qsizetype from,
455 QRegularExpressionMatch *rmatch =
nullptr)
const;
456 [[nodiscard]]
bool contains(
const QRegularExpression &re, QRegularExpressionMatch *rmatch =
nullptr)
const;
457 [[nodiscard]] qsizetype count(
const QRegularExpression &re)
const;
461 SectionDefault = 0x00,
462 SectionSkipEmpty = 0x01,
463 SectionIncludeLeadingSep = 0x02,
464 SectionIncludeTrailingSep = 0x04,
465 SectionCaseInsensitiveSeps = 0x08
467 Q_DECLARE_FLAGS(SectionFlags, SectionFlag)
469 [[nodiscard]]
inline QString section(QChar sep, qsizetype start, qsizetype end = -1, SectionFlags flags = SectionDefault)
const;
470 [[nodiscard]] QString section(
const QString &in_sep, qsizetype start, qsizetype end = -1, SectionFlags flags = SectionDefault)
const;
471#if QT_CONFIG(regularexpression)
472 [[nodiscard]] QString section(
const QRegularExpression &re, qsizetype start, qsizetype end = -1, SectionFlags flags = SectionDefault)
const;
475#if QT_CORE_REMOVED_SINCE(6
, 7
)
476 QString left(qsizetype n)
const;
477 QString right(qsizetype n)
const;
478 QString mid(qsizetype position, qsizetype n = -1)
const;
480 QString first(qsizetype n)
const;
481 QString last(qsizetype n)
const;
482 QString sliced(qsizetype pos)
const;
483 QString sliced(qsizetype pos, qsizetype n)
const;
484 QString chopped(qsizetype n)
const;
486 [[nodiscard]] QString left(qsizetype n)
const &
488 if (size_t(n) >= size_t(size()))
492 [[nodiscard]] QString left(qsizetype n) &&
494 if (size_t(n) >= size_t(size()))
495 return std::move(*
this);
496 return std::move(*
this).first(n);
498 [[nodiscard]] QString right(qsizetype n)
const &
500 if (size_t(n) >= size_t(size()))
504 [[nodiscard]] QString right(qsizetype n) &&
506 if (size_t(n) >= size_t(size()))
507 return std::move(*
this);
508 return std::move(*
this).last(n);
510 [[nodiscard]] QString mid(qsizetype position, qsizetype n = -1)
const &;
511 [[nodiscard]] QString mid(qsizetype position, qsizetype n = -1) &&;
513 [[nodiscard]] QString first(qsizetype n)
const &
514 { verify(0, n);
return sliced(0, n); }
515 [[nodiscard]] QString last(qsizetype n)
const &
516 { verify(0, n);
return sliced(size() - n, n); }
517 [[nodiscard]] QString sliced(qsizetype pos)
const &
518 { verify(pos, 0);
return sliced(pos, size() - pos); }
519 [[nodiscard]] QString sliced(qsizetype pos, qsizetype n)
const &
520 { verify(pos, n);
return QString(begin() + pos, n); }
521 [[nodiscard]] QString chopped(qsizetype n)
const &
522 { verify(0, n);
return sliced(0, size() - n); }
524 [[nodiscard]] QString first(qsizetype n) &&
528 return std::move(*
this);
530 [[nodiscard]] QString last(qsizetype n) &&
531 { verify(0, n);
return sliced_helper(*
this, size() - n, n); }
532 [[nodiscard]] QString sliced(qsizetype pos) &&
533 { verify(pos, 0);
return sliced_helper(*
this, pos, size() - pos); }
534 [[nodiscard]] QString sliced(qsizetype pos, qsizetype n) &&
535 { verify(pos, n);
return sliced_helper(*
this, pos, n); }
536 [[nodiscard]] QString chopped(qsizetype n) &&
537 { verify(0, n); chop(n);
return std::move(*
this); }
539 bool startsWith(
const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
540 [[nodiscard]]
bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept
541 {
return QStringView(begin(), size()).startsWith(s, cs); }
542 bool startsWith(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
543 bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
545 bool endsWith(
const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
546 [[nodiscard]]
bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept
547 {
return QStringView(begin(), size()).endsWith(s, cs); }
548 bool endsWith(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
549 bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
551 bool isUpper()
const;
552 bool isLower()
const;
554 [[nodiscard]] QString leftJustified(qsizetype width, QChar fill = u' ',
bool trunc =
false)
const;
555 [[nodiscard]] QString rightJustified(qsizetype width, QChar fill = u' ',
bool trunc =
false)
const;
558 [[nodiscard]] QString toLower()
const &
559 {
return toLower_helper(*
this); }
560 [[nodiscard]] QString toLower() &&
561 {
return toLower_helper(*
this); }
562 [[nodiscard]] QString toUpper()
const &
563 {
return toUpper_helper(*
this); }
564 [[nodiscard]] QString toUpper() &&
565 {
return toUpper_helper(*
this); }
566 [[nodiscard]] QString toCaseFolded()
const &
567 {
return toCaseFolded_helper(*
this); }
568 [[nodiscard]] QString toCaseFolded() &&
569 {
return toCaseFolded_helper(*
this); }
570 [[nodiscard]] QString trimmed()
const &
571 {
return trimmed_helper(*
this); }
572 [[nodiscard]] QString trimmed() &&
573 {
return trimmed_helper(*
this); }
574 [[nodiscard]] QString simplified()
const &
575 {
return simplified_helper(*
this); }
576 [[nodiscard]] QString simplified() &&
577 {
return simplified_helper(*
this); }
579 [[nodiscard]] QString toLower()
const;
580 [[nodiscard]] QString toUpper()
const;
581 [[nodiscard]] QString toCaseFolded()
const;
582 [[nodiscard]] QString trimmed()
const;
583 [[nodiscard]] QString simplified()
const;
585 [[nodiscard]] QString toHtmlEscaped()
const;
587 QString &insert(qsizetype i, QChar c);
588 QString &insert(qsizetype i,
const QChar *uc, qsizetype len);
589 inline QString &insert(qsizetype i,
const QString &s) {
return insert(i, s.constData(), s.size()); }
590 inline QString &insert(qsizetype i, QStringView v) {
return insert(i, v.data(), v.size()); }
591 QString &insert(qsizetype i, QLatin1StringView s);
592 QString &insert(qsizetype i, QUtf8StringView s);
594 QString &append(QChar c);
595 QString &append(
const QChar *uc, qsizetype len);
596 QString &append(
const QString &s);
597 inline QString &append(QStringView v) {
return append(v.data(), v.size()); }
598 QString &append(QLatin1StringView s);
599 QString &append(QUtf8StringView s);
601 inline QString &prepend(QChar c) {
return insert(0, c); }
602 inline QString &prepend(
const QChar *uc, qsizetype len) {
return insert(0, uc, len); }
603 inline QString &prepend(
const QString &s) {
return insert(0, s); }
604 inline QString &prepend(QStringView v) {
return prepend(v.data(), v.size()); }
605 inline QString &prepend(QLatin1StringView s) {
return insert(0, s); }
606 QString &prepend(QUtf8StringView s) {
return insert(0, s); }
608 QString &assign(QAnyStringView s);
609 inline QString &assign(qsizetype n, QChar c)
614 template <
typename InputIterator, if_compatible_iterator<InputIterator> =
true>
615 QString &assign(InputIterator first, InputIterator last)
617 using V =
typename std::iterator_traits<InputIterator>::value_type;
618 constexpr bool IsL1C = std::is_same_v<std::remove_cv_t<V>, QLatin1Char>;
619 constexpr bool IsFwdIt = std::is_convertible_v<
620 typename std::iterator_traits<InputIterator>::iterator_category,
621 std::forward_iterator_tag
624 if constexpr (is_contiguous_iterator_v<InputIterator>) {
625 const auto p = q20::to_address(first);
626 const auto len = qsizetype(last - first);
628 return assign(QLatin1StringView(
reinterpret_cast<
const char*>(p), len));
629 else if constexpr (
sizeof(V) == 4)
630 return assign_helper(p, len);
632 return assign(QAnyStringView(p, len));
633 }
else if constexpr (
sizeof(V) == 4) {
635 if constexpr (IsFwdIt) {
636 const qsizetype requiredCapacity = 2 * std::distance(first, last);
637 reserve(requiredCapacity);
639 while (first != last) {
640 append(QChar::fromUcs4(*first));
644 }
else if constexpr (QtPrivate::IsCompatibleChar8Type<V>::value) {
645 assign_helper_char8(first, last);
646 if (d.constAllocatedCapacity())
647 d.data()[d.size] = u'\0';
650 d->assign(first, last, [](QChar ch)
noexcept ->
char16_t {
return ch.unicode(); });
651 if (d.constAllocatedCapacity())
652 d.data()[d.size] = u'\0';
657 inline QString &operator+=(QChar c) {
return append(c); }
659 inline QString &operator+=(
const QString &s) {
return append(s); }
660 inline QString &operator+=(QStringView v) {
return append(v); }
661 inline QString &operator+=(QLatin1StringView s) {
return append(s); }
662 QString &operator+=(QUtf8StringView s) {
return append(s); }
664#if defined(QT_RESTRICTED_CAST_FROM_ASCII)
665 template <qsizetype N>
666 QString &insert(qsizetype i,
const char (&ch)[N]) {
return insert(i, QUtf8StringView(ch)); }
667 template <qsizetype N>
668 QString &append(
const char (&ch)[N]) {
return append(QUtf8StringView(ch)); }
669 template <qsizetype N>
670 QString &prepend(
const char (&ch)[N]) {
return prepend(QUtf8StringView(ch)); }
671 template <qsizetype N>
672 QString &operator+=(
const char (&ch)[N]) {
return append(QUtf8StringView(ch)); }
675 QString &remove(qsizetype i, qsizetype len);
676 QString &remove(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive);
677 QString &remove(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive);
678 QString &remove(
const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive);
680 QString &removeAt(qsizetype pos)
681 {
return size_t(pos) < size_t(size()) ? remove(pos, 1) : *
this; }
682 QString &removeFirst() {
return !isEmpty() ? remove(0, 1) : *
this; }
683 QString &removeLast() {
return !isEmpty() ? remove(size() - 1, 1) : *
this; }
685 template <
typename Predicate>
686 QString &removeIf(Predicate pred)
688 removeIf_helper(pred);
692 QString &replace(qsizetype i, qsizetype len, QChar after);
693 QString &replace(qsizetype i, qsizetype len,
const QChar *s, qsizetype slen);
694 QString &replace(qsizetype i, qsizetype len,
const QString &after);
695 QString &replace(QChar before, QChar after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
696 QString &replace(
const QChar *before, qsizetype blen,
const QChar *after, qsizetype alen, Qt::CaseSensitivity cs = Qt::CaseSensitive);
697 QString &replace(QLatin1StringView before, QLatin1StringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
698 QString &replace(QLatin1StringView before,
const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
699 QString &replace(
const QString &before, QLatin1StringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
700 QString &replace(
const QString &before,
const QString &after,
701 Qt::CaseSensitivity cs = Qt::CaseSensitive);
702 QString &replace(QChar c,
const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
703 QString &replace(QChar c, QLatin1StringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
704#if QT_CONFIG(regularexpression)
705 QString &replace(
const QRegularExpression &re,
const QString &after);
706 inline QString &remove(
const QRegularExpression &re)
707 {
return replace(re, QString()); }
712 QStringList split(
const QString &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
713 Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
715 QStringList split(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
716 Qt::CaseSensitivity cs = Qt::CaseSensitive)
const;
717#ifndef QT_NO_REGULAREXPRESSION
719 QStringList split(
const QRegularExpression &sep,
720 Qt::SplitBehavior behavior = Qt::KeepEmptyParts)
const;
723 template <
typename Needle,
typename...Flags>
724 [[nodiscard]]
inline auto tokenize(Needle &&needle, Flags...flags)
const &
725 noexcept(
noexcept(qTokenize(std::declval<
const QString &>(), std::forward<Needle>(needle), flags...)))
726 ->
decltype(qTokenize(*
this, std::forward<Needle>(needle), flags...))
727 {
return qTokenize(qToStringViewIgnoringNull(*
this), std::forward<Needle>(needle), flags...); }
729 template <
typename Needle,
typename...Flags>
730 [[nodiscard]]
inline auto tokenize(Needle &&needle, Flags...flags)
const &&
731 noexcept(
noexcept(qTokenize(std::declval<
const QString>(), std::forward<Needle>(needle), flags...)))
732 ->
decltype(qTokenize(std::move(*
this), std::forward<Needle>(needle), flags...))
733 {
return qTokenize(std::move(*
this), std::forward<Needle>(needle), flags...); }
735 template <
typename Needle,
typename...Flags>
736 [[nodiscard]]
inline auto tokenize(Needle &&needle, Flags...flags) &&
737 noexcept(
noexcept(qTokenize(std::declval<QString>(), std::forward<Needle>(needle), flags...)))
738 ->
decltype(qTokenize(std::move(*
this), std::forward<Needle>(needle), flags...))
739 {
return qTokenize(std::move(*
this), std::forward<Needle>(needle), flags...); }
742 enum NormalizationForm {
745 NormalizationForm_KD,
748 [[nodiscard]] QString normalized(NormalizationForm mode, QChar::UnicodeVersion version = QChar::Unicode_Unassigned)
const;
750 [[nodiscard]] QString repeated(qsizetype times)
const;
752 const ushort *utf16()
const;
753 [[nodiscard]] QString nullTerminated()
const &;
754 [[nodiscard]] QString nullTerminated() &&;
755 QString &nullTerminate();
758 [[nodiscard]] QByteArray toLatin1()
const &
759 {
return toLatin1_helper(*
this); }
760 [[nodiscard]] QByteArray toLatin1() &&
761 {
return toLatin1_helper_inplace(*
this); }
762 [[nodiscard]] QByteArray toUtf8()
const &
763 {
return toUtf8_helper(*
this); }
764 [[nodiscard]] QByteArray toUtf8() &&
765 {
return toUtf8_helper(*
this); }
766 [[nodiscard]] QByteArray toLocal8Bit()
const &
767 {
return toLocal8Bit_helper(isNull() ?
nullptr : constData(), size()); }
768 [[nodiscard]] QByteArray toLocal8Bit() &&
769 {
return toLocal8Bit_helper(isNull() ?
nullptr : constData(), size()); }
771 [[nodiscard]] QByteArray toLatin1()
const;
772 [[nodiscard]] QByteArray toUtf8()
const;
773 [[nodiscard]] QByteArray toLocal8Bit()
const;
775 [[nodiscard]] QList<uint> toUcs4()
const;
778 static QString fromLatin1(QByteArrayView ba);
780 static inline QString fromLatin1(
const QByteArray &ba) {
return fromLatin1(QByteArrayView(ba)); }
781 static inline QString fromLatin1(
const char *str, qsizetype size)
783 return fromLatin1(QByteArrayView(str, !str || size < 0 ? qstrlen(str) : size));
785 static QString fromUtf8(QByteArrayView utf8);
787 static inline QString fromUtf8(
const QByteArray &ba) {
return fromUtf8(QByteArrayView(ba)); }
788 static inline QString fromUtf8(
const char *utf8, qsizetype size)
790 return fromUtf8(QByteArrayView(utf8, !utf8 || size < 0 ? qstrlen(utf8) : size));
792#if defined(__cpp_char8_t) || defined(Q_QDOC)
794 static inline QString fromUtf8(
const char8_t *str)
795 {
return fromUtf8(
reinterpret_cast<
const char *>(str)); }
797 static inline QString fromUtf8(
const char8_t *str, qsizetype size)
798 {
return fromUtf8(
reinterpret_cast<
const char *>(str), size); }
800 static QString fromLocal8Bit(QByteArrayView ba);
802 static inline QString fromLocal8Bit(
const QByteArray &ba) {
return fromLocal8Bit(QByteArrayView(ba)); }
803 static inline QString fromLocal8Bit(
const char *str, qsizetype size)
805 return fromLocal8Bit(QByteArrayView(str, !str || size < 0 ? qstrlen(str) : size));
807 static QString fromUtf16(
const char16_t *, qsizetype size = -1);
808 static QString fromUcs4(
const char32_t *, qsizetype size = -1);
809 static QString fromRawData(
const char16_t *unicode, qsizetype size)
811 return QString(DataPointer::fromRawData(unicode, size));
813 QT_CORE_INLINE_SINCE(6, 10)
814 static QString fromRawData(
const QChar *, qsizetype size);
816#if QT_DEPRECATED_SINCE(6
, 0
)
817 QT_DEPRECATED_VERSION_X_6_0(
"Use char16_t* overload.")
818 static QString fromUtf16(
const ushort *str, qsizetype size = -1)
819 {
return fromUtf16(
reinterpret_cast<
const char16_t *>(str), size); }
820 QT_DEPRECATED_VERSION_X_6_0(
"Use char32_t* overload.")
821 static QString fromUcs4(
const uint *str, qsizetype size = -1)
822 {
return fromUcs4(
reinterpret_cast<
const char32_t *>(str), size); }
825 inline qsizetype toWCharArray(
wchar_t *array)
const;
826 [[nodiscard]]
static inline QString fromWCharArray(
const wchar_t *string, qsizetype size = -1);
828 QString &setRawData(
const QChar *unicode, qsizetype size);
829 QString &setUnicode(
const QChar *unicode, qsizetype size);
831 QString &setUnicode(
const char16_t *utf16, qsizetype size)
832 {
return setUnicode(
reinterpret_cast<
const QChar *>(utf16), size); }
833 QString &setUtf16(
const char16_t *utf16, qsizetype size)
834 {
return setUnicode(
reinterpret_cast<
const QChar *>(utf16), size); }
836#if !QT_CORE_REMOVED_SINCE(6
, 9
)
839 QString &setUtf16(
const ushort *autf16, qsizetype asize)
840 {
return setUnicode(
reinterpret_cast<
const QChar *>(autf16), asize); }
842 int compare(
const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept;
843 int compare(QLatin1StringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept;
844 inline int compare(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept;
845 int compare(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive)
const noexcept
846 {
return compare(QStringView{&ch, 1}, cs); }
848 static inline int compare(
const QString &s1,
const QString &s2,
849 Qt::CaseSensitivity cs = Qt::CaseSensitive)
noexcept
850 {
return s1.compare(s2, cs); }
852 static inline int compare(
const QString &s1, QLatin1StringView s2,
853 Qt::CaseSensitivity cs = Qt::CaseSensitive)
noexcept
854 {
return s1.compare(s2, cs); }
855 static inline int compare(QLatin1StringView s1,
const QString &s2,
856 Qt::CaseSensitivity cs = Qt::CaseSensitive)
noexcept
857 {
return -s2.compare(s1, cs); }
858 static int compare(
const QString &s1, QStringView s2, Qt::CaseSensitivity cs = Qt::CaseSensitive)
noexcept
859 {
return s1.compare(s2, cs); }
860 static int compare(QStringView s1,
const QString &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive)
noexcept
861 {
return -s2.compare(s1, cs); }
863 int localeAwareCompare(
const QString& s)
const;
864 inline int localeAwareCompare(QStringView s)
const;
865 static int localeAwareCompare(
const QString& s1,
const QString& s2)
866 {
return s1.localeAwareCompare(s2); }
868 static inline int localeAwareCompare(QStringView s1, QStringView s2);
870 short toShort(
bool *ok=
nullptr,
int base=10)
const
871 {
return toIntegral_helper<
short>(*
this, ok, base); }
872 ushort toUShort(
bool *ok=
nullptr,
int base=10)
const
873 {
return toIntegral_helper<ushort>(*
this, ok, base); }
874 int toInt(
bool *ok=
nullptr,
int base=10)
const
875 {
return toIntegral_helper<
int>(*
this, ok, base); }
876 uint toUInt(
bool *ok=
nullptr,
int base=10)
const
877 {
return toIntegral_helper<uint>(*
this, ok, base); }
878 long toLong(
bool *ok=
nullptr,
int base=10)
const
879 {
return toIntegral_helper<
long>(*
this, ok, base); }
880 ulong toULong(
bool *ok=
nullptr,
int base=10)
const
881 {
return toIntegral_helper<ulong>(*
this, ok, base); }
882 QT_CORE_INLINE_SINCE(6, 5)
883 qlonglong toLongLong(
bool *ok=
nullptr,
int base=10)
const;
884 QT_CORE_INLINE_SINCE(6, 5)
885 qulonglong toULongLong(
bool *ok=
nullptr,
int base=10)
const;
886 float toFloat(
bool *ok=
nullptr)
const;
887 double toDouble(
bool *ok=
nullptr)
const;
889 inline QString &setNum(
short,
int base=10);
890 inline QString &setNum(ushort,
int base=10);
891 inline QString &setNum(
int,
int base=10);
892 inline QString &setNum(uint,
int base=10);
893 inline QString &setNum(
long,
int base=10);
894 inline QString &setNum(ulong,
int base=10);
895 QString &setNum(qlonglong,
int base=10);
896 QString &setNum(qulonglong,
int base=10);
897 inline QString &setNum(
float,
char format=
'g',
int precision=6);
898 QString &setNum(
double,
char format=
'g',
int precision=6);
900 static QString number(
int,
int base=10);
901 static QString number(uint,
int base=10);
902 static QString number(
long,
int base=10);
903 static QString number(ulong,
int base=10);
904 static QString number(qlonglong,
int base=10);
905 static QString number(qulonglong,
int base=10);
906 static QString number(
double,
char format=
'g',
int precision=6);
908 friend bool comparesEqual(
const QString &s1,
const QString &s2)
noexcept
909 {
return comparesEqual(QStringView(s1), QStringView(s2)); }
910 friend Qt::strong_ordering compareThreeWay(
const QString &s1,
const QString &s2)
noexcept
911 {
return compareThreeWay(QStringView(s1), QStringView(s2)); }
912 Q_DECLARE_STRONGLY_ORDERED(QString)
915 friend bool comparesEqual(
const QString &s1, QUtf8StringView s2)
noexcept
916 {
return QtPrivate::equalStrings(s1, s2); }
918 friend Qt::strong_ordering compareThreeWay(
const QString &s1, QUtf8StringView s2)
noexcept
920 const int res = QtPrivate::compareStrings(s1, s2, Qt::CaseSensitive);
921 return Qt::compareThreeWay(res, 0);
923 Q_DECLARE_STRONGLY_ORDERED(QString, QUtf8StringView, Q_WEAK_OVERLOAD)
926 friend bool comparesEqual(
const QString &s1,
const char8_t *s2)
noexcept
927 {
return comparesEqual(s1, QUtf8StringView(s2)); }
928 friend Qt::strong_ordering compareThreeWay(
const QString &s1,
const char8_t *s2)
noexcept
929 {
return compareThreeWay(s1, QUtf8StringView(s2)); }
930 Q_DECLARE_STRONGLY_ORDERED(QString,
const char8_t *)
933 friend bool comparesEqual(
const QString &s1, QLatin1StringView s2)
noexcept
934 {
return (s1.size() == s2.size()) && QtPrivate::equalStrings(s1, s2); }
935 friend Qt::strong_ordering
936 compareThreeWay(
const QString &s1, QLatin1StringView s2)
noexcept
938 const int res = QtPrivate::compareStrings(s1, s2, Qt::CaseSensitive);
939 return Qt::compareThreeWay(res, 0);
941 Q_DECLARE_STRONGLY_ORDERED(QString, QLatin1StringView)
944 friend bool comparesEqual(
const QString &s1, std::nullptr_t)
noexcept
945 {
return s1.isEmpty(); }
946 friend Qt::strong_ordering compareThreeWay(
const QString &s1, std::nullptr_t)
noexcept
947 {
return s1.isEmpty() ? Qt::strong_ordering::equivalent : Qt::strong_ordering::greater; }
948 Q_DECLARE_STRONGLY_ORDERED(QString, std::nullptr_t)
950 friend bool comparesEqual(
const QString &s1,
const char16_t *s2)
noexcept
951 {
return comparesEqual(s1, QStringView(s2)); }
952 friend Qt::strong_ordering compareThreeWay(
const QString &s1,
const char16_t *s2)
noexcept
953 {
return compareThreeWay(s1, QStringView(s2)); }
954 Q_DECLARE_STRONGLY_ORDERED(QString,
const char16_t *)
957 friend bool comparesEqual(
const QString &lhs, QChar rhs)
noexcept
958 {
return lhs.size() == 1 && rhs == lhs.front(); }
959 friend Qt::strong_ordering compareThreeWay(
const QString &lhs, QChar rhs)
noexcept
961 const int res = compare_helper(lhs.data(), lhs.size(), &rhs, 1);
962 return Qt::compareThreeWay(res, 0);
964 Q_DECLARE_STRONGLY_ORDERED(QString, QChar)
967#if defined(QT_RESTRICTED_CAST_FROM_ASCII)
968 template <qsizetype N>
969 inline QString(
const char (&ch)[N])
970 : QString(fromUtf8(ch))
972 template <qsizetype N>
973 QString(
char (&)[N]) =
delete;
974 template <qsizetype N>
975 inline QString &operator=(
const char (&ch)[N])
976 {
return (*
this = fromUtf8(ch, N - 1)); }
977 template <qsizetype N>
978 QString &operator=(
char (&)[N]) =
delete;
980#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
981 QT_ASCII_CAST_WARN
inline QString(
const char *ch)
982 : QString(fromUtf8(ch))
984 QT_ASCII_CAST_WARN
inline QString(
const QByteArray &a)
985 : QString(fromUtf8(a))
987 QT_ASCII_CAST_WARN
inline QString &operator=(
const char *ch)
995 QT_ASCII_CAST_WARN
inline QString &operator=(
const QByteArray &a)
1004 QT_ASCII_CAST_WARN
inline QString &prepend(
const char *s)
1005 {
return prepend(QUtf8StringView(s)); }
1006 QT_ASCII_CAST_WARN
inline QString &prepend(
const QByteArray &s)
1007 {
return prepend(QUtf8StringView(s)); }
1008 QT_ASCII_CAST_WARN
inline QString &append(
const char *s)
1009 {
return append(QUtf8StringView(s)); }
1010 QT_ASCII_CAST_WARN
inline QString &append(
const QByteArray &s)
1011 {
return append(QUtf8StringView(s)); }
1012 QT_ASCII_CAST_WARN
inline QString &insert(qsizetype i,
const char *s)
1013 {
return insert(i, QUtf8StringView(s)); }
1014 QT_ASCII_CAST_WARN
inline QString &insert(qsizetype i,
const QByteArray &s)
1015 {
return insert(i, QUtf8StringView(s)); }
1016 QT_ASCII_CAST_WARN
inline QString &operator+=(
const char *s)
1017 {
return append(QUtf8StringView(s)); }
1018 QT_ASCII_CAST_WARN
inline QString &operator+=(
const QByteArray &s)
1019 {
return append(QUtf8StringView(s)); }
1021#if QT_CORE_REMOVED_SINCE(6
, 8
)
1022 QT_ASCII_CAST_WARN
inline bool operator==(
const char *s)
const;
1023 QT_ASCII_CAST_WARN
inline bool operator!=(
const char *s)
const;
1024 QT_ASCII_CAST_WARN
inline bool operator<(
const char *s)
const;
1025 QT_ASCII_CAST_WARN
inline bool operator<=(
const char *s)
const;
1026 QT_ASCII_CAST_WARN
inline bool operator>(
const char *s)
const;
1027 QT_ASCII_CAST_WARN
inline bool operator>=(
const char *s)
const;
1029 QT_ASCII_CAST_WARN
inline bool operator==(
const QByteArray &s)
const;
1030 QT_ASCII_CAST_WARN
inline bool operator!=(
const QByteArray &s)
const;
1031 QT_ASCII_CAST_WARN
inline bool operator<(
const QByteArray &s)
const;
1032 QT_ASCII_CAST_WARN
inline bool operator>(
const QByteArray &s)
const;
1033 QT_ASCII_CAST_WARN
inline bool operator<=(
const QByteArray &s)
const;
1034 QT_ASCII_CAST_WARN
inline bool operator>=(
const QByteArray &s)
const;
1036 friend bool comparesEqual(
const QString &lhs, QByteArrayView rhs)
noexcept
1038 return QString::compare_helper(lhs.constData(), lhs.size(),
1039 rhs.constData(), rhs.size()) == 0;
1041 friend Qt::strong_ordering
1042 compareThreeWay(
const QString &lhs, QByteArrayView rhs)
noexcept
1044 const int res = QString::compare_helper(lhs.constData(), lhs.size(),
1045 rhs.constData(), rhs.size());
1046 return Qt::compareThreeWay(res, 0);
1048 Q_DECLARE_STRONGLY_ORDERED(QString, QByteArrayView, QT_ASCII_CAST_WARN)
1050 friend bool comparesEqual(
const QString &lhs,
const QByteArray &rhs)
noexcept
1051 {
return comparesEqual(lhs, QByteArrayView(rhs)); }
1052 friend Qt::strong_ordering
1053 compareThreeWay(
const QString &lhs,
const QByteArray &rhs)
noexcept
1055 return compareThreeWay(lhs, QByteArrayView(rhs));
1057 Q_DECLARE_STRONGLY_ORDERED(QString, QByteArray, QT_ASCII_CAST_WARN)
1059 friend bool comparesEqual(
const QString &lhs,
const char *rhs)
noexcept
1060 {
return comparesEqual(lhs, QByteArrayView(rhs)); }
1061 friend Qt::strong_ordering
1062 compareThreeWay(
const QString &lhs,
const char *rhs)
noexcept
1064 return compareThreeWay(lhs, QByteArrayView(rhs));
1066 Q_DECLARE_STRONGLY_ORDERED(QString,
const char *, QT_ASCII_CAST_WARN)
1071 typedef QChar *iterator;
1072 typedef const QChar *const_iterator;
1073 typedef iterator Iterator;
1074 typedef const_iterator ConstIterator;
1075 typedef std::reverse_iterator<iterator> reverse_iterator;
1076 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
1077 inline iterator begin();
1078 inline const_iterator begin()
const;
1079 inline const_iterator cbegin()
const;
1080 inline const_iterator constBegin()
const;
1081 inline iterator end();
1082 inline const_iterator end()
const;
1083 inline const_iterator cend()
const;
1084 inline const_iterator constEnd()
const;
1085 reverse_iterator rbegin() {
return reverse_iterator(end()); }
1086 reverse_iterator rend() {
return reverse_iterator(begin()); }
1087 const_reverse_iterator rbegin()
const {
return const_reverse_iterator(end()); }
1088 const_reverse_iterator rend()
const {
return const_reverse_iterator(begin()); }
1089 const_reverse_iterator crbegin()
const {
return const_reverse_iterator(end()); }
1090 const_reverse_iterator crend()
const {
return const_reverse_iterator(begin()); }
1093 typedef qsizetype size_type;
1094 typedef qptrdiff difference_type;
1095 typedef const QChar & const_reference;
1096 typedef QChar & reference;
1097 typedef QChar *pointer;
1098 typedef const QChar *const_pointer;
1099 typedef QChar value_type;
1100 inline void push_back(QChar c) { append(c); }
1101 inline void push_back(
const QString &s) { append(s); }
1102 inline void push_front(QChar c) { prepend(c); }
1103 inline void push_front(
const QString &s) { prepend(s); }
1104 void shrink_to_fit() { squeeze(); }
1105 iterator erase(const_iterator first, const_iterator last);
1106 inline iterator erase(const_iterator it) {
return erase(it, it + 1); }
1107 constexpr qsizetype max_size()
const noexcept
1112 static inline QString fromStdString(
const std::string &s);
1113 std::string toStdString()
const;
1114 static inline QString fromStdWString(
const std::wstring &s);
1115 inline std::wstring toStdWString()
const;
1117 static inline QString fromStdU16String(
const std::u16string &s);
1118 inline std::u16string toStdU16String()
const;
1119 static inline QString fromStdU32String(
const std::u32string &s);
1120 inline std::u32string toStdU32String()
const;
1122 constexpr Q_IMPLICIT
inline operator std::u16string_view()
const noexcept;
1124#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
1125 static QString fromCFString(CFStringRef string);
1126 CFStringRef toCFString()
const Q_DECL_CF_RETURNS_RETAINED;
1127 static QString fromNSString(
const NSString *string);
1128 NSString *toNSString()
const Q_DECL_NS_RETURNS_AUTORELEASED;
1131#if defined(Q_OS_WASM) || defined(Q_QDOC)
1132 static QString fromEcmaString(emscripten::val jsString);
1133 emscripten::val toEcmaString()
const;
1136 constexpr bool isNull()
const {
return d.isNull(); }
1138 bool isRightToLeft()
const;
1139 [[nodiscard]]
bool isValidUtf16()
const noexcept
1140 {
return QStringView(*
this).isValidUtf16(); }
1142 QString(qsizetype size, Qt::Initialization);
1143 Q_DECL_CONSTEXPR_DTOR
1144 explicit QString(DataPointer &&dd) : d(std::move(dd)) {}
1147#if defined(QT_NO_CAST_FROM_ASCII)
1148#define QSTRING_DECL_DELETED_ASCII_OP Q_DECL_EQ_DELETE_X("This function is not available under QT_NO_CAST_FROM_ASCII")
1149 QString &operator+=(
const char *s) QSTRING_DECL_DELETED_ASCII_OP;
1150 QString &operator+=(
const QByteArray &s) QSTRING_DECL_DELETED_ASCII_OP;
1151 QString(
const char *ch) QSTRING_DECL_DELETED_ASCII_OP;
1152 QString(
const QByteArray &a) QSTRING_DECL_DELETED_ASCII_OP;
1153 QString &operator=(
const char *ch) QSTRING_DECL_DELETED_ASCII_OP;
1154 QString &operator=(
const QByteArray &a) QSTRING_DECL_DELETED_ASCII_OP;
1155#undef QSTRING_DECL_DELETED_ASCII_OP
1159 static const char16_t _empty;
1161 void reallocData(qsizetype alloc, QArrayData::AllocationOption option);
1162 void reallocGrowData(qsizetype n);
1164 QString &assign_helper(
const char32_t *data, qsizetype len);
1166 template <
typename InputIterator>
1167 void assign_helper_char8(InputIterator first, InputIterator last);
1168 static int compare_helper(
const QChar *data1, qsizetype length1,
1169 const QChar *data2, qsizetype length2,
1170 Qt::CaseSensitivity cs = Qt::CaseSensitive)
noexcept;
1171 static int compare_helper(
const QChar *data1, qsizetype length1,
1172 const char *data2, qsizetype length2,
1173 Qt::CaseSensitivity cs = Qt::CaseSensitive)
noexcept;
1174 static int localeAwareCompare_helper(
const QChar *data1, qsizetype length1,
1175 const QChar *data2, qsizetype length2);
1176 static QString sliced_helper(QString &str, qsizetype pos, qsizetype n);
1177 static QString toLower_helper(
const QString &str);
1178 static QString toLower_helper(QString &str);
1179 static QString toUpper_helper(
const QString &str);
1180 static QString toUpper_helper(QString &str);
1181 static QString toCaseFolded_helper(
const QString &str);
1182 static QString toCaseFolded_helper(QString &str);
1183 static QString trimmed_helper(
const QString &str);
1184 static QString trimmed_helper(QString &str);
1185 static QString simplified_helper(
const QString &str);
1186 static QString simplified_helper(QString &str);
1187 static QByteArray toLatin1_helper(
const QString &);
1188 static QByteArray toLatin1_helper_inplace(QString &);
1189 static QByteArray toUtf8_helper(
const QString &);
1190 static QByteArray toLocal8Bit_helper(
const QChar *data, qsizetype size);
1191#if QT_CORE_REMOVED_SINCE(6
, 6
)
1192 static qsizetype toUcs4_helper(
const ushort *uc, qsizetype length, uint *out);
1194 static qsizetype toUcs4_helper(
const char16_t *uc, qsizetype length,
char32_t *out);
1195 static qlonglong toIntegral_helper(QStringView string,
bool *ok,
int base);
1196 static qulonglong toIntegral_helper(QStringView string,
bool *ok, uint base);
1197 template <
typename Predicate>
1198 qsizetype removeIf_helper(Predicate pred)
1200 const qsizetype result = d->eraseIf(pred);
1202 d.data()[d.size] = u'\0';
1206 friend class QStringView;
1207 friend class QByteArray;
1208 friend struct QAbstractConcatenable;
1209 template <
typename T>
friend qsizetype erase(QString &s,
const T &t);
1210 template <
typename Predicate>
friend qsizetype erase_if(QString &s, Predicate pred);
1212 template <
typename T>
static
1213 T toIntegral_helper(QStringView string,
bool *ok,
int base)
1215 using Int64 =
typename std::conditional<std::is_unsigned<T>::value, qulonglong, qlonglong>::type;
1216 using Int32 =
typename std::conditional<std::is_unsigned<T>::value, uint,
int>::type;
1219 Int64 val = toIntegral_helper(string, ok, Int32(base));
1220 if (T(val) != val) {
1228 Q_ALWAYS_INLINE
constexpr void verify([[maybe_unused]] qsizetype pos = 0,
1229 [[maybe_unused]] qsizetype n = 1)
const
1232 Q_ASSERT(pos <= d.size);
1234 Q_ASSERT(n <= d.size - pos);
1238 inline DataPointer &data_ptr() {
return d; }
1239 inline const DataPointer &data_ptr()
const {
return d; }