Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qstring.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// Copyright (C) 2019 Intel Corporation.
3// Copyright (C) 2019 Mail.ru Group.
4// Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
5// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
6
7#ifndef QSTRING_H
8#define QSTRING_H
9
10#if defined(QT_NO_CAST_FROM_ASCII) && defined(QT_RESTRICTED_CAST_FROM_ASCII)
11#error QT_NO_CAST_FROM_ASCII and QT_RESTRICTED_CAST_FROM_ASCII must not be defined at the same time
12#endif
13
14#include <QtCore/qchar.h>
15#include <QtCore/qcompare.h>
16#include <QtCore/qbytearray.h>
17#include <QtCore/qbytearrayview.h>
18#include <QtCore/qarraydata.h>
19#include <QtCore/qlatin1stringview.h>
20#include <QtCore/qnamespace.h>
21#include <QtCore/qstringliteral.h>
22#include <QtCore/qstringalgorithms.h>
23#include <QtCore/qanystringview.h>
24#include <QtCore/qstringtokenizer.h>
25
26#include <string>
27#include <iterator>
28#include <QtCore/q20memory.h>
29#include <string_view>
30
31#include <stdarg.h>
32
33#ifdef truncate
34#error qstring.h must be included before any header file that defines truncate
35#endif
36
37#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
40#endif
41
42class tst_QString;
43
45
48class QString;
49
50namespace QtPrivate {
51template <bool...B> class BoolList;
52
53template <typename Char>
55 std::is_same<Char, char32_t>;
56template <typename Char>
58 = IsCompatibleChar32TypeHelper<q20::remove_cvref_t<Char>>;
59}
60
61// Qt 4.x compatibility
62
63//
64// QLatin1StringView inline implementations
65//
66constexpr bool QtPrivate::isLatin1(QLatin1StringView) noexcept
67{ return true; }
68
69//
70// QStringView members that require QLatin1StringView:
71//
75{ return QtPrivate::startsWith(*this, s, cs); }
77{ return QtPrivate::endsWith(*this, s, cs); }
81{ return indexOf(s, 0, cs) != qsizetype(-1); }
88
89//
90// QAnyStringView members that require QLatin1StringView
91//
92
94 : m_data{str.data()}, m_size{size_t(str.size() << SizeShift) | Tag::Latin1} {}
95
96constexpr QLatin1StringView QAnyStringView::asLatin1StringView() const
97{
98 Q_ASSERT(isLatin1());
99 return {m_data_utf8, size()};
100}
101
102
103template <typename Visitor>
104constexpr decltype(auto) QAnyStringView::visit(Visitor &&v) const
105{
106 if (isUtf16())
107 return std::forward<Visitor>(v)(asStringView());
108 else if (isLatin1())
109 return std::forward<Visitor>(v)(asLatin1StringView());
110 else
111 return std::forward<Visitor>(v)(asUtf8StringView());
112}
113
114//
115// QAnyStringView members that require QAnyStringView::visit()
116//
117
119{
120 return visit([] (auto that) { return QAnyStringView::toQChar(that.front()); });
121}
123{
124 return visit([] (auto that) { return QAnyStringView::toQChar(that.back()); });
125}
126
127
128class Q_CORE_EXPORT QString
129{
130 typedef QTypedArrayData<char16_t> Data;
131
132 friend class ::tst_QString;
133
134 template <typename Iterator>
135 static constexpr bool is_contiguous_iterator_v =
136 // Can't use contiguous_iterator_tag here, as STL impls can't agree on feature macro.
137 // To avoid differences in C++20 and C++17 builds, treat only pointers as contiguous
138 // for now:
139 // std::contiguous_iterator<Iterator>;
140 std::is_pointer_v<Iterator>;
141
142 template <typename Char>
143 using is_compatible_char_helper = std::disjunction<
147 std::is_same<Char, QLatin1Char> // special case
148 >;
149
150 template <typename Iterator>
151 static constexpr bool is_compatible_iterator_v = std::conjunction_v<
152 std::is_convertible<
153 typename std::iterator_traits<Iterator>::iterator_category,
154 std::input_iterator_tag
155 >,
156 is_compatible_char_helper<typename std::iterator_traits<Iterator>::value_type>
157 >;
158
159 template <typename Iterator>
160 using if_compatible_iterator = std::enable_if_t<is_compatible_iterator_v<Iterator>, bool>;
161
162public:
164
165 constexpr QString() noexcept;
166 explicit QString(const QChar *unicode, qsizetype size = -1);
167 QString(QChar c);
169 inline QString(QLatin1StringView latin1);
171#if defined(__cpp_char8_t) || defined(Q_QDOC)
173 inline QString(const char8_t *str)
174 : QString(fromUtf8(str))
175 {}
176#endif
177 inline QString(const QString &) noexcept;
178 inline ~QString();
179 QString &operator=(QChar c);
180 QString &operator=(const QString &) noexcept;
181 QString &operator=(QLatin1StringView latin1);
182 inline QString(QString &&other) noexcept
183 = default;
184 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QString)
185 void swap(QString &other) noexcept { d.swap(other.d); }
186 inline qsizetype size() const noexcept { return d.size; }
187#if QT_DEPRECATED_SINCE(6, 4)
188 QT_DEPRECATED_VERSION_X_6_4("Use size() or length() instead.")
189 inline qsizetype count() const { return d.size; }
190#endif
191 inline qsizetype length() const noexcept { return d.size; }
192 inline bool isEmpty() const noexcept { return d.size == 0; }
193 void resize(qsizetype size);
194 void resize(qsizetype size, QChar fillChar);
195 void resizeForOverwrite(qsizetype size);
196
198 void truncate(qsizetype pos);
199 void chop(qsizetype n);
200
202 { verify(pos, 0); return remove(0, pos); }
204 {
205 verify(pos, n);
206 if (isNull())
207 return *this;
208 resize(pos + n);
209 return remove(0, pos);
210 }
211
212 inline qsizetype capacity() const;
213 inline void reserve(qsizetype size);
214 inline void squeeze();
215
216 inline const QChar *unicode() const;
217 inline QChar *data();
218 inline const QChar *data() const;
219 inline const QChar *constData() const;
220
221 inline void detach();
222 inline bool isDetached() const;
223 inline bool isSharedWith(const QString &other) const { return d.isSharedWith(other.d); }
224 inline void clear();
225
226 inline const QChar at(qsizetype i) const;
227 inline const QChar operator[](qsizetype i) const;
228 [[nodiscard]] inline QChar &operator[](qsizetype i);
229
230 [[nodiscard]] inline QChar front() const { return at(0); }
231 [[nodiscard]] inline QChar &front();
232 [[nodiscard]] inline QChar back() const { return at(size() - 1); }
233 [[nodiscard]] inline QChar &back();
234
235 [[nodiscard]] QString arg(qlonglong a, int fieldwidth=0, int base=10,
236 QChar fillChar = u' ') const;
237 [[nodiscard]] QString arg(qulonglong a, int fieldwidth=0, int base=10,
238 QChar fillChar = u' ') const;
239 [[nodiscard]] inline QString arg(long a, int fieldwidth=0, int base=10,
240 QChar fillChar = u' ') const;
241 [[nodiscard]] inline QString arg(ulong a, int fieldwidth=0, int base=10,
242 QChar fillChar = u' ') const;
243 [[nodiscard]] inline QString arg(int a, int fieldWidth = 0, int base = 10,
244 QChar fillChar = u' ') const;
245 [[nodiscard]] inline QString arg(uint a, int fieldWidth = 0, int base = 10,
246 QChar fillChar = u' ') const;
247 [[nodiscard]] inline QString arg(short a, int fieldWidth = 0, int base = 10,
248 QChar fillChar = u' ') const;
249 [[nodiscard]] inline QString arg(ushort a, int fieldWidth = 0, int base = 10,
250 QChar fillChar = u' ') const;
251 [[nodiscard]] QString arg(double a, int fieldWidth = 0, char format = 'g', int precision = -1,
252 QChar fillChar = u' ') const;
253 [[nodiscard]] QString arg(char a, int fieldWidth = 0,
254 QChar fillChar = u' ') const;
255 [[nodiscard]] QString arg(QChar a, int fieldWidth = 0,
256 QChar fillChar = u' ') const;
257 [[nodiscard]] QString arg(const QString &a, int fieldWidth = 0,
258 QChar fillChar = u' ') const;
259 [[nodiscard]] QString arg(QStringView a, int fieldWidth = 0,
260 QChar fillChar = u' ') const;
261 [[nodiscard]] QString arg(QLatin1StringView a, int fieldWidth = 0,
262 QChar fillChar = u' ') const;
263private:
264 template <typename T>
265 using is_convertible_to_view_or_qstring = std::disjunction<
266 std::is_convertible<T, QString>,
267 std::is_convertible<T, QStringView>,
268 std::is_convertible<T, QLatin1StringView>
269 >;
270public:
271 template <typename...Args>
272 [[nodiscard]]
273#ifdef Q_QDOC
274 QString
275#else
276 typename std::enable_if<
277 sizeof...(Args) >= 2 && std::is_same<
278 QtPrivate::BoolList<is_convertible_to_view_or_qstring<Args>::value..., true>,
279 QtPrivate::BoolList<true, is_convertible_to_view_or_qstring<Args>::value...>
280 >::value,
281 QString
282 >::type
283#endif
284 arg(Args &&...args) const
285 { return qToStringViewIgnoringNull(*this).arg(std::forward<Args>(args)...); }
286
287 static QString vasprintf(const char *format, va_list ap) Q_ATTRIBUTE_FORMAT_PRINTF(1, 0);
288 static QString asprintf(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(1, 2);
289
290 [[nodiscard]] QT_CORE_INLINE_SINCE(6, 7)
291 qsizetype indexOf(QChar c, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
292 [[nodiscard]] qsizetype indexOf(QLatin1StringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
293 [[nodiscard]] qsizetype indexOf(const QString &s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
294 [[nodiscard]] qsizetype indexOf(QStringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
295 { return QtPrivate::findString(*this, from, s, cs); }
297 { return lastIndexOf(c, -1, cs); }
298 [[nodiscard]] QT_CORE_INLINE_SINCE(6, 7)
299 qsizetype lastIndexOf(QChar c, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
300 [[nodiscard]] qsizetype lastIndexOf(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
301 { return lastIndexOf(s, size(), cs); }
304 { return lastIndexOf(s, size(), cs); }
305 [[nodiscard]] qsizetype lastIndexOf(const QString &s, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
306
308 { return lastIndexOf(s, size(), cs); }
310 { return QtPrivate::lastIndexOf(*this, from, s, cs); }
311
312 [[nodiscard]] inline bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
313 [[nodiscard]] inline bool contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
314 [[nodiscard]] inline bool contains(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
315 [[nodiscard]] inline bool contains(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
316 [[nodiscard]] qsizetype count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
317 [[nodiscard]] qsizetype count(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
319
320#if QT_CONFIG(regularexpression)
321 [[nodiscard]] qsizetype indexOf(const QRegularExpression &re, qsizetype from = 0,
322 QRegularExpressionMatch *rmatch = nullptr) const;
323#ifdef Q_QDOC
324 [[nodiscard]] qsizetype lastIndexOf(const QRegularExpression &re, QRegularExpressionMatch *rmatch = nullptr) const;
325#else
326 // prevent an ambiguity when called like this: lastIndexOf(re, 0)
327 template <typename T = QRegularExpressionMatch, std::enable_if_t<std::is_same_v<T, QRegularExpressionMatch>, bool> = false>
328 [[nodiscard]] qsizetype lastIndexOf(const QRegularExpression &re, T *rmatch = nullptr) const
329 { return lastIndexOf(re, size(), rmatch); }
330#endif
331 [[nodiscard]] qsizetype lastIndexOf(const QRegularExpression &re, qsizetype from,
332 QRegularExpressionMatch *rmatch = nullptr) const;
333 [[nodiscard]] bool contains(const QRegularExpression &re, QRegularExpressionMatch *rmatch = nullptr) const;
334 [[nodiscard]] qsizetype count(const QRegularExpression &re) const;
335#endif
336
338 SectionDefault = 0x00,
339 SectionSkipEmpty = 0x01,
340 SectionIncludeLeadingSep = 0x02,
341 SectionIncludeTrailingSep = 0x04,
342 SectionCaseInsensitiveSeps = 0x08
343 };
344 Q_DECLARE_FLAGS(SectionFlags, SectionFlag)
345
346 [[nodiscard]] inline QString section(QChar sep, qsizetype start, qsizetype end = -1, SectionFlags flags = SectionDefault) const;
347 [[nodiscard]] QString section(const QString &in_sep, qsizetype start, qsizetype end = -1, SectionFlags flags = SectionDefault) const;
348#if QT_CONFIG(regularexpression)
349 [[nodiscard]] QString section(const QRegularExpression &re, qsizetype start, qsizetype end = -1, SectionFlags flags = SectionDefault) const;
350#endif
351
352#if QT_CORE_REMOVED_SINCE(6, 7)
353 QString left(qsizetype n) const;
354 QString right(qsizetype n) const;
355 QString mid(qsizetype position, qsizetype n = -1) const;
356
357 QString first(qsizetype n) const;
358 QString last(qsizetype n) const;
359 QString sliced(qsizetype pos) const;
360 QString sliced(qsizetype pos, qsizetype n) const;
361 QString chopped(qsizetype n) const;
362#else
363 [[nodiscard]] QString left(qsizetype n) const &
364 {
365 if (size_t(n) >= size_t(size()))
366 return *this;
367 return first(n);
368 }
369 [[nodiscard]] QString left(qsizetype n) &&
370 {
371 if (size_t(n) >= size_t(size()))
372 return std::move(*this);
373 return std::move(*this).first(n);
374 }
375 [[nodiscard]] QString right(qsizetype n) const &
376 {
377 if (size_t(n) >= size_t(size()))
378 return *this;
379 return last(n);
380 }
381 [[nodiscard]] QString right(qsizetype n) &&
382 {
383 if (size_t(n) >= size_t(size()))
384 return std::move(*this);
385 return std::move(*this).last(n);
386 }
387 [[nodiscard]] QString mid(qsizetype position, qsizetype n = -1) const &;
388 [[nodiscard]] QString mid(qsizetype position, qsizetype n = -1) &&;
389
390 [[nodiscard]] QString first(qsizetype n) const &
391 { verify(0, n); return sliced(0, n); }
392 [[nodiscard]] QString last(qsizetype n) const &
393 { verify(0, n); return sliced(size() - n, n); }
394 [[nodiscard]] QString sliced(qsizetype pos) const &
395 { verify(pos, 0); return sliced(pos, size() - pos); }
396 [[nodiscard]] QString sliced(qsizetype pos, qsizetype n) const &
397 { verify(pos, n); return QString(begin() + pos, n); }
398 [[nodiscard]] QString chopped(qsizetype n) const &
399 { verify(0, n); return sliced(0, size() - n); }
400
401 [[nodiscard]] QString first(qsizetype n) &&
402 {
403 verify(0, n);
404 resize(n); // may detach and allocate memory
405 return std::move(*this);
406 }
407 [[nodiscard]] QString last(qsizetype n) &&
408 { verify(0, n); return sliced_helper(*this, size() - n, n); }
409 [[nodiscard]] QString sliced(qsizetype pos) &&
410 { verify(pos, 0); return sliced_helper(*this, pos, size() - pos); }
412 { verify(pos, n); return sliced_helper(*this, pos, n); }
413 [[nodiscard]] QString chopped(qsizetype n) &&
414 { verify(0, n); return std::move(*this).first(size() - n); }
415#endif
416 bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
417 [[nodiscard]] bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
418 { return QtPrivate::startsWith(*this, s, cs); }
419 bool startsWith(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
420 bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
421
422 bool endsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
423 [[nodiscard]] bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
424 { return QtPrivate::endsWith(*this, s, cs); }
425 bool endsWith(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
426 bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
427
428 bool isUpper() const;
429 bool isLower() const;
430
431 [[nodiscard]] QString leftJustified(qsizetype width, QChar fill = u' ', bool trunc = false) const;
432 [[nodiscard]] QString rightJustified(qsizetype width, QChar fill = u' ', bool trunc = false) const;
433
434#if !defined(Q_QDOC)
435 [[nodiscard]] QString toLower() const &
436 { return toLower_helper(*this); }
437 [[nodiscard]] QString toLower() &&
438 { return toLower_helper(*this); }
439 [[nodiscard]] QString toUpper() const &
440 { return toUpper_helper(*this); }
441 [[nodiscard]] QString toUpper() &&
442 { return toUpper_helper(*this); }
443 [[nodiscard]] QString toCaseFolded() const &
444 { return toCaseFolded_helper(*this); }
445 [[nodiscard]] QString toCaseFolded() &&
446 { return toCaseFolded_helper(*this); }
447 [[nodiscard]] QString trimmed() const &
448 { return trimmed_helper(*this); }
449 [[nodiscard]] QString trimmed() &&
450 { return trimmed_helper(*this); }
451 [[nodiscard]] QString simplified() const &
452 { return simplified_helper(*this); }
453 [[nodiscard]] QString simplified() &&
454 { return simplified_helper(*this); }
455#else
456 [[nodiscard]] QString toLower() const;
457 [[nodiscard]] QString toUpper() const;
458 [[nodiscard]] QString toCaseFolded() const;
459 [[nodiscard]] QString trimmed() const;
460 [[nodiscard]] QString simplified() const;
461#endif
462 [[nodiscard]] QString toHtmlEscaped() const;
463
466 inline QString &insert(qsizetype i, const QString &s) { return insert(i, s.constData(), s.size()); }
467 inline QString &insert(qsizetype i, QStringView v) { return insert(i, v.data(), v.size()); }
470
472 QString &append(const QChar *uc, qsizetype len);
473 QString &append(const QString &s);
474 inline QString &append(QStringView v) { return append(v.data(), v.size()); }
477
478 inline QString &prepend(QChar c) { return insert(0, c); }
479 inline QString &prepend(const QChar *uc, qsizetype len) { return insert(0, uc, len); }
480 inline QString &prepend(const QString &s) { return insert(0, s); }
481 inline QString &prepend(QStringView v) { return prepend(v.data(), v.size()); }
482 inline QString &prepend(QLatin1StringView s) { return insert(0, s); }
484
485 QString &assign(QAnyStringView s);
487 {
488 Q_ASSERT(n >= 0);
489 return fill(c, n);
490 }
491 template <typename InputIterator, if_compatible_iterator<InputIterator> = true>
492 QString &assign(InputIterator first, InputIterator last)
493 {
494 using V = typename std::iterator_traits<InputIterator>::value_type;
495 constexpr bool IsL1C = std::is_same_v<std::remove_cv_t<V>, QLatin1Char>;
496 constexpr bool IsFwdIt = std::is_convertible_v<
497 typename std::iterator_traits<InputIterator>::iterator_category,
498 std::forward_iterator_tag
499 >;
500
501 if constexpr (is_contiguous_iterator_v<InputIterator>) {
502 const auto p = q20::to_address(first);
503 const auto len = qsizetype(last - first);
504 if constexpr (IsL1C)
505 return assign(QLatin1StringView(reinterpret_cast<const char*>(p), len));
506 else if constexpr (sizeof(V) == 4)
507 return assign_helper(p, len);
508 else
509 return assign(QAnyStringView(p, len));
510 } else if constexpr (sizeof(V) == 4) { // non-contiguous iterator, feed data piecemeal
511 resize(0);
512 if constexpr (IsFwdIt) {
513 const qsizetype requiredCapacity = 2 * std::distance(first, last);
514 reserve(requiredCapacity);
515 }
516 while (first != last) {
517 append(QChar::fromUcs4(*first));
518 ++first;
519 }
520 return *this;
521 } else if constexpr (QtPrivate::IsCompatibleChar8Type<V>::value) {
522 assign_helper_char8(first, last);
523 d.data()[d.size] = u'\0';
524 return *this;
525 } else {
526 d.assign(first, last, [](QChar ch) -> char16_t { return ch.unicode(); });
527 d.data()[d.size] = u'\0';
528 return *this;
529 }
530 }
531
532 inline QString &operator+=(QChar c) { return append(c); }
533
534 inline QString &operator+=(const QString &s) { return append(s); }
535 inline QString &operator+=(QStringView v) { return append(v); }
538
539#if defined(QT_RESTRICTED_CAST_FROM_ASCII)
540 template <qsizetype N>
541 QString &insert(qsizetype i, const char (&ch)[N]) { return insert(i, QUtf8StringView(ch)); }
542 template <qsizetype N>
543 QString &append(const char (&ch)[N]) { return append(QUtf8StringView(ch)); }
544 template <qsizetype N>
545 QString &prepend(const char (&ch)[N]) { return prepend(QUtf8StringView(ch)); }
546 template <qsizetype N>
547 QString &operator+=(const char (&ch)[N]) { return append(QUtf8StringView(ch)); }
548#endif
549
554
556 { return size_t(pos) < size_t(size()) ? remove(pos, 1) : *this; }
557 QString &removeFirst() { return !isEmpty() ? remove(0, 1) : *this; }
558 QString &removeLast() { return !isEmpty() ? remove(size() - 1, 1) : *this; }
559
560 template <typename Predicate>
561 QString &removeIf(Predicate pred)
562 {
563 removeIf_helper(pred);
564 return *this;
565 }
566
567 QString &replace(qsizetype i, qsizetype len, QChar after);
568 QString &replace(qsizetype i, qsizetype len, const QChar *s, qsizetype slen);
569 QString &replace(qsizetype i, qsizetype len, const QString &after);
570 QString &replace(QChar before, QChar after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
571 QString &replace(const QChar *before, qsizetype blen, const QChar *after, qsizetype alen, Qt::CaseSensitivity cs = Qt::CaseSensitive);
573 QString &replace(QLatin1StringView before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
574 QString &replace(const QString &before, QLatin1StringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
575 QString &replace(const QString &before, const QString &after,
577 QString &replace(QChar c, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
579#if QT_CONFIG(regularexpression)
580 QString &replace(const QRegularExpression &re, const QString &after);
581 inline QString &remove(const QRegularExpression &re)
582 { return replace(re, QString()); }
583#endif
584
585public:
586 [[nodiscard]]
587 QStringList split(const QString &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
589 [[nodiscard]]
590 QStringList split(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
592#ifndef QT_NO_REGULAREXPRESSION
593 [[nodiscard]]
595 Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const;
596#endif
597
598 template <typename Needle, typename...Flags>
599 [[nodiscard]] inline auto tokenize(Needle &&needle, Flags...flags) const &
600 noexcept(noexcept(qTokenize(std::declval<const QString &>(), std::forward<Needle>(needle), flags...)))
601 -> decltype(qTokenize(*this, std::forward<Needle>(needle), flags...))
602 { return qTokenize(qToStringViewIgnoringNull(*this), std::forward<Needle>(needle), flags...); }
603
604 template <typename Needle, typename...Flags>
605 [[nodiscard]] inline auto tokenize(Needle &&needle, Flags...flags) const &&
606 noexcept(noexcept(qTokenize(std::declval<const QString>(), std::forward<Needle>(needle), flags...)))
607 -> decltype(qTokenize(std::move(*this), std::forward<Needle>(needle), flags...))
608 { return qTokenize(std::move(*this), std::forward<Needle>(needle), flags...); }
609
610 template <typename Needle, typename...Flags>
611 [[nodiscard]] inline auto tokenize(Needle &&needle, Flags...flags) &&
612 noexcept(noexcept(qTokenize(std::declval<QString>(), std::forward<Needle>(needle), flags...)))
613 -> decltype(qTokenize(std::move(*this), std::forward<Needle>(needle), flags...))
614 { return qTokenize(std::move(*this), std::forward<Needle>(needle), flags...); }
615
616
623 [[nodiscard]] QString normalized(NormalizationForm mode, QChar::UnicodeVersion version = QChar::Unicode_Unassigned) const;
624
625 [[nodiscard]] QString repeated(qsizetype times) const;
626
627 const ushort *utf16() const; // ### Qt 7 char16_t
628
629#if !defined(Q_QDOC)
630 [[nodiscard]] QByteArray toLatin1() const &
631 { return toLatin1_helper(*this); }
632 [[nodiscard]] QByteArray toLatin1() &&
633 { return toLatin1_helper_inplace(*this); }
634 [[nodiscard]] QByteArray toUtf8() const &
635 { return toUtf8_helper(*this); }
636 [[nodiscard]] QByteArray toUtf8() &&
637 { return toUtf8_helper(*this); }
638 [[nodiscard]] QByteArray toLocal8Bit() const &
639 { return toLocal8Bit_helper(isNull() ? nullptr : constData(), size()); }
640 [[nodiscard]] QByteArray toLocal8Bit() &&
641 { return toLocal8Bit_helper(isNull() ? nullptr : constData(), size()); }
642#else
643 [[nodiscard]] QByteArray toLatin1() const;
644 [[nodiscard]] QByteArray toUtf8() const;
645 [[nodiscard]] QByteArray toLocal8Bit() const;
646#endif
647 [[nodiscard]] QList<uint> toUcs4() const; // ### Qt 7 char32_t
648
649 // note - this are all inline so we can benefit from strlen() compile time optimizations
650 static QString fromLatin1(QByteArrayView ba);
652 static inline QString fromLatin1(const QByteArray &ba) { return fromLatin1(QByteArrayView(ba)); }
653 static inline QString fromLatin1(const char *str, qsizetype size)
654 {
655 return fromLatin1(QByteArrayView(str, !str || size < 0 ? qstrlen(str) : size));
656 }
657 static QString fromUtf8(QByteArrayView utf8);
659 static inline QString fromUtf8(const QByteArray &ba) { return fromUtf8(QByteArrayView(ba)); }
660 static inline QString fromUtf8(const char *utf8, qsizetype size)
661 {
662 return fromUtf8(QByteArrayView(utf8, !utf8 || size < 0 ? qstrlen(utf8) : size));
663 }
664#if defined(__cpp_char8_t) || defined(Q_QDOC)
666 static inline QString fromUtf8(const char8_t *str)
667 { return fromUtf8(reinterpret_cast<const char *>(str)); }
669 static inline QString fromUtf8(const char8_t *str, qsizetype size)
670 { return fromUtf8(reinterpret_cast<const char *>(str), size); }
671#endif
675 static inline QString fromLocal8Bit(const char *str, qsizetype size)
676 {
677 return fromLocal8Bit(QByteArrayView(str, !str || size < 0 ? qstrlen(str) : size));
678 }
679 static QString fromUtf16(const char16_t *, qsizetype size = -1);
680 static QString fromUcs4(const char32_t *, qsizetype size = -1);
681 static QString fromRawData(const QChar *, qsizetype size);
682
683#if QT_DEPRECATED_SINCE(6, 0)
684 QT_DEPRECATED_VERSION_X_6_0("Use char16_t* overload.")
685 static QString fromUtf16(const ushort *str, qsizetype size = -1)
686 { return fromUtf16(reinterpret_cast<const char16_t *>(str), size); }
687 QT_DEPRECATED_VERSION_X_6_0("Use char32_t* overload.")
688 static QString fromUcs4(const uint *str, qsizetype size = -1)
689 { return fromUcs4(reinterpret_cast<const char32_t *>(str), size); }
690#endif
691
692 inline qsizetype toWCharArray(wchar_t *array) const;
693 [[nodiscard]] static inline QString fromWCharArray(const wchar_t *string, qsizetype size = -1);
694
695 QString &setRawData(const QChar *unicode, qsizetype size);
696 QString &setUnicode(const QChar *unicode, qsizetype size);
697 inline QString &setUtf16(const ushort *utf16, qsizetype size); // ### Qt 7 char16_t
698
699 int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
701 inline int compare(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
703 { return compare(QStringView{&ch, 1}, cs); }
704
705 static inline int compare(const QString &s1, const QString &s2,
707 { return s1.compare(s2, cs); }
708
709 static inline int compare(const QString &s1, QLatin1StringView s2,
711 { return s1.compare(s2, cs); }
712 static inline int compare(QLatin1StringView s1, const QString &s2,
714 { return -s2.compare(s1, cs); }
716 { return s1.compare(s2, cs); }
718 { return -s2.compare(s1, cs); }
719
720 int localeAwareCompare(const QString& s) const;
721 inline int localeAwareCompare(QStringView s) const;
722 static int localeAwareCompare(const QString& s1, const QString& s2)
723 { return s1.localeAwareCompare(s2); }
724
725 static inline int localeAwareCompare(QStringView s1, QStringView s2);
726
727 short toShort(bool *ok=nullptr, int base=10) const
728 { return toIntegral_helper<short>(*this, ok, base); }
729 ushort toUShort(bool *ok=nullptr, int base=10) const
730 { return toIntegral_helper<ushort>(*this, ok, base); }
731 int toInt(bool *ok=nullptr, int base=10) const
732 { return toIntegral_helper<int>(*this, ok, base); }
733 uint toUInt(bool *ok=nullptr, int base=10) const
734 { return toIntegral_helper<uint>(*this, ok, base); }
735 long toLong(bool *ok=nullptr, int base=10) const
736 { return toIntegral_helper<long>(*this, ok, base); }
737 ulong toULong(bool *ok=nullptr, int base=10) const
738 { return toIntegral_helper<ulong>(*this, ok, base); }
739 QT_CORE_INLINE_SINCE(6, 5)
740 qlonglong toLongLong(bool *ok=nullptr, int base=10) const;
741 QT_CORE_INLINE_SINCE(6, 5)
742 qulonglong toULongLong(bool *ok=nullptr, int base=10) const;
743 float toFloat(bool *ok=nullptr) const;
744 double toDouble(bool *ok=nullptr) const;
745
746 inline QString &setNum(short, int base=10);
747 inline QString &setNum(ushort, int base=10);
748 inline QString &setNum(int, int base=10);
749 inline QString &setNum(uint, int base=10);
750 inline QString &setNum(long, int base=10);
751 inline QString &setNum(ulong, int base=10);
752 QString &setNum(qlonglong, int base=10);
753 QString &setNum(qulonglong, int base=10);
754 inline QString &setNum(float, char format='g', int precision=6);
755 QString &setNum(double, char format='g', int precision=6);
756
757 static QString number(int, int base=10);
758 static QString number(uint, int base=10);
759 static QString number(long, int base=10);
760 static QString number(ulong, int base=10);
761 static QString number(qlonglong, int base=10);
762 static QString number(qulonglong, int base=10);
763 static QString number(double, char format='g', int precision=6);
764
765 friend bool comparesEqual(const QString &s1, const QString &s2) noexcept
770
772 friend bool comparesEqual(const QString &s1, QUtf8StringView s2) noexcept
773 { return QtPrivate::equalStrings(s1, s2); }
781
782#ifdef __cpp_char8_t
783 friend bool comparesEqual(const QString &s1, const char8_t *s2) noexcept
784 { return comparesEqual(s1, QUtf8StringView(s2)); }
785 friend Qt::strong_ordering compareThreeWay(const QString &s1, const char8_t *s2) noexcept
786 { return compareThreeWay(s1, QUtf8StringView(s2)); }
787 Q_DECLARE_STRONGLY_ORDERED(QString, const char8_t *)
788#endif // __cpp_char8_t
789
790 friend bool comparesEqual(const QString &s1, QLatin1StringView s2) noexcept
791 { return (s1.size() == s2.size()) && QtPrivate::equalStrings(s1, s2); }
794 {
796 return Qt::compareThreeWay(res, 0);
797 }
799
800 // Check isEmpty() instead of isNull() for backwards compatibility.
801 friend bool comparesEqual(const QString &s1, std::nullptr_t) noexcept
802 { return s1.isEmpty(); }
803 friend Qt::strong_ordering compareThreeWay(const QString &s1, std::nullptr_t) noexcept
805 Q_DECLARE_STRONGLY_ORDERED(QString, std::nullptr_t)
806
807 friend bool comparesEqual(const QString &s1, const char16_t *s2) noexcept
808 { return comparesEqual(s1, QStringView(s2)); }
809 friend Qt::strong_ordering compareThreeWay(const QString &s1, const char16_t *s2) noexcept
810 { return compareThreeWay(s1, QStringView(s2)); }
811 Q_DECLARE_STRONGLY_ORDERED(QString, const char16_t *)
812
813 // QChar <> QString
814 friend bool comparesEqual(const QString &lhs, QChar rhs) noexcept
815 { return lhs.size() == 1 && rhs == lhs.front(); }
816 friend Qt::strong_ordering compareThreeWay(const QString &lhs, QChar rhs) noexcept
817 {
818 const int res = compare_helper(lhs.data(), lhs.size(), &rhs, 1);
819 return Qt::compareThreeWay(res, 0);
820 }
822
823 // ASCII compatibility
824#if defined(QT_RESTRICTED_CAST_FROM_ASCII)
825 template <qsizetype N>
826 inline QString(const char (&ch)[N])
827 : QString(fromUtf8(ch))
828 {}
829 template <qsizetype N>
830 QString(char (&)[N]) = delete;
831 template <qsizetype N>
832 inline QString &operator=(const char (&ch)[N])
833 { return (*this = fromUtf8(ch, N - 1)); }
834 template <qsizetype N>
835 QString &operator=(char (&)[N]) = delete;
836#endif
837#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
838 QT_ASCII_CAST_WARN inline QString(const char *ch)
839 : QString(fromUtf8(ch))
840 {}
842 : QString(fromUtf8(a))
843 {}
845 {
846 if (!ch) {
847 clear();
848 return *this;
849 }
850 return assign(ch);
851 }
853 {
854 if (a.isNull()) {
855 clear();
856 return *this;
857 }
858 return assign(a);
859 }
860 // these are needed, so it compiles with STL support enabled
861 QT_ASCII_CAST_WARN inline QString &prepend(const char *s)
862 { return prepend(QUtf8StringView(s)); }
865 QT_ASCII_CAST_WARN inline QString &append(const char *s)
866 { return append(QUtf8StringView(s)); }
870 { return insert(i, QUtf8StringView(s)); }
874 { return append(QUtf8StringView(s)); }
877
878#if QT_CORE_REMOVED_SINCE(6, 8)
879 QT_ASCII_CAST_WARN inline bool operator==(const char *s) const;
880 QT_ASCII_CAST_WARN inline bool operator!=(const char *s) const;
881 QT_ASCII_CAST_WARN inline bool operator<(const char *s) const;
882 QT_ASCII_CAST_WARN inline bool operator<=(const char *s) const;
883 QT_ASCII_CAST_WARN inline bool operator>(const char *s) const;
884 QT_ASCII_CAST_WARN inline bool operator>=(const char *s) const;
885
886 QT_ASCII_CAST_WARN inline bool operator==(const QByteArray &s) const;
887 QT_ASCII_CAST_WARN inline bool operator!=(const QByteArray &s) const;
888 QT_ASCII_CAST_WARN inline bool operator<(const QByteArray &s) const;
889 QT_ASCII_CAST_WARN inline bool operator>(const QByteArray &s) const;
890 QT_ASCII_CAST_WARN inline bool operator<=(const QByteArray &s) const;
891 QT_ASCII_CAST_WARN inline bool operator>=(const QByteArray &s) const;
892#else
893 friend bool comparesEqual(const QString &lhs, QByteArrayView rhs) noexcept
894 {
895 return QString::compare_helper(lhs.constData(), lhs.size(),
896 rhs.constData(), rhs.size()) == 0;
897 }
899 compareThreeWay(const QString &lhs, QByteArrayView rhs) noexcept
900 {
901 const int res = QString::compare_helper(lhs.constData(), lhs.size(),
902 rhs.constData(), rhs.size());
903 return Qt::compareThreeWay(res, 0);
904 }
906
907 friend bool comparesEqual(const QString &lhs, const QByteArray &rhs) noexcept
908 { return comparesEqual(lhs, QByteArrayView(rhs)); }
910 compareThreeWay(const QString &lhs, const QByteArray &rhs) noexcept
911 {
912 return compareThreeWay(lhs, QByteArrayView(rhs));
913 }
915
916 friend bool comparesEqual(const QString &lhs, const char *rhs) noexcept
917 { return comparesEqual(lhs, QByteArrayView(rhs)); }
919 compareThreeWay(const QString &lhs, const char *rhs) noexcept
920 {
921 return compareThreeWay(lhs, QByteArrayView(rhs));
922 }
924#endif // QT_CORE_REMOVED_SINCE(6, 8)
925
926#endif // !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
927
928 typedef QChar *iterator;
929 typedef const QChar *const_iterator;
932 typedef std::reverse_iterator<iterator> reverse_iterator;
933 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
934 inline iterator begin();
935 inline const_iterator begin() const;
936 inline const_iterator cbegin() const;
937 inline const_iterator constBegin() const;
938 inline iterator end();
939 inline const_iterator end() const;
940 inline const_iterator cend() const;
941 inline const_iterator constEnd() const;
948
949 // STL compatibility
952 typedef const QChar & const_reference;
953 typedef QChar & reference;
954 typedef QChar *pointer;
955 typedef const QChar *const_pointer;
957 inline void push_back(QChar c) { append(c); }
958 inline void push_back(const QString &s) { append(s); }
959 inline void push_front(QChar c) { prepend(c); }
960 inline void push_front(const QString &s) { prepend(s); }
961 void shrink_to_fit() { squeeze(); }
962 iterator erase(const_iterator first, const_iterator last);
963 inline iterator erase(const_iterator it) { return erase(it, it + 1); }
964 static constexpr qsizetype max_size() noexcept
965 {
966 // -1 to deal with the NUL terminator
967 return Data::max_size() - 1;
968 }
969
970 static inline QString fromStdString(const std::string &s);
971 inline std::string toStdString() const;
972 static inline QString fromStdWString(const std::wstring &s);
973 inline std::wstring toStdWString() const;
974
975 static inline QString fromStdU16String(const std::u16string &s);
976 inline std::u16string toStdU16String() const;
977 static inline QString fromStdU32String(const std::u32string &s);
978 inline std::u32string toStdU32String() const;
979
980 Q_IMPLICIT inline operator std::u16string_view() const noexcept;
981
982#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
983 static QString fromCFString(CFStringRef string);
984 CFStringRef toCFString() const Q_DECL_CF_RETURNS_RETAINED;
985 static QString fromNSString(const NSString *string);
986 NSString *toNSString() const Q_DECL_NS_RETURNS_AUTORELEASED;
987#endif
988
989#if defined(Q_OS_WASM) || defined(Q_QDOC)
990 static QString fromEcmaString(emscripten::val jsString);
991 emscripten::val toEcmaString() const;
992#endif
993
994 inline bool isNull() const { return d->isNull(); }
995
996 bool isRightToLeft() const;
997 [[nodiscard]] bool isValidUtf16() const noexcept
998 { return QStringView(*this).isValidUtf16(); }
999
1001 explicit QString(DataPointer &&dd) : d(std::move(dd)) {}
1002
1003private:
1004#if defined(QT_NO_CAST_FROM_ASCII)
1005 QString &operator+=(const char *s);
1006 QString &operator+=(const QByteArray &s);
1007 QString(const char *ch);
1008 QString(const QByteArray &a);
1009 QString &operator=(const char *ch);
1010 QString &operator=(const QByteArray &a);
1011#endif
1012
1013 DataPointer d;
1014 static const char16_t _empty;
1015
1016 void reallocData(qsizetype alloc, QArrayData::AllocationOption option);
1017 void reallocGrowData(qsizetype n);
1018 // ### remove once QAnyStringView supports UTF-32:
1019 QString &assign_helper(const char32_t *data, qsizetype len);
1020 // Defined in qstringconverter.h
1021 template <typename InputIterator>
1022 void assign_helper_char8(InputIterator first, InputIterator last);
1023 static int compare_helper(const QChar *data1, qsizetype length1,
1024 const QChar *data2, qsizetype length2,
1026 static int compare_helper(const QChar *data1, qsizetype length1,
1027 const char *data2, qsizetype length2,
1029 static int localeAwareCompare_helper(const QChar *data1, qsizetype length1,
1030 const QChar *data2, qsizetype length2);
1031 static QString sliced_helper(QString &str, qsizetype pos, qsizetype n);
1032 static QString toLower_helper(const QString &str);
1033 static QString toLower_helper(QString &str);
1034 static QString toUpper_helper(const QString &str);
1035 static QString toUpper_helper(QString &str);
1036 static QString toCaseFolded_helper(const QString &str);
1037 static QString toCaseFolded_helper(QString &str);
1038 static QString trimmed_helper(const QString &str);
1039 static QString trimmed_helper(QString &str);
1040 static QString simplified_helper(const QString &str);
1041 static QString simplified_helper(QString &str);
1042 static QByteArray toLatin1_helper(const QString &);
1043 static QByteArray toLatin1_helper_inplace(QString &);
1044 static QByteArray toUtf8_helper(const QString &);
1045 static QByteArray toLocal8Bit_helper(const QChar *data, qsizetype size);
1046#if QT_CORE_REMOVED_SINCE(6, 6)
1047 static qsizetype toUcs4_helper(const ushort *uc, qsizetype length, uint *out);
1048#endif
1049 static qsizetype toUcs4_helper(const char16_t *uc, qsizetype length, char32_t *out);
1050 static qlonglong toIntegral_helper(QStringView string, bool *ok, int base);
1051 static qulonglong toIntegral_helper(QStringView string, bool *ok, uint base);
1052 template <typename Predicate>
1053 qsizetype removeIf_helper(Predicate pred)
1054 {
1055 const qsizetype result = d->eraseIf(pred);
1056 if (result > 0)
1057 d.data()[d.size] = u'\0';
1058 return result;
1059 }
1060
1061 friend class QStringView;
1062 friend class QByteArray;
1064 template <typename T> friend qsizetype erase(QString &s, const T &t);
1065 template <typename Predicate> friend qsizetype erase_if(QString &s, Predicate pred);
1066
1067 template <typename T> static
1068 T toIntegral_helper(QStringView string, bool *ok, int base)
1069 {
1070 using Int64 = typename std::conditional<std::is_unsigned<T>::value, qulonglong, qlonglong>::type;
1071 using Int32 = typename std::conditional<std::is_unsigned<T>::value, uint, int>::type;
1072
1073 // we select the right overload by casting base to int or uint
1074 Int64 val = toIntegral_helper(string, ok, Int32(base));
1075 if (T(val) != val) {
1076 if (ok)
1077 *ok = false;
1078 val = 0;
1079 }
1080 return T(val);
1081 }
1082
1083 Q_ALWAYS_INLINE constexpr void verify([[maybe_unused]] qsizetype pos = 0,
1084 [[maybe_unused]] qsizetype n = 1) const
1085 {
1086 Q_ASSERT(pos >= 0);
1087 Q_ASSERT(pos <= d.size);
1088 Q_ASSERT(n >= 0);
1089 Q_ASSERT(n <= d.size - pos);
1090 }
1091
1092public:
1093 inline DataPointer &data_ptr() { return d; }
1094 inline const DataPointer &data_ptr() const { return d; }
1095};
1096
1097//
1098// QLatin1StringView inline members that require QUtf8StringView:
1099//
1100
1103
1104//
1105// QLatin1StringView inline members that require QString:
1106//
1107
1108QString QLatin1StringView::toString() const { return *this; }
1109
1110//
1111// QStringView inline members that require QUtf8StringView:
1112//
1113
1116
1117//
1118// QStringView inline members that require QString:
1119//
1120
1122{ return QString(*this); }
1123
1125{ return QString::toIntegral_helper<qint64>(*this, ok, base); }
1127{ return QString::toIntegral_helper<quint64>(*this, ok, base); }
1128long QStringView::toLong(bool *ok, int base) const
1129{ return QString::toIntegral_helper<long>(*this, ok, base); }
1131{ return QString::toIntegral_helper<ulong>(*this, ok, base); }
1132int QStringView::toInt(bool *ok, int base) const
1133{ return QString::toIntegral_helper<int>(*this, ok, base); }
1135{ return QString::toIntegral_helper<uint>(*this, ok, base); }
1136short QStringView::toShort(bool *ok, int base) const
1137{ return QString::toIntegral_helper<short>(*this, ok, base); }
1139{ return QString::toIntegral_helper<ushort>(*this, ok, base); }
1140
1141//
1142// QUtf8StringView inline members that require QStringView:
1143//
1144
1145template <bool UseChar8T>
1150
1151template <bool UseChar8T>
1156
1157template <bool UseChar8T>
1158[[nodiscard]] bool QBasicUtf8StringView<UseChar8T>::equal(QChar other) const noexcept
1159{
1160 return QtPrivate::equalStrings(*this, QStringView(&other, 1));
1161}
1162
1163template <bool UseChar8T>
1165{
1166 return QtPrivate::equalStrings(*this, other);
1167}
1168
1169//
1170// QUtf8StringView inline members that require QString, QL1SV or QBA:
1171//
1172
1173template <bool UseChar8T>
1178
1179template<bool UseChar8T>
1181 Qt::CaseSensitivity cs) const noexcept
1182{
1183 return QtPrivate::compareStrings(*this, other, cs);
1184}
1185
1186template<bool UseChar8T>
1188 Qt::CaseSensitivity cs) const noexcept
1189{
1190 return QtPrivate::compareStrings(*this,
1191 QBasicUtf8StringView<UseChar8T>(other.data(), other.size()),
1192 cs);
1193}
1194
1195template <bool UseChar8T>
1197{
1198 return QtPrivate::equalStrings(*this, other);
1199}
1200
1201template <bool UseChar8T>
1202[[nodiscard]] bool QBasicUtf8StringView<UseChar8T>::equal(const QByteArray &other) const noexcept
1203{
1204 return size() == other.size()
1205 && QtPrivate::equalStrings(*this, QBasicUtf8StringView<UseChar8T>(other.data(),
1206 other.size()));
1207}
1208
1209//
1210// QAnyStringView inline members that require QString:
1211//
1212
1217
1220
1221//
1222// QString inline members
1223//
1225{ *this = QString::fromLatin1(latin1.data(), latin1.size()); }
1227{ verify(i, 1); return QChar(d.data()[i]); }
1229{ verify(i, 1); return QChar(d.data()[i]); }
1231{ return data(); }
1232const QChar *QString::data() const
1233{
1234#if QT5_NULL_STRINGS == 1
1235 return reinterpret_cast<const QChar *>(d.data() ? d.data() : &_empty);
1236#else
1237 return reinterpret_cast<const QChar *>(d.data());
1238#endif
1239}
1241{
1242 detach();
1243 Q_ASSERT(d.data());
1244 return reinterpret_cast<QChar *>(d.data());
1245}
1247{ return data(); }
1249{ if (d->needsDetach()) reallocData(d.size, QArrayData::KeepSize); }
1251{ return !d->isShared(); }
1253{ if (!isNull()) *this = QString(); }
1254QString::QString(const QString &other) noexcept : d(other.d)
1255{ }
1256qsizetype QString::capacity() const { return qsizetype(d->constAllocatedCapacity()); }
1258{ return setNum(qlonglong(n), base); }
1260{ return setNum(qulonglong(n), base); }
1262{ return setNum(qlonglong(n), base); }
1264{ return setNum(qulonglong(n), base); }
1266{ return setNum(qlonglong(n), base); }
1268{ return setNum(qulonglong(n), base); }
1269QString &QString::setNum(float n, char f, int prec)
1270{ return setNum(double(n),f,prec); }
1271QString QString::arg(int a, int fieldWidth, int base, QChar fillChar) const
1272{ return arg(qlonglong(a), fieldWidth, base, fillChar); }
1273QString QString::arg(uint a, int fieldWidth, int base, QChar fillChar) const
1274{ return arg(qulonglong(a), fieldWidth, base, fillChar); }
1275QString QString::arg(long a, int fieldWidth, int base, QChar fillChar) const
1276{ return arg(qlonglong(a), fieldWidth, base, fillChar); }
1277QString QString::arg(ulong a, int fieldWidth, int base, QChar fillChar) const
1278{ return arg(qulonglong(a), fieldWidth, base, fillChar); }
1279QString QString::arg(short a, int fieldWidth, int base, QChar fillChar) const
1280{ return arg(qlonglong(a), fieldWidth, base, fillChar); }
1281QString QString::arg(ushort a, int fieldWidth, int base, QChar fillChar) const
1282{ return arg(qulonglong(a), fieldWidth, base, fillChar); }
1283
1284QString QString::section(QChar asep, qsizetype astart, qsizetype aend, SectionFlags aflags) const
1285{ return section(QString(asep), astart, aend, aflags); }
1286
1288QT_WARNING_DISABLE_MSVC(4127) // "conditional expression is constant"
1289QT_WARNING_DISABLE_INTEL(111) // "statement is unreachable"
1290
1291qsizetype QString::toWCharArray(wchar_t *array) const
1292{
1294}
1295
1297{
1298 if (sizeof(wchar_t) == sizeof(QChar)) {
1299 if (auto src = data())
1300 memcpy(array, src, sizeof(QChar) * size());
1301 return size();
1302 } else {
1303 return QString::toUcs4_helper(utf16(), size(), reinterpret_cast<char32_t *>(array));
1304 }
1305}
1306
1308
1310{
1311 if constexpr (sizeof(wchar_t) == sizeof(QChar)) {
1312 return QString(reinterpret_cast<const QChar *>(string), size);
1313 } else {
1314#ifdef QT_BOOTSTRAPPED
1315 Q_UNREACHABLE_RETURN(QString());
1316#else
1317 return fromUcs4(reinterpret_cast<const char32_t *>(string), size);
1318#endif
1319 }
1320}
1321
1322constexpr QString::QString() noexcept {}
1324
1326{
1327 if (d->needsDetach() || asize >= capacity() - d.freeSpaceAtBegin())
1328 reallocData(qMax(asize, size()), QArrayData::KeepSize);
1329 if (d->constAllocatedCapacity())
1330 d->setFlag(Data::CapacityReserved);
1331}
1332
1334{
1335 if (!d.isMutable())
1336 return;
1337 if (d->needsDetach() || size() < capacity())
1338 reallocData(d.size, QArrayData::KeepSize);
1339 if (d->constAllocatedCapacity())
1340 d->clearFlag(Data::CapacityReserved);
1341}
1342
1344{ return setUnicode(reinterpret_cast<const QChar *>(autf16), asize); }
1346{ verify(i, 1); return data()[i]; }
1347QChar &QString::front() { return operator[](0); }
1348QChar &QString::back() { return operator[](size() - 1); }
1350{ detach(); return reinterpret_cast<QChar*>(d.data()); }
1352{ return reinterpret_cast<const QChar*>(d.data()); }
1354{ return reinterpret_cast<const QChar*>(d.data()); }
1356{ return reinterpret_cast<const QChar*>(d.data()); }
1358{ detach(); return reinterpret_cast<QChar*>(d.data() + d.size); }
1360{ return reinterpret_cast<const QChar*>(d.data() + d.size); }
1362{ return reinterpret_cast<const QChar*>(d.data() + d.size); }
1364{ return reinterpret_cast<const QChar*>(d.data() + d.size); }
1366{ return indexOf(s, 0, cs) != -1; }
1368{ return indexOf(s, 0, cs) != -1; }
1370{ return indexOf(c, 0, cs) != -1; }
1372{ return indexOf(s, 0, cs) != -1; }
1373
1374#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
1375#if QT_CORE_REMOVED_SINCE(6, 8)
1376bool QString::operator==(const char *s) const
1377{ return QString::compare_helper(constData(), size(), s, -1) == 0; }
1378bool QString::operator!=(const char *s) const
1379{ return QString::compare_helper(constData(), size(), s, -1) != 0; }
1380bool QString::operator<(const char *s) const
1381{ return QString::compare_helper(constData(), size(), s, -1) < 0; }
1382bool QString::operator>(const char *s) const
1383{ return QString::compare_helper(constData(), size(), s, -1) > 0; }
1384bool QString::operator<=(const char *s) const
1385{ return QString::compare_helper(constData(), size(), s, -1) <= 0; }
1386bool QString::operator>=(const char *s) const
1387{ return QString::compare_helper(constData(), size(), s, -1) >= 0; }
1388
1389QT_ASCII_CAST_WARN bool QString::operator==(const QByteArray &s) const
1390{ return QString::compare_helper(constData(), size(), s.constData(), s.size()) == 0; }
1391QT_ASCII_CAST_WARN bool QString::operator!=(const QByteArray &s) const
1392{ return QString::compare_helper(constData(), size(), s.constData(), s.size()) != 0; }
1393QT_ASCII_CAST_WARN bool QString::operator<(const QByteArray &s) const
1394{ return QString::compare_helper(constData(), size(), s.constData(), s.size()) < 0; }
1395QT_ASCII_CAST_WARN bool QString::operator>(const QByteArray &s) const
1396{ return QString::compare_helper(constData(), size(), s.constData(), s.size()) > 0; }
1397QT_ASCII_CAST_WARN bool QString::operator<=(const QByteArray &s) const
1398{ return QString::compare_helper(constData(), size(), s.constData(), s.size()) <= 0; }
1399QT_ASCII_CAST_WARN bool QString::operator>=(const QByteArray &s) const
1400{ return QString::compare_helper(constData(), size(), s.constData(), s.size()) >= 0; }
1401
1402bool QByteArray::operator==(const QString &s) const
1403{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) == 0; }
1404bool QByteArray::operator!=(const QString &s) const
1405{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) != 0; }
1406bool QByteArray::operator<(const QString &s) const
1407{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) > 0; }
1408bool QByteArray::operator>(const QString &s) const
1409{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) < 0; }
1410bool QByteArray::operator<=(const QString &s) const
1411{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) >= 0; }
1412bool QByteArray::operator>=(const QString &s) const
1413{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) <= 0; }
1414#endif // QT_CORE_REMOVED_SINCE(6, 8)
1415#endif // !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
1416
1417#if !defined(QT_USE_FAST_OPERATOR_PLUS) && !defined(QT_USE_QSTRINGBUILDER)
1418inline QString operator+(const QString &s1, const QString &s2)
1419{ QString t(s1); t += s2; return t; }
1420inline QString operator+(QString &&lhs, const QString &rhs)
1421{ return std::move(lhs += rhs); }
1423{ QString t(s1); t += s2; return t; }
1424inline QString operator+(QString &&lhs, QChar rhs)
1425{ return std::move(lhs += rhs); }
1427{ QString t(s1); t += s2; return t; }
1428# if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
1430{ QString t(s1); t += QUtf8StringView(s2); return t; }
1431QT_ASCII_CAST_WARN inline QString operator+(QString &&lhs, const char *rhs)
1432{ QT_IGNORE_DEPRECATIONS(return std::move(lhs += rhs);) }
1434{ QString t = QString::fromUtf8(s1); t += s2; return t; }
1436{ QString t = QString::fromUtf8(ba); t += s; return t; }
1438{ QString t(s); t += QUtf8StringView(ba); return t; }
1440{ QT_IGNORE_DEPRECATIONS(return std::move(lhs += rhs);) }
1441# endif // QT_NO_CAST_FROM_ASCII
1442#endif // QT_USE_QSTRINGBUILDER
1443
1444std::string QString::toStdString() const
1445{ return toUtf8().toStdString(); }
1446
1448{ return fromUtf8(s.data(), qsizetype(s.size())); }
1449
1450std::wstring QString::toStdWString() const
1451{
1452 std::wstring str;
1453 str.resize(size());
1454 str.resize(toWCharArray(str.data()));
1455 return str;
1456}
1457
1459{ return fromWCharArray(s.data(), qsizetype(s.size())); }
1460
1462{ return fromUtf16(s.data(), qsizetype(s.size())); }
1463
1464std::u16string QString::toStdU16String() const
1465{ return std::u16string(reinterpret_cast<const char16_t*>(data()), size()); }
1466
1468{ return fromUcs4(s.data(), qsizetype(s.size())); }
1469
1470std::u32string QString::toStdU32String() const
1471{
1472 std::u32string u32str(size(), char32_t(0));
1473 const qsizetype len = toUcs4_helper(reinterpret_cast<const char16_t *>(data()),
1474 size(), u32str.data());
1475 u32str.resize(len);
1476 return u32str;
1477}
1478
1479QString::operator std::u16string_view() const noexcept
1480{
1481 return std::u16string_view(d.data(), size_t(d.size));
1482}
1483
1484#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED)
1485Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QString &);
1486Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QString &);
1487#endif
1488
1489Q_DECLARE_SHARED(QString)
1490Q_DECLARE_OPERATORS_FOR_FLAGS(QString::SectionFlags)
1491
1492int QString::compare(QStringView s, Qt::CaseSensitivity cs) const noexcept
1493{ return -s.compare(*this, cs); }
1494
1496{ return localeAwareCompare_helper(constData(), size(), s.constData(), s.size()); }
1498{ return localeAwareCompare_helper(s1.constData(), s1.size(), s2.constData(), s2.size()); }
1501
1502#if QT_CORE_INLINE_IMPL_SINCE(6, 5)
1503qint64 QString::toLongLong(bool *ok, int base) const
1504{
1505 return toIntegral_helper<qlonglong>(*this, ok, base);
1506}
1507
1508quint64 QString::toULongLong(bool *ok, int base) const
1509{
1510 return toIntegral_helper<qulonglong>(*this, ok, base);
1511}
1512#endif
1513#if QT_CORE_INLINE_IMPL_SINCE(6, 7)
1515{
1516 return qToStringViewIgnoringNull(*this).indexOf(ch, from, cs);
1517}
1519{
1520 return qToStringViewIgnoringNull(*this).lastIndexOf(ch, from, cs);
1521}
1522#endif
1523
1524namespace QtPrivate {
1525// used by qPrintable() and qUtf8Printable() macros
1526inline const QString &asString(const QString &s) { return s; }
1527inline QString &&asString(QString &&s) { return std::move(s); }
1528}
1529
1530#ifndef qPrintable
1531# define qPrintable(string) QtPrivate::asString(string).toLocal8Bit().constData()
1532#endif
1533
1534#ifndef qUtf8Printable
1535# define qUtf8Printable(string) QtPrivate::asString(string).toUtf8().constData()
1536#endif
1537
1538/*
1539 Wrap QString::utf16() with enough casts to allow passing it
1540 to QString::asprintf("%ls") without warnings.
1541*/
1542#ifndef qUtf16Printable
1543# define qUtf16Printable(string) \
1544 static_cast<const wchar_t*>(static_cast<const void*>(QtPrivate::asString(string).utf16()))
1545#endif
1546
1547//
1548// QStringView::arg() implementation
1549//
1550
1551namespace QtPrivate {
1552
1553struct ArgBase {
1554 enum Tag : uchar { L1, U8, U16 } tag;
1555};
1556
1559 QStringViewArg() = default;
1560 constexpr explicit QStringViewArg(QStringView v) noexcept : ArgBase{U16}, string{v} {}
1561};
1562
1565 QLatin1StringArg() = default;
1566 constexpr explicit QLatin1StringArg(QLatin1StringView v) noexcept : ArgBase{L1}, string{v} {}
1567};
1568
1569[[nodiscard]] Q_CORE_EXPORT QString argToQString(QStringView pattern, size_t n, const ArgBase **args);
1570[[nodiscard]] Q_CORE_EXPORT QString argToQString(QLatin1StringView pattern, size_t n, const ArgBase **args);
1571
1572template <typename StringView, typename...Args>
1573[[nodiscard]] Q_ALWAYS_INLINE QString argToQStringDispatch(StringView pattern, const Args &...args)
1574{
1575 const ArgBase *argBases[] = {&args..., /* avoid zero-sized array */ nullptr};
1576 return QtPrivate::argToQString(pattern, sizeof...(Args), argBases);
1577}
1578
1580constexpr inline QStringViewArg qStringLikeToArg(QStringView s) noexcept { return QStringViewArg{s}; }
1581 inline QStringViewArg qStringLikeToArg(const QChar &c) noexcept { return QStringViewArg{QStringView{&c, 1}}; }
1583
1584} // namespace QtPrivate
1585
1586template <typename...Args>
1592
1593template <typename...Args>
1599
1600template <typename T>
1602{
1603 return s.removeIf_helper([&t](const auto &e) { return t == e; });
1604}
1605
1606template <typename Predicate>
1607qsizetype erase_if(QString &s, Predicate pred)
1608{
1609 return s.removeIf_helper(pred);
1610}
1611
1612namespace Qt {
1613inline namespace Literals {
1614inline namespace StringLiterals {
1615inline QString operator""_s(const char16_t *str, size_t size) noexcept
1616{
1617 return QString(QStringPrivate(nullptr, const_cast<char16_t *>(str), qsizetype(size)));
1618}
1619
1620} // StringLiterals
1621} // Literals
1622} // Qt
1623
1624inline namespace QtLiterals {
1625#if QT_DEPRECATED_SINCE(6, 8)
1626
1627QT_DEPRECATED_VERSION_X_6_8("Use _s from Qt::StringLiterals namespace instead.")
1628inline QString operator""_qs(const char16_t *str, size_t size) noexcept
1629{
1630 return Qt::StringLiterals::operator""_s(str, size);
1631}
1632
1633#endif // QT_DEPRECATED_SINCE(6, 8)
1634} // QtLiterals
1635
1637
1638#include <QtCore/qstringbuilder.h>
1639#include <QtCore/qstringconverter.h>
1640
1641#ifdef Q_L1S_VIEW_IS_PRIMARY
1642# undef Q_L1S_VIEW_IS_PRIMARY
1643#endif
1644
1645#endif // QSTRING_H
NSData * m_data
\inmodule QtCore
constexpr QAnyStringView() noexcept
Constructs a null string view.
constexpr QChar back() const
Returns the last character in the string view.
Definition qstring.h:122
const char * m_data_utf8
QString toString() const
Returns a deep copy of this string view's data as a QString.
Definition qstring.h:1218
constexpr QChar front() const
Returns the first character in the string view.
Definition qstring.h:118
constexpr decltype(auto) visit(Visitor &&v) const
Calls v with either a QUtf8StringView, QLatin1String, or QStringView, depending on the encoding of th...
int compare(QBasicUtf8StringView other, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QString toString() const
Definition qstring.h:1174
bool equal(QChar other) const noexcept
Definition qstring.h:1158
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
\inmodule QtCore\reentrant
Definition qdatastream.h:46
constexpr const char * data() const noexcept
QString toString() const
Definition qstring.h:1108
int compare(QStringView other, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QString arg(Args &&...args) const
constexpr qsizetype size() const noexcept
\inmodule QtCore \reentrant
\inmodule QtCore \reentrant
\inmodule QtCore
\inmodule QtCore
Definition qstringview.h:78
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
bool startsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
qsizetype count(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
int localeAwareCompare(QStringView other) const
Definition qstring.h:1499
ushort toUShort(bool *ok=nullptr, int base=10) const
Returns the string view converted to an {unsigned short} using base base, which is 10 by default and ...
Definition qstring.h:1138
QString arg(Args &&...args) const
bool endsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QString toString() const
Returns a deep copy of this string view's data as a QString.
Definition qstring.h:1121
int toInt(bool *ok=nullptr, int base=10) const
Returns the string view converted to an int using base base, which is 10 by default and must be betwe...
Definition qstring.h:1132
qlonglong toLongLong(bool *ok=nullptr, int base=10) const
Returns the string view converted to a {long long} using base base, which is 10 by default and must b...
Definition qstring.h:1124
ulong toULong(bool *ok=nullptr, int base=10) const
Returns the string view converted to an {unsigned long} using base base, which is 10 by default and m...
Definition qstring.h:1130
bool isValidUtf16() const noexcept
int compare(QStringView other, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
qulonglong toULongLong(bool *ok=nullptr, int base=10) const
Returns the string view converted to an {unsigned long long} using base base, which is 10 by default ...
Definition qstring.h:1126
short toShort(bool *ok=nullptr, int base=10) const
Returns the string view converted to a short using base base, which is 10 by default and must be betw...
Definition qstring.h:1136
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
uint toUInt(bool *ok=nullptr, int base=10) const
Returns the string view converted to an {unsigned int} using base base, which is 10 by default and mu...
Definition qstring.h:1134
qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
long toLong(bool *ok=nullptr, int base=10) const
Returns the string view converted to a long using base base, which is 10 by default and must be betwe...
Definition qstring.h:1128
qsizetype toWCharArray(wchar_t *array) const
Definition qstring.h:1296
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QString & removeFirst()
Definition qstring.h:557
QString left(qsizetype n) const &
Definition qstring.h:363
bool startsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
Definition qstring.h:417
QString & slice(qsizetype pos)
Definition qstring.h:201
iterator begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first character in the string.
Definition qstring.h:1349
QString & removeAt(qsizetype pos)
Definition qstring.h:555
std::u32string toStdU32String() const
Definition qstring.h:1470
QByteArray toLatin1() const &
Definition qstring.h:630
bool isDetached() const
Definition qstring.h:1250
QString left(qsizetype n) &&
Definition qstring.h:369
QString & operator+=(QStringView v)
Definition qstring.h:535
const QChar operator[](qsizetype i) const
Definition qstring.h:1228
QChar * iterator
Definition qstring.h:928
friend Qt::strong_ordering compareThreeWay(const QString &s1, const QString &s2) noexcept
Definition qstring.h:767
QT_ASCII_CAST_WARN QString & append(const QByteArray &s)
Definition qstring.h:867
QString & assign(qsizetype n, QChar c)
Definition qstring.h:486
void push_front(QChar c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.h:959
QChar & reference
Definition qstring.h:953
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition qstring.cpp:4517
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
Definition qstring.h:296
const_iterator constEnd() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing just after the last character in...
Definition qstring.h:1363
QString first(qsizetype n) &&
Definition qstring.h:401
static QString fromLatin1(const char *str, qsizetype size)
Returns a QString initialized with the first size characters of the Latin-1 string str.
Definition qstring.h:653
const_reverse_iterator rbegin() const
Definition qstring.h:944
std::wstring toStdWString() const
Returns a std::wstring object with the data contained in this QString.
Definition qstring.h:1450
int toInt(bool *ok=nullptr, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition qstring.h:731
static Q_WEAK_OVERLOAD QString fromLocal8Bit(const QByteArray &ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.h:674
QT_ASCII_CAST_WARN QString(const char *ch)
Constructs a string initialized with the 8-bit string str.
Definition qstring.h:838
void reserve(qsizetype size)
Ensures the string has space for at least size characters.
Definition qstring.h:1325
iterator erase(const_iterator it)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.h:963
QString sliced(qsizetype pos) const &
Definition qstring.h:394
QString chopped(qsizetype n) const &
Definition qstring.h:398
QString toLower() &&
Definition qstring.h:437
static QString fromStdU16String(const std::u16string &s)
Definition qstring.h:1461
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5871
QString & operator+=(QChar c)
Definition qstring.h:532
const QChar & const_reference
Definition qstring.h:952
QChar * pointer
The QString::pointer typedef provides an STL-style pointer to a QString element (QChar).
Definition qstring.h:954
QT_ASCII_CAST_WARN QString(const QByteArray &a)
Constructs a string initialized with the byte array ba.
Definition qstring.h:841
static QString fromStdString(const std::string &s)
Definition qstring.h:1447
QString trimmed() &&
Definition qstring.h:449
QT_ASCII_CAST_WARN QString & append(const char *s)
Definition qstring.h:865
QByteArray toUtf8() &&
Definition qstring.h:636
QString & operator+=(QUtf8StringView s)
Definition qstring.h:537
Q_WEAK_OVERLOAD friend Qt::strong_ordering compareThreeWay(const QString &s1, QUtf8StringView s2) noexcept
Definition qstring.h:775
QString & prepend(const QString &s)
Prepends the string str to the beginning of this string and returns a reference to this string.
Definition qstring.h:480
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
qsizetype lastIndexOf(QStringView s, qsizetype from, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
Definition qstring.h:309
iterator Iterator
Qt-style synonym for QString::iterator.
Definition qstring.h:930
QString(DataPointer &&dd)
Definition qstring.h:1001
static int compare(QStringView s1, const QString &s2, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Definition qstring.h:717
void push_front(const QString &s)
This function is provided for STL compatibility, prepending the given other string to the beginning o...
Definition qstring.h:960
QString & prepend(QStringView v)
Definition qstring.h:481
void clear()
Clears the contents of the string and makes it null.
Definition qstring.h:1252
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition qstring.h:1246
friend Qt::strong_ordering compareThreeWay(const QString &lhs, const QByteArray &rhs) noexcept
Definition qstring.h:910
Q_WEAK_OVERLOAD friend bool comparesEqual(const QString &s1, QUtf8StringView s2) noexcept
Definition qstring.h:772
ushort toUShort(bool *ok=nullptr, int base=10) const
Returns the string converted to an {unsigned short} using base base, which is 10 by default and must ...
Definition qstring.h:729
qsizetype size_type
Definition qstring.h:950
friend Qt::strong_ordering compareThreeWay(const QString &lhs, QChar rhs) noexcept
Definition qstring.h:816
QString(QString &&other) noexcept=default
Move-constructs a QString instance, making it point at the same object that other was pointing to.
bool isValidUtf16() const noexcept
Definition qstring.h:997
const_iterator cbegin() const
Definition qstring.h:1353
QString toCaseFolded() const &
Definition qstring.h:443
static constexpr qsizetype max_size() noexcept
Definition qstring.h:964
reverse_iterator rend()
Definition qstring.h:943
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition qstring.h:994
QString right(qsizetype n) &&
Definition qstring.h:381
qsizetype size() const noexcept
Returns the number of characters in this string.
Definition qstring.h:186
std::string toStdString() const
Returns a std::string object with the data contained in this QString.
Definition qstring.h:1444
const QChar * const_pointer
The QString::const_pointer typedef provides an STL-style const pointer to a QString element (QChar).
Definition qstring.h:955
uint toUInt(bool *ok=nullptr, int base=10) const
Returns the string converted to an {unsigned int} using base base, which is 10 by default and must be...
Definition qstring.h:733
const_iterator cend() const
Definition qstring.h:1361
void push_back(QChar c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.h:957
QT_ASCII_CAST_WARN QString & operator=(const char *ch)
Definition qstring.h:844
QString & removeIf(Predicate pred)
Definition qstring.h:561
QT_ASCII_CAST_WARN QString & operator+=(const char *s)
Definition qstring.h:873
QString simplified() &&
Definition qstring.h:453
QStringPrivate DataPointer
Definition qstring.h:163
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:6018
QString & prepend(QLatin1StringView s)
Definition qstring.h:482
QT_ASCII_CAST_WARN QString & operator+=(const QByteArray &s)
Definition qstring.h:875
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
Definition qstring.cpp:8870
QString & insert(qsizetype i, const QString &s)
Definition qstring.h:466
QByteArray toLatin1() &&
Definition qstring.h:632
QString & assign(InputIterator first, InputIterator last)
Definition qstring.h:492
SectionFlag
This enum specifies flags that can be used to affect various aspects of the section() function's beha...
Definition qstring.h:337
QString section(QChar sep, qsizetype start, qsizetype end=-1, SectionFlags flags=SectionDefault) const
This function returns a section of the string.
Definition qstring.h:1284
constexpr QString() noexcept
Constructs a null string.
Definition qstring.h:1322
bool isSharedWith(const QString &other) const
Definition qstring.h:223
QT_ASCII_CAST_WARN QString & operator=(const QByteArray &a)
Definition qstring.h:852
qsizetype capacity() const
Returns the maximum number of characters that can be stored in the string without forcing a reallocat...
Definition qstring.h:1256
qulonglong toULongLong(bool *ok=nullptr, int base=10) const
Returns the string converted to an {unsigned long long} using base base, which is 10 by default and m...
QString simplified() const &
Definition qstring.h:451
const_reverse_iterator crbegin() const
Definition qstring.h:946
QChar back() const
Definition qstring.h:232
QString & slice(qsizetype pos, qsizetype n)
Definition qstring.h:203
iterator end()
Returns an \l{STL-style iterators}{STL-style iterator} pointing just after the last character in the ...
Definition qstring.h:1357
friend Qt::strong_ordering compareThreeWay(const QString &s1, const char16_t *s2) noexcept
Definition qstring.h:809
QString sliced(qsizetype pos, qsizetype n) &&
Definition qstring.h:411
static QString fromLocal8Bit(const char *str, qsizetype size)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition qstring.h:675
static int compare(const QString &s1, QLatin1StringView s2, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Definition qstring.h:709
static int compare(const QString &s1, QStringView s2, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Definition qstring.h:715
void detach()
Definition qstring.h:1248
QString toUpper() &&
Definition qstring.h:441
QT_ASCII_CAST_WARN QString & insert(qsizetype i, const QByteArray &s)
Definition qstring.h:871
long toLong(bool *ok=nullptr, int base=10) const
Returns the string converted to a long using base base, which is 10 by default and must be between 2 ...
Definition qstring.h:735
QString right(qsizetype n) const &
Definition qstring.h:375
QT_ASCII_CAST_WARN QString & insert(qsizetype i, const char *s)
Definition qstring.h:869
qlonglong toLongLong(bool *ok=nullptr, int base=10) const
Returns the string converted to a {long long} using base base, which is 10 by default and must be bet...
friend Qt::strong_ordering compareThreeWay(const QString &s1, QLatin1StringView s2) noexcept
Definition qstring.h:793
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
Definition qstring.h:1226
friend bool comparesEqual(const QString &lhs, QByteArrayView rhs) noexcept
Definition qstring.h:893
std::enable_if< sizeof...(Args)>=2 &&std::is_same< QtPrivate::BoolList< is_convertible_to_view_or_qstring< Args >::value..., true >, QtPrivate::BoolList< true, is_convertible_to_view_or_qstring< Args >::value... > >::value, QString >::type arg(Args &&...args) const
Definition qstring.h:284
QChar front() const
Definition qstring.h:230
short toShort(bool *ok=nullptr, int base=10) const
Returns the string converted to a short using base base, which is 10 by default and must be between 2...
Definition qstring.h:727
QT_CORE_INLINE_SINCE(6, 7) qsizetype lastIndexOf(QChar c
void shrink_to_fit()
Definition qstring.h:961
static int compare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Definition qstring.h:705
QString & prepend(const QChar *uc, qsizetype len)
Definition qstring.h:479
QString & operator+=(const QString &s)
Appends the string other onto the end of this string and returns a reference to this string.
Definition qstring.h:534
QString sliced(qsizetype pos) &&
Definition qstring.h:409
friend Qt::strong_ordering compareThreeWay(const QString &lhs, QByteArrayView rhs) noexcept
Definition qstring.h:899
DataPointer & data_ptr()
Definition qstring.h:1093
const_reverse_iterator crend() const
Definition qstring.h:947
QString toLower() const &
Definition qstring.h:435
qsizetype lastIndexOf(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition qstring.h:303
QString & append(QStringView v)
Definition qstring.h:474
QString & insert(qsizetype i, QStringView v)
Definition qstring.h:467
static QString fromStdU32String(const std::u32string &s)
Definition qstring.h:1467
QByteArray toLocal8Bit() const &
Definition qstring.h:638
auto tokenize(Needle &&needle, Flags...flags) const &&noexcept(noexcept(qTokenize(std::declval< const QString >(), std::forward< Needle >(needle), flags...))) -> decltype(qTokenize(std::move(*this), std::forward< Needle >(needle), flags...))
Definition qstring.h:605
const DataPointer & data_ptr() const
Definition qstring.h:1094
void push_back(const QString &s)
This function is provided for STL compatibility, appending the given other string onto the end of thi...
Definition qstring.h:958
QChar * data()
Returns a pointer to the data stored in the QString.
Definition qstring.h:1240
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition qstring.h:1369
static QString fromWCharArray(const wchar_t *string, qsizetype size=-1)
Definition qstring.h:1309
QString & operator+=(QLatin1StringView s)
Definition qstring.h:536
void squeeze()
Releases any memory not required to store the character data.
Definition qstring.h:1333
QString & setUtf16(const ushort *utf16, qsizetype size)
Resizes the string to size characters and copies unicode into the string.
Definition qstring.h:1343
friend bool comparesEqual(const QString &s1, QLatin1StringView s2) noexcept
Definition qstring.h:790
int localeAwareCompare(const QString &s) const
Definition qstring.cpp:6907
QT_ASCII_CAST_WARN QString & prepend(const QByteArray &s)
Definition qstring.h:863
auto tokenize(Needle &&needle, Flags...flags) &&noexcept(noexcept(qTokenize(std::declval< QString >(), std::forward< Needle >(needle), flags...))) -> decltype(qTokenize(std::move(*this), std::forward< Needle >(needle), flags...))
Definition qstring.h:611
std::u16string toStdU16String() const
Definition qstring.h:1464
QString trimmed() const &
Definition qstring.h:447
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.h:1257
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition qstring.h:933
QString last(qsizetype n) &&
Definition qstring.h:407
qptrdiff difference_type
Definition qstring.h:951
QT_ASCII_CAST_WARN QString & prepend(const char *s)
Definition qstring.h:861
QString & removeLast()
Definition qstring.h:558
ulong toULong(bool *ok=nullptr, int base=10) const
Returns the string converted to an {unsigned long} using base base, which is 10 by default and must b...
Definition qstring.h:737
static QString fromUtf8(const char *utf8, qsizetype size)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition qstring.h:660
QByteArray toUtf8() const &
Definition qstring.h:634
static Q_WEAK_OVERLOAD QString fromLatin1(const QByteArray &ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.h:652
QString last(qsizetype n) const &
Definition qstring.h:392
static int localeAwareCompare(const QString &s1, const QString &s2)
Compares s1 with s2 and returns an integer less than, equal to, or greater than zero if s1 is less th...
Definition qstring.h:722
QString & prepend(QUtf8StringView s)
Definition qstring.h:483
QStringList split(const QRegularExpression &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts) const
static QString fromStdWString(const std::wstring &s)
Returns a copy of the str string.
Definition qstring.h:1458
QString sliced(qsizetype pos, qsizetype n) const &
Definition qstring.h:396
QString & prepend(QChar c)
Definition qstring.h:478
QByteArray toLocal8Bit() &&
Definition qstring.h:640
auto tokenize(Needle &&needle, Flags...flags) const &noexcept(noexcept(qTokenize(std::declval< const QString & >(), std::forward< Needle >(needle), flags...))) -> decltype(qTokenize(*this, std::forward< Needle >(needle), flags...))
Definition qstring.h:599
QString toUpper() const &
Definition qstring.h:439
std::reverse_iterator< iterator > reverse_iterator
Definition qstring.h:932
const_reverse_iterator rend() const
Definition qstring.h:945
const_iterator constBegin() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first character in the st...
Definition qstring.h:1355
QString toCaseFolded() &&
Definition qstring.h:445
NormalizationForm
This enum describes the various normalized forms of Unicode text.
Definition qstring.h:617
@ NormalizationForm_KD
Definition qstring.h:620
@ NormalizationForm_C
Definition qstring.h:619
@ NormalizationForm_D
Definition qstring.h:618
const_iterator ConstIterator
Qt-style synonym for QString::const_iterator.
Definition qstring.h:931
qsizetype lastIndexOf(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
Definition qstring.h:307
static int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Definition qstring.h:712
friend Qt::strong_ordering compareThreeWay(const QString &lhs, const char *rhs) noexcept
Definition qstring.h:919
reverse_iterator rbegin()
Definition qstring.h:942
const QChar * unicode() const
Returns a Unicode representation of the string.
Definition qstring.h:1230
int compare(QChar ch, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
Definition qstring.h:702
qsizetype length() const noexcept
Returns the number of characters in this string.
Definition qstring.h:191
const QChar * const_iterator
Definition qstring.h:929
~QString()
Destroys the string.
Definition qstring.h:1323
friend Qt::strong_ordering compareThreeWay(const QString &s1, std::nullptr_t) noexcept
Definition qstring.h:803
QString chopped(qsizetype n) &&
Definition qstring.h:413
bool endsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
Definition qstring.h:423
void resize(qsizetype size)
Sets the size of the string to size characters.
Definition qstring.cpp:2668
static Q_WEAK_OVERLOAD QString fromUtf8(const QByteArray &ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.h:659
QChar value_type
Definition qstring.h:956
\inmodule QtCore \title Classes and helpers for defining comparison operators \keyword qtcompare
Definition qcompare.h:400
static const strong_ordering greater
Definition qcompare.h:405
static const strong_ordering equivalent
Definition qcompare.h:403
#define this
Definition dialogs.cpp:9
QString str
[2]
a resize(100000)
b clear()
list append(new Employee("Blackpool", "Stephen"))
cache insert(employee->id(), employee)
QSet< QString >::iterator it
set reserve(20000)
Combined button and popup list for selecting options.
qsizetype fromUtf8(uchar b, OutputPtr &dst, InputPtr &src, InputPtr end)
\macro QT_NO_KEYWORDS >
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QByteArrayView haystack, qsizetype from, char needle) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QByteArrayView haystack, QByteArrayView needle) noexcept
Q_CORE_EXPORT QString convertToQString(QAnyStringView s)
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QByteArrayView haystack, QByteArrayView needle) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype count(QByteArrayView haystack, QByteArrayView needle) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QStringView lhs, QStringView rhs) noexcept
Definition qstring.cpp:1393
QStringViewArg qStringLikeToArg(const QString &s) noexcept
Definition qstring.h:1579
qsizetype findString(QStringView str, qsizetype from, QChar needle, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Q_CORE_EXPORT QString argToQString(QStringView pattern, size_t n, const ArgBase **args)
Definition qstring.cpp:9291
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
std::is_same< Char, char32_t > IsCompatibleChar32TypeHelper
Definition qstring.h:54
IsCompatibleChar8TypeHelper< q20::remove_cvref_t< Char > > IsCompatibleChar8Type
Q_ALWAYS_INLINE QString argToQStringDispatch(StringView pattern, const Args &...args)
Definition qstring.h:1573
IsCompatibleChar32TypeHelper< q20::remove_cvref_t< Char > > IsCompatibleChar32Type
Definition qstring.h:57
constexpr bool isLatin1(QLatin1StringView s) noexcept
Definition qstring.h:66
Definition qcompare.h:63
constexpr Qt::strong_ordering compareThreeWay(LeftInt lhs, RightInt rhs) noexcept
CaseSensitivity
@ CaseSensitive
@ KeepEmptyParts
Definition qnamespace.h:127
Initialization
constexpr T * to_address(T *p) noexcept
Definition q20memory.h:57
qsizetype erase_if(QByteArray &ba, Predicate pred)
Definition qbytearray.h:788
qsizetype erase(QByteArray &ba, const T &t)
Definition qbytearray.h:782
size_t qstrlen(const char *str)
#define Q_DECLARE_STRONGLY_ORDERED(...)
#define Q_DECL_NS_RETURNS_AUTORELEASED
#define QT_WARNING_DISABLE_INTEL(number)
#define Q_DECL_CF_RETURNS_RETAINED
#define Q_WEAK_OVERLOAD
#define QT_IGNORE_DEPRECATIONS(statement)
#define QT_WARNING_POP
#define QT_WARNING_DISABLE_MSVC(number)
#define Q_ATTRIBUTE_FORMAT_PRINTF(A, B)
#define QT_WARNING_PUSH
#define Q_IMPLICIT
#define Q_ALWAYS_INLINE
constexpr bool operator!=(const timespec &t1, const timespec &t2)
constexpr timespec operator+(const timespec &t1, const timespec &t2)
constexpr timespec & operator+=(timespec &t1, const timespec &t2)
AudioChannelLayoutTag tag
#define Q_FORWARD_DECLARE_CF_TYPE(type)
#define Q_FORWARD_DECLARE_OBJC_CLASS(classname)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
bool comparesEqual(const QDir &lhs, const QDir &rhs)
Definition qdir.cpp:1819
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
quint32 Tag
Flags
NSUInteger capacity
static T toIntegral_helper(const QLocalePrivate *d, QStringView str, bool *ok)
Definition qlocale.cpp:1434
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
static bool contains(const QJsonArray &haystack, unsigned needle)
Definition qopengl.cpp:116
GLsizei const GLfloat * v
[13]
GLenum mode
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLuint end
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
GLenum GLuint GLenum GLsizei length
GLenum GLenum GLsizei count
GLdouble GLdouble right
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat f
GLenum src
GLint GLsizei width
GLint left
GLenum type
GLbitfield flags
GLuint start
GLboolean GLboolean g
GLint first
GLfloat n
GLint GLsizei GLsizei GLenum format
GLdouble s
[6]
Definition qopenglext.h:235
GLuint res
const GLubyte * c
GLuint GLfloat * val
GLenum array
GLdouble GLdouble t
Definition qopenglext.h:243
GLint GLenum GLboolean normalized
Definition qopenglext.h:752
GLuint64EXT * result
[6]
GLfloat GLfloat p
[1]
GLuint GLenum option
GLenum GLsizei len
GLubyte * pattern
GLenum GLint GLint * precision
bool operator>(const QPoint &a, const QPoint &b)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
static void split(QT_FT_Vector *b)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
static bool operator<(const QSettingsIniKey &k1, const QSettingsIniKey &k2)
static constexpr QChar sep
static QT_BEGIN_NAMESPACE const char * asString(QSSGRenderGraphObject::Type type)
SSL_CTX int void * arg
static QChar * fromLocal8Bit(QChar *out, QByteArrayView in, QStringConverter::State *state)
static char * toLocal8Bit(char *out, QStringView in, QStringConverter::State *state)
QBasicUtf8StringView< false > QUtf8StringView
Definition qstringfwd.h:46
QArrayDataPointer< char16_t > QStringPrivate
constexpr auto qTokenize(Haystack &&h, Needle &&n, Flags...flags) noexcept(QtPrivate::Tok::is_nothrow_constructible_from< Haystack, Needle >::value) -> decltype(QtPrivate::Tok::TokenizerResult< Haystack, Needle >{std::forward< Haystack >(h), std::forward< Needle >(n), flags...})
QStringView qToStringViewIgnoringNull(const QStringLike &s) noexcept
#define s2
#define QT_ASCII_CAST_WARN
#define QT_DEPRECATED_VERSION_X_6_4(text)
#define QT_DEPRECATED_VERSION_X_6_0(text)
#define QT_DEPRECATED_VERSION_X_6_8(text)
static int compare(quint64 a, quint64 b)
unsigned char uchar
Definition qtypes.h:32
unsigned long ulong
Definition qtypes.h:35
ptrdiff_t qptrdiff
Definition qtypes.h:164
quint64 qulonglong
Definition qtypes.h:64
unsigned long long quint64
Definition qtypes.h:61
ptrdiff_t qsizetype
Definition qtypes.h:165
unsigned int uint
Definition qtypes.h:34
long long qint64
Definition qtypes.h:60
unsigned short ushort
Definition qtypes.h:33
qint64 qlonglong
Definition qtypes.h:63
Qt::weak_ordering compareThreeWay(const QUrl &lhs, const QUrl &rhs)
Definition qurl.cpp:3079
static const uint base
Definition qurlidna.cpp:20
bool operator<=(const QUuid &lhs, const QUuid &rhs) noexcept
Definition quuid.h:294
bool operator>=(const QUuid &lhs, const QUuid &rhs) noexcept
Definition quuid.h:296
static double toDouble(Value v)
#define explicit
QByteArray ba
[0]
settings remove("monkey")
QTextStream out(stdout)
[7]
QDataStream & operator<<(QDataStream &out, const MyClass &myObj)
[4]
QDataStream & operator>>(QDataStream &in, MyClass &myObj)
QObject::connect nullptr
ba fill(true)
list prepend("one")
list lastIndexOf("B")
list indexOf("B")
QSharedPointer< T > other(t)
[5]
this swap(other)
QAction * at
QJSValueList args
\inmodule QtCore \reentrant
Definition qchar.h:18
QLatin1StringView string
Definition qstring.h:1564
constexpr QLatin1StringArg(QLatin1StringView v) noexcept
Definition qstring.h:1566
constexpr QStringViewArg(QStringView v) noexcept
Definition qstring.h:1560