Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qstringview.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qstringview.h"
5
7
8/*!
9 \class QStringView
10 \inmodule QtCore
11 \since 5.10
12 \brief The QStringView class provides a unified view on UTF-16 strings with a read-only subset of the QString API.
13 \reentrant
14 \ingroup tools
15 \ingroup string-processing
16
17 A QStringView references a contiguous portion of a UTF-16 string it does
18 not own. It acts as an interface type to all kinds of UTF-16 string,
19 without the need to construct a QString first.
20
21 The UTF-16 string may be represented as an array (or an array-compatible
22 data-structure such as QString,
23 std::basic_string, etc.) of QChar, \c ushort, \c char16_t or
24 (on platforms, such as Windows, where it is a 16-bit type) \c wchar_t.
25
26 QStringView is designed as an interface type; its main use-case is
27 as a function parameter type. When QStringViews are used as automatic
28 variables or data members, care must be taken to ensure that the referenced
29 string data (for example, owned by a QString) outlives the QStringView on all code paths,
30 lest the string view ends up referencing deleted data.
31
32 When used as an interface type, QStringView allows a single function to accept
33 a wide variety of UTF-16 string data sources. One function accepting QStringView
34 thus replaces three function overloads (taking QString and
35 \c{(const QChar*, qsizetype)}), while at the same time enabling even more string data
36 sources to be passed to the function, such as \c{u"Hello World"}, a \c char16_t
37 string literal.
38
39 QStringViews should be passed by value, not by reference-to-const:
40 \snippet code/src_corelib_text_qstringview.cpp 0
41
42 If you want to give your users maximum freedom in what strings they can pass
43 to your function, accompany the QStringView overload with overloads for
44
45 \list
46 \li \e QChar: this overload can delegate to the QStringView version:
47 \snippet code/src_corelib_text_qstringview.cpp 1
48 even though, for technical reasons, QStringView cannot provide a
49 QChar constructor by itself.
50 \li \e QString: if you store an unmodified copy of the string and thus would
51 like to take advantage of QString's implicit sharing.
52 \li QLatin1StringView: if you can implement the function without converting the
53 QLatin1StringView to UTF-16 first; users expect a function overloaded on
54 QLatin1StringView to perform strictly less memory allocations than the
55 semantically equivalent call of the QStringView version, involving
56 construction of a QString from the QLatin1StringView.
57 \endlist
58
59 QStringView can also be used as the return value of a function. If you call a
60 function returning QStringView, take extra care to not keep the QStringView
61 around longer than the function promises to keep the referenced string data alive.
62 If in doubt, obtain a strong reference to the data by calling toString() to convert
63 the QStringView into a QString.
64
65 QStringView is a \e{Literal Type}, but since it stores data as \c{char16_t}, iteration
66 is not \c constexpr (casts from \c{const char16_t*} to \c{const QChar*}, which is not
67 allowed in \c constexpr functions). You can use an indexed loop and/or utf16() in
68 \c constexpr contexts instead.
69
70 \sa QString
71*/
72
73/*!
74 \typedef QStringView::storage_type
75
76 Alias for \c{char16_t}.
77*/
78
79/*!
80 \typedef QStringView::value_type
81
82 Alias for \c{const QChar}. Provided for compatibility with the STL.
83*/
84
85/*!
86 \typedef QStringView::difference_type
87
88 Alias for \c{std::ptrdiff_t}. Provided for compatibility with the STL.
89*/
90
91/*!
92 \typedef QStringView::size_type
93
94 Alias for qsizetype. Provided for compatibility with the STL.
95*/
96
97/*!
98 \typedef QStringView::reference
99
100 Alias for \c{value_type &}. Provided for compatibility with the STL.
101
102 QStringView does not support mutable references, so this is the same
103 as const_reference.
104*/
105
106/*!
107 \typedef QStringView::const_reference
108
109 Alias for \c{value_type &}. Provided for compatibility with the STL.
110*/
111
112/*!
113 \typedef QStringView::pointer
114
115 Alias for \c{value_type *}. Provided for compatibility with the STL.
116
117 QStringView does not support mutable pointers, so this is the same
118 as const_pointer.
119*/
120
121/*!
122 \typedef QStringView::const_pointer
123
124 Alias for \c{value_type *}. Provided for compatibility with the STL.
125*/
126
127/*!
128 \typedef QStringView::iterator
129
130 This typedef provides an STL-style const iterator for QStringView.
131
132 QStringView does not support mutable iterators, so this is the same
133 as const_iterator.
134
135 \sa const_iterator, reverse_iterator
136*/
137
138/*!
139 \typedef QStringView::const_iterator
140
141 This typedef provides an STL-style const iterator for QStringView.
142
143 \sa iterator, const_reverse_iterator
144*/
145
146/*!
147 \typedef QStringView::reverse_iterator
148
149 This typedef provides an STL-style const reverse iterator for QStringView.
150
151 QStringView does not support mutable reverse iterators, so this is the
152 same as const_reverse_iterator.
153
154 \sa const_reverse_iterator, iterator
155*/
156
157/*!
158 \typedef QStringView::const_reverse_iterator
159
160 This typedef provides an STL-style const reverse iterator for QStringView.
161
162 \sa reverse_iterator, const_iterator
163*/
164
165/*!
166 \fn size_t qHash(QStringView key, size_t seed)
167 \since 5.10
168 \qhashold{QStringView}
169*/
170
171/*!
172 \fn QStringView::QStringView()
173
174 Constructs a null string view.
175
176 \sa isNull()
177*/
178
179/*!
180 \fn QStringView::QStringView(std::nullptr_t)
181
182 Constructs a null string view.
183
184 \sa isNull()
185*/
186
187/*!
188 \fn template <typename Char, QStringView::if_compatible_char<Char> = true> QStringView::QStringView(const Char *str, qsizetype len)
189
190 Constructs a string view on \a str with length \a len.
191
192 The range \c{[str,len)} must remain valid for the lifetime of this string view object.
193
194 Passing \nullptr as \a str is safe if \a len is 0, too, and results in a null string view.
195
196 The behavior is undefined if \a len is negative or, when positive, if \a str is \nullptr.
197
198//! [compatible-char-types]
199 \constraints \c Char is a compatible
200 character type. The compatible character types are: \c QChar, \c ushort, \c char16_t and
201 (on platforms, such as Windows, where it is a 16-bit type) \c wchar_t.
202//! [compatible-char-types]
203*/
204
205/*!
206 \fn template <typename Char, QStringView::if_compatible_char<Char> = true> QStringView::QStringView(const Char *first, const Char *last)
207
208 Constructs a string view on \a first with length (\a last - \a first).
209
210 The range \c{[first,last)} must remain valid for the lifetime of
211 this string view object.
212
213 Passing \c \nullptr as \a first is safe if \a last is \nullptr, too,
214 and results in a null string view.
215
216 The behavior is undefined if \a last precedes \a first, or \a first
217 is \nullptr and \a last is not.
218
219 \include qstringview.cpp compatible-char-types
220*/
221
222/*!
223 \fn template <typename Char> QStringView::QStringView(const Char *str)
224
225 Constructs a string view on \a str. The length is determined
226 by scanning for the first \c{Char(0)}.
227
228 \a str must remain valid for the lifetime of this string view object.
229
230 Passing \nullptr as \a str is safe and results in a null string view.
231
232 \include qstringview.cpp compatible-char-types
233*/
234
235/*!
236 \fn template <typename Char, size_t N> QStringView::QStringView(const Char (&string)[N])
237
238 Constructs a string view on the character string literal \a string.
239 The view covers the array until the first \c{Char(0)} is encountered,
240 or \c N, whichever comes first.
241 If you need the full array, use fromArray() instead.
242
243 \a string must remain valid for the lifetime of this string view
244 object.
245
246 \include qstringview.cpp compatible-char-types
247
248 \sa fromArray
249*/
250
251/*!
252 \fn QStringView::QStringView(const QString &str)
253
254 Constructs a string view on \a str.
255
256 \c{str.data()} must remain valid for the lifetime of this string view object.
257
258 The string view will be null if and only if \c{str.isNull()}.
259*/
260
261/*!
262 \fn template <typename Container, QStringView::if_compatible_container<Container>> QStringView::QStringView(const Container &str)
263
264 Constructs a string view on \a str. The length is taken from \c{std::size(str)}.
265
266 \c{std::data(str)} must remain valid for the lifetime of this string view object.
267
268 The string view will be empty if and only if \c{std::size(str) == 0}. It is unspecified
269 whether this constructor can result in a null string view (\c{std::data(str)} would
270 have to return \nullptr for this).
271
272 \constraints \c Container is a
273 container with a compatible character type as \c{value_type}. The
274 compatible character types are: \c QChar, \c ushort, \c char16_t and
275 (on platforms, such as Windows, where it is a 16-bit type) \c wchar_t.
276
277 \sa isNull(), isEmpty()
278*/
279
280/*!
281 \fn template <typename Char, size_t Size, QStringView::if_compatible_char<Char> = true> static QStringView QStringView::fromArray(const Char (&string)[Size]) noexcept
282
283 Constructs a string view on the full character string literal \a string,
284 including any trailing \c{Char(0)}. If you don't want the
285 null-terminator included in the view then you can chop() it off
286 when you are certain it is at the end. Alternatively you can use
287 the constructor overload taking an array literal which will create
288 a view up to, but not including, the first null-terminator in the data.
289
290 \a string must remain valid for the lifetime of this string view
291 object.
292
293 This function will work with any array literal if \c Char is a
294 compatible character type. The compatible character types are: \c QChar, \c ushort, \c
295 char16_t and (on platforms, such as Windows, where it is a 16-bit
296 type) \c wchar_t.
297*/
298
299/*!
300 \fn QString QStringView::toString() const
301
302 Returns a deep copy of this string view's data as a QString.
303
304 The return value will be the null QString if and only if this string view is null.
305*/
306
307/*!
308 \fn const QChar *QStringView::data() const
309
310//! [const-pointer-to-first-ch]
311 Returns a const pointer to the first character in the string view.
312
313 \note The character array represented by the return value is \e not null-terminated.
314//! [const-pointer-to-first-ch]
315
316 \sa begin(), end(), utf16()
317*/
318
319/*!
320 \fn const QChar *QStringView::constData() const
321 \since 6.0
322
323 \include qstringview.cpp const-pointer-to-first-ch
324
325 \sa data(), begin(), end(), utf16()
326*/
327
328/*!
329 \fn const storage_type *QStringView::utf16() const
330
331 \include qstringview.cpp const-pointer-to-first-ch
332
333 \c{storage_type} is \c{char16_t}.
334
335 \sa begin(), end(), data()
336*/
337
338/*!
339 \fn QStringView::const_iterator QStringView::begin() const
340
341 Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first character in
342 the string view.
343
344 This function is provided for STL compatibility.
345
346 \sa end(), constBegin(), cbegin(), rbegin(), data()
347*/
348
349/*!
350 \fn QStringView::const_iterator QStringView::cbegin() const
351
352 Same as begin().
353
354 This function is provided for STL compatibility.
355
356 \sa cend(), begin(), constBegin(), crbegin(), data()
357*/
358
359/*!
360 \fn QStringView::const_iterator QStringView::constBegin() const
361 \since 6.1
362
363 Same as begin().
364
365 \sa constEnd(), begin(), cbegin(), crbegin(), data()
366*/
367
368/*!
369 \fn QStringView::const_iterator QStringView::end() const
370
371 Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
372 character after the last character in the list.
373
374 This function is provided for STL compatibility.
375
376 \sa begin(), constEnd(), cend(), rend()
377*/
378
379/*! \fn QStringView::const_iterator QStringView::cend() const
380
381 Same as end().
382
383 This function is provided for STL compatibility.
384
385 \sa cbegin(), end(), constEnd(), crend()
386*/
387
388/*! \fn QStringView::const_iterator QStringView::constEnd() const
389 \since 6.1
390
391 Same as end().
392
393 \sa constBegin(), end(), cend(), crend()
394*/
395
396/*!
397 \fn QStringView::const_reverse_iterator QStringView::rbegin() const
398
399 Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
400 character in the string view, in reverse order.
401
402 This function is provided for STL compatibility.
403
404 \sa rend(), crbegin(), begin()
405*/
406
407/*!
408 \fn QStringView::const_reverse_iterator QStringView::crbegin() const
409
410 Same as rbegin().
411
412 This function is provided for STL compatibility.
413
414 \sa crend(), rbegin(), cbegin()
415*/
416
417/*!
418 \fn QStringView::const_reverse_iterator QStringView::rend() const
419
420 Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to one past
421 the last character in the string view, in reverse order.
422
423 This function is provided for STL compatibility.
424
425 \sa rbegin(), crend(), end()
426*/
427
428/*!
429 \fn QStringView::const_reverse_iterator QStringView::crend() const
430
431 Same as rend().
432
433 This function is provided for STL compatibility.
434
435 \sa crbegin(), rend(), cend()
436*/
437
438/*!
439 \fn bool QStringView::empty() const
440
441 Returns whether this string view is empty - that is, whether \c{size() == 0}.
442
443 This function is provided for STL compatibility.
444
445 \sa isEmpty(), isNull(), size(), length()
446*/
447
448/*!
449 \fn bool QStringView::isEmpty() const
450
451 Returns whether this string view is empty - that is, whether \c{size() == 0}.
452
453 This function is provided for compatibility with other Qt containers.
454
455 \sa empty(), isNull(), size(), length()
456*/
457
458/*!
459 \fn bool QStringView::isNull() const
460
461 Returns whether this string view is null - that is, whether \c{data() == nullptr}.
462
463 This functions is provided for compatibility with other Qt containers.
464
465 \sa empty(), isEmpty(), size(), length()
466*/
467
468/*!
469 \fn qsizetype QStringView::size() const
470
471 Returns the size of this string view, in UTF-16 code units (that is,
472 surrogate pairs count as two for the purposes of this function, the same
473 as in QString).
474
475 \sa empty(), isEmpty(), isNull(), length()
476*/
477
478/*!
479 \fn QStringView::length() const
480
481 Same as size().
482
483 This function is provided for compatibility with other Qt containers.
484
485 \sa empty(), isEmpty(), isNull(), size()
486*/
487
488/*!
489 \fn QChar QStringView::operator[](qsizetype n) const
490
491 Returns the character at position \a n in this string view.
492
493 The behavior is undefined if \a n is negative or not less than size().
494
495 \sa at(), front(), back()
496*/
497
498/*!
499 \fn QChar QStringView::at(qsizetype n) const
500
501 Returns the character at position \a n in this string view.
502
503 The behavior is undefined if \a n is negative or not less than size().
504
505 \sa operator[](), front(), back()
506*/
507
508/*!
509 \fn template <typename...Args> QString QStringView::arg(Args &&...args) const
510 \fn template <typename...Args> QString QLatin1StringView::arg(Args &&...args) const
511 \fn template <typename...Args> QString QString::arg(Args &&...args) const
512 \since 5.14
513
514//![qstring-multi-arg]
515 Replaces occurrences of \c{%N} in this string with the corresponding
516 argument from \a args. The arguments are not positional: the first of
517 the \a args replaces the \c{%N} with the lowest \c{N} (all of them), the
518 second of the \a args the \c{%N} with the next-lowest \c{N} etc.
519
520 \c Args can consist of anything that implicitly converts to QAnyStringView.
521//![qstring-multi-arg]
522
523 \note In Qt versions prior to 6.9, QAnyStringView and UTF-8 strings
524 (QUtf8StringView, QByteArray, QByteArrayView, \c{const char8_t*}, etc) were
525 not supported as \a args.
526
527 \sa QString::arg()
528*/
529
530/*!
531 \fn QChar QStringView::front() const
532
533 Returns the first character in the string view. Same as first().
534
535 This function is provided for STL compatibility.
536
537//! [calling-on-empty-is-UB]
538 \warning Calling this function on an empty string view constitutes
539 undefined behavior.
540//! [calling-on-empty-is-UB]
541
542 \sa back(), first(), last()
543*/
544
545/*!
546 \fn QChar QStringView::back() const
547
548 Returns the last character in the string view. Same as last().
549
550 This function is provided for STL compatibility.
551
552 \include qstringview.cpp calling-on-empty-is-UB
553
554 \sa front(), first(), last()
555*/
556
557/*!
558 \fn QChar QStringView::first() const
559
560 Returns the first character in the string view. Same as front().
561
562 This function is provided for compatibility with other Qt containers.
563
564 \include qstringview.cpp calling-on-empty-is-UB
565
566 \sa front(), back(), last()
567*/
568
569/*!
570 \fn QChar QStringView::last() const
571
572 Returns the last character in the string view. Same as back().
573
574 This function is provided for compatibility with other Qt containers.
575
576 \include qstringview.cpp calling-on-empty-is-UB
577
578 \sa back(), front(), first()
579*/
580
581/*!
582 \fn QStringView QStringView::mid(qsizetype start, qsizetype length) const
583
584 Returns the substring of length \a length starting at position
585 \a start in this object.
586
587 \deprecated Use sliced() instead in new code.
588
589 Returns an empty string view if \a start exceeds the
590 length of the string view. If there are less than \a length characters
591 available in the string view starting at \a start, or if
592 \a length is negative (default), the function returns all characters that
593 are available from \a start.
594
595 \sa first(), last(), sliced(), chopped(), chop(), truncate(), slice()
596*/
597
598/*!
599 \fn QStringView QStringView::left(qsizetype length) const
600
601 \deprecated Use first() instead in new code.
602
603 Returns the substring of length \a length starting at position
604 0 in this object.
605
606 The entire string view is returned if \a length is greater than or equal
607 to size(), or less than zero.
608
609 \sa first(), last(), sliced(), startsWith(), chopped(), chop(), truncate(), slice()
610*/
611
612/*!
613 \fn QStringView QStringView::right(qsizetype length) const
614
615 \deprecated Use last() instead in new code.
616
617 Returns the substring of length \a length starting at position
618 size() - \a length in this object.
619
620 The entire string view is returned if \a length is greater than or equal
621 to size(), or less than zero.
622
623 \sa first(), last(), sliced(), endsWith(), chopped(), chop(), truncate(), slice()
624*/
625
626/*!
627 \fn QStringView QStringView::first(qsizetype n) const
628 \since 6.0
629
630 Returns a string view that points to the first \a n characters
631 of this string view.
632
633 \note The behavior is undefined when \a n < 0 or \a n > size().
634
635 \sa last(), sliced(), startsWith(), chopped(), chop(), truncate(), slice()
636*/
637
638/*!
639 \fn QStringView QStringView::last(qsizetype n) const
640 \since 6.0
641
642 Returns a string view that points to the last \a n characters of this string
643 view.
644
645 \note The behavior is undefined when \a n < 0 or \a n > size().
646
647 \sa first(), sliced(), endsWith(), chopped(), chop(), truncate(), slice()
648*/
649
650/*!
651 \fn QStringView QStringView::sliced(qsizetype pos, qsizetype n) const
652 \since 6.0
653
654 Returns a string view that points to \a n characters of this string view,
655 starting at position \a pos.
656
657//! [UB-sliced-index-length]
658 \note The behavior is undefined when \a pos < 0, \a n < 0,
659 or \a pos + \a n > size().
660//! [UB-sliced-index-length]
661
662 \sa first(), last(), chopped(), chop(), truncate(), slice()
663*/
664
665/*!
666 \fn QStringView QStringView::sliced(qsizetype pos) const
667 \since 6.0
668 \overload
669
670 Returns a string view starting at position \a pos in this object,
671 and extending to its end.
672
673//! [UB-sliced-index-only]
674 \note The behavior is undefined when \a pos < 0 or \a pos > size().
675//! [UB-sliced-index-only]
676
677 \sa first(), last(), chopped(), chop(), truncate(), slice()
678*/
679
680/*!
681 \fn QStringView &QStringView::slice(qsizetype pos, qsizetype n)
682 \since 6.8
683
684 Modifies this string view to start from position \a pos, extending
685 for \a n code points.
686
687 \include qstringview.cpp UB-sliced-index-length
688
689 \sa sliced(), first(), last(), chopped(), chop(), truncate()
690*/
691
692/*!
693 \fn QStringView &QStringView::slice(qsizetype pos)
694 \since 6.8
695 \overload
696
697 Modifies this string view to start from position \a pos, extending
698 to its end.
699
700 \include qstringview.cpp UB-sliced-index-only
701
702 \sa sliced(), first(), last(), chopped(), chop(), truncate()
703*/
704
705/*!
706 \fn QStringView QStringView::chopped(qsizetype length) const
707
708 Returns the substring of length size() - \a length starting at the
709 beginning of this object.
710
711 Same as \c{left(size() - length)}.
712
713 \note The behavior is undefined when \a length < 0 or \a length > size().
714
715 \sa mid(), left(), right(), chop(), truncate(), slice()
716*/
717
718/*!
719 \fn void QStringView::truncate(qsizetype length)
720
721 Truncates this string view to length \a length.
722
723 Same as \c{*this = left(length)}.
724
725 \note The behavior is undefined when \a length < 0 or \a length > size().
726
727 \sa mid(), left(), right(), chopped(), chop()
728*/
729
730/*!
731 \fn void QStringView::chop(qsizetype length)
732
733 Truncates this string view by \a length characters.
734
735 Same as \c{*this = left(size() - length)}.
736
737 \note The behavior is undefined when \a length < 0 or \a length > size().
738
739 \sa mid(), left(), right(), chopped(), truncate(), slice()
740*/
741
742/*!
743 \fn QStringView QStringView::trimmed() const
744
745 Strips leading and trailing whitespace and returns the result.
746
747 Whitespace means any character for which QChar::isSpace() returns
748 \c true. This includes the ASCII characters '\\t', '\\n', '\\v',
749 '\\f', '\\r', and ' '.
750*/
751
752/*!
753 \fn int QStringView::compare(QStringView str, Qt::CaseSensitivity cs) const
754 \since 5.12
755
756 Compares this string view with string view \a str and returns a negative integer if
757 this string view is less than \a str, a positive integer if it is greater than
758 \a str, and zero if they are equal.
759
760 \include qstring.qdocinc {search-comparison-case-sensitivity} {comparison}
761
762 \sa operator==(), operator<(), operator>()
763*/
764
765/*!
766 \fn int QStringView::compare(QUtf8StringView str, Qt::CaseSensitivity cs) const
767 \since 6.5
768
769 Compares this string view with QUtf8StringView \a str and returns a negative integer if
770 this string view is less than \a str, a positive integer if it is greater than
771 \a str, and zero if they are equal.
772
773 \include qstring.qdocinc {search-comparison-case-sensitivity} {comparison}
774
775 \sa operator==(), operator<(), operator>()
776*/
777
778/*!
779 \fn int QStringView::compare(QLatin1StringView l1, Qt::CaseSensitivity cs) const
780 \fn int QStringView::compare(QChar ch) const
781 \fn int QStringView::compare(QChar ch, Qt::CaseSensitivity cs) const
782 \since 5.15
783
784 Compares this string view to the Latin-1 string view \a l1, or the character \a ch.
785 Returns a negative integer if this string view is less than \a l1 or \a ch,
786 a positive integer if it is greater than \a l1 or \a ch, and zero if they are equal.
787
788 \include qstring.qdocinc {search-comparison-case-sensitivity} {comparison}
789
790 \sa operator==(), operator<(), operator>()
791*/
792
793/*!
794 \fn QStringView::operator==(const QStringView &lhs, const QStringView &rhs)
795 \fn QStringView::operator!=(const QStringView &lhs, const QStringView &rhs)
796 \fn QStringView::operator< (const QStringView &lhs, const QStringView &rhs)
797 \fn QStringView::operator<=(const QStringView &lhs, const QStringView &rhs)
798 \fn QStringView::operator> (const QStringView &lhs, const QStringView &rhs)
799 \fn QStringView::operator>=(const QStringView &lhs, const QStringView &rhs)
800
801 Operators for comparing \a lhs to \a rhs.
802
803 \sa compare()
804*/
805
806/*!
807 \fn int QStringView::localeAwareCompare(QStringView other) const
808 \since 6.4
809
810 Compares this string view with the \a other string view and returns
811 an integer less than, equal to, or greater than zero if this string
812 view is less than, equal to, or greater than the \a other string view.
813
814 The comparison is performed in a locale- and also platform-dependent
815 manner. Use this function to present sorted lists of strings to the
816 user.
817
818 \sa {Comparing Strings}
819*/
820
821/*
822//! [utf16-or-latin1-or-ch]
823the UTF-16 string viewed by \a str, the Latin-1 string viewed by \a l1,
824or the character \a ch
825//! [utf16-or-latin1-or-ch]
826*/
827
828/*!
829 \fn bool QStringView::startsWith(QStringView str, Qt::CaseSensitivity cs) const
830 \fn bool QStringView::startsWith(QLatin1StringView l1, Qt::CaseSensitivity cs) const
831 \fn bool QStringView::startsWith(QChar ch) const
832 \fn bool QStringView::startsWith(QChar ch, Qt::CaseSensitivity cs) const
833
834 Returns \c true if this string view starts with
835 \include qstringview.cpp utf16-or-latin1-or-ch
836 respectively; otherwise returns \c false.
837
838 \include qstring.qdocinc {search-comparison-case-sensitivity} {search}
839
840 \sa endsWith()
841*/
842
843/*!
844 \fn bool QStringView::endsWith(QStringView str, Qt::CaseSensitivity cs) const
845 \fn bool QStringView::endsWith(QLatin1StringView l1, Qt::CaseSensitivity cs) const
846 \fn bool QStringView::endsWith(QChar ch) const
847 \fn bool QStringView::endsWith(QChar ch, Qt::CaseSensitivity cs) const
848
849 Returns \c true if this string view ends with
850 \include qstringview.cpp utf16-or-latin1-or-ch
851 respectively; otherwise returns \c false.
852
853 \include qstring.qdocinc {search-comparison-case-sensitivity} {search}
854
855 \sa startsWith()
856*/
857
858/*!
859 \fn qsizetype QStringView::indexOf(QStringView str, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
860 \fn qsizetype QStringView::indexOf(QLatin1StringView l1, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
861 \fn qsizetype QStringView::indexOf(QChar c, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
862 \since 5.14
863
864 Returns the index position of the first occurrence of
865 \include qstringview.cpp utf16-or-latin1-or-ch
866 respectively, in this string view, searching forward from index position
867 \a from. Returns -1 if \a str, \a l1 or \a ch is not found, respectively.
868
869 \include qstring.qdocinc {search-comparison-case-sensitivity} {search}
870
871 \include qstring.qdocinc negative-index-start-search-from-end
872
873 \sa QString::indexOf()
874*/
875
876/*!
877 \fn bool QStringView::contains(QStringView str, Qt::CaseSensitivity cs) const
878 \fn bool QStringView::contains(QLatin1StringView l1, Qt::CaseSensitivity cs) const
879 \fn bool QStringView::contains(QChar c, Qt::CaseSensitivity cs) const
880 \since 5.14
881
882 Returns \c true if this string view contains an occurrence of
883 \include qstringview.cpp utf16-or-latin1-or-ch
884 respectively; otherwise returns \c false.
885
886 \include qstring.qdocinc {search-comparison-case-sensitivity} {search}
887
888 \sa indexOf()
889*/
890
891/*!
892 \fn qsizetype QStringView::lastIndexOf(QStringView str, qsizetype from, Qt::CaseSensitivity cs) const
893 \fn qsizetype QStringView::lastIndexOf(QLatin1StringView l1, qsizetype from, Qt::CaseSensitivity cs) const
894 \fn qsizetype QStringView::lastIndexOf(QChar c, qsizetype from, Qt::CaseSensitivity cs) const
895 \since 5.14
896
897 Returns the index position of the last occurrence of
898 \include qstringview.cpp utf16-or-latin1-or-ch
899 respectively, in this string view, searching backward from index
900 position \a from.
901
902 \include qstring.qdocinc negative-index-start-search-from-end
903
904 Returns -1 if \a str, \a l1 or \a c is not found, respectively.
905
906 \include qstring.qdocinc {search-comparison-case-sensitivity} {search}
907
908 \note When searching for a 0-length \a str or \a l1, the match at
909 the end of the data is excluded from the search by a negative \a
910 from, even though \c{-1} is normally thought of as searching from
911 the end of the string view: the match at the end is \e after the
912 last character, so it is excluded. To include such a final empty
913 match, either give a positive value for \a from or omit the \a from
914 parameter entirely.
915
916 \sa QString::lastIndexOf()
917*/
918
919/*!
920 \fn qsizetype QStringView::lastIndexOf(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
921 \fn qsizetype QStringView::lastIndexOf(QLatin1StringView l1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
922 \since 6.2
923 \overload lastIndexOf()
924
925 Returns the index position of the last occurrence of the UTF-16 string viewed
926 by \a str or the Latin-1 string viewed by \a l1 respectively, in this string
927 view searching backward from the last character of this string view. Returns
928 -1 if \a str or \a l1 is not found, respectively.
929
930 \include qstring.qdocinc {search-comparison-case-sensitivity} {search}
931
932 \sa QString::lastIndexOf()
933*/
934
935/*!
936 \fn QStringView::lastIndexOf(QChar c, Qt::CaseSensitivity cs) const
937 \since 6.3
938 \overload lastIndexOf()
939*/
940
941#if QT_CONFIG(regularexpression)
942/*!
943 \fn qsizetype QStringView::indexOf(const QRegularExpression &re, qsizetype from, QRegularExpressionMatch *rmatch) const
944 \since 6.1
945
946 Returns the index position of the first match of the regular
947 expression \a re in the string view, searching forward from index
948 position \a from. Returns -1 if \a re didn't match anywhere.
949
950 If the match is successful and \a rmatch is not \nullptr, it also
951 writes the results of the match into the QRegularExpressionMatch object
952 pointed to by \a rmatch.
953
954 \note Due to how the regular expression matching algorithm works,
955 this function will actually match repeatedly from the beginning of
956 the string view until the position \a from is reached.
957*/
958
959/*!
960 \fn qsizetype QStringView::lastIndexOf(const QRegularExpression &re, qsizetype from, QRegularExpressionMatch *rmatch) const
961 \since 6.1
962
963 Returns the index position of the last match of the regular
964 expression \a re in the string view, which starts before the index
965 position \a from.
966
967 \include qstring.qdocinc negative-index-start-search-from-end
968
969 Returns -1 if \a re didn't match anywhere.
970
971 If the match is successful and \a rmatch is not \nullptr, it also
972 writes the results of the match into the QRegularExpressionMatch object
973 pointed to by \a rmatch.
974
975 \note Due to how the regular expression matching algorithm works,
976 this function will actually match repeatedly from the beginning of
977 the string view until the position \a from is reached.
978
979 \note When searching for a regular expression \a re that may match
980 0 characters, the match at the end of the data is excluded from the
981 search by a negative \a from, even though \c{-1} is normally
982 thought of as searching from the end of the string view: the match
983 at the end is \e after the last character, so it is excluded. To
984 include such a final empty match, either give a positive value for
985 \a from or omit the \a from parameter entirely.
986*/
987
988/*!
989 \fn qsizetype QStringView::lastIndexOf(const QRegularExpression &re, QRegularExpressionMatch *rmatch = nullptr) const
990 \since 6.2
991
992 Returns the index position of the last match of the regular
993 expression \a re in the string view. Returns -1 if \a re didn't match
994 anywhere.
995
996 If the match is successful and \a rmatch is not \nullptr, it also
997 writes the results of the match into the QRegularExpressionMatch object
998 pointed to by \a rmatch.
999
1000 \note Due to how the regular expression matching algorithm works,
1001 this function will actually match repeatedly from the beginning of
1002 the string view until the end of the string view is reached.
1003*/
1004
1005/*!
1006 \fn bool QStringView::contains(const QRegularExpression &re, QRegularExpressionMatch *rmatch) const
1007 \since 6.1
1008
1009 Returns \c true if the regular expression \a re matches somewhere in this
1010 string view; otherwise returns \c false.
1011
1012 If the match is successful and \a rmatch is not \nullptr, it also
1013 writes the results of the match into the QRegularExpressionMatch object
1014 pointed to by \a rmatch.
1015
1016 \sa QRegularExpression::match()
1017*/
1018
1019/*!
1020 \fn qsizetype QStringView::count(const QRegularExpression &re) const
1021 \since 6.1
1022
1023 Returns the number of times the regular expression \a re matches
1024 in the string view.
1025
1026 For historical reasons, this function counts overlapping matches.
1027 This behavior is different from simply iterating over the matches
1028 in the string view using QRegularExpressionMatchIterator.
1029
1030 \sa QRegularExpression::globalMatch()
1031
1032*/
1033#endif // QT_CONFIG(regularexpression)
1034
1035/*!
1036 \fn QByteArray QStringView::toLatin1() const
1037
1038 Returns a Latin-1 representation of the string as a QByteArray.
1039
1040 The behavior is undefined if the string contains non-Latin1 characters.
1041
1042 \sa toUtf8(), toLocal8Bit(), QStringEncoder
1043*/
1044
1045/*!
1046 \fn QByteArray QStringView::toLocal8Bit() const
1047
1048 Returns a local 8-bit representation of the string as a QByteArray.
1049
1050 On Unix systems this is equivalen to toUtf8(), on Windows the systems
1051 current code page is being used.
1052
1053 The behavior is undefined if the string contains characters not
1054 supported by the locale's 8-bit encoding.
1055
1056 \sa toLatin1(), toUtf8(), QStringEncoder
1057*/
1058
1059/*!
1060 \fn QByteArray QStringView::toUtf8() const
1061
1062 Returns a UTF-8 representation of the string view as a QByteArray.
1063
1064 UTF-8 is a Unicode codec and can represent all characters in a Unicode
1065 string like QString.
1066
1067 \sa toLatin1(), toLocal8Bit(), QStringEncoder
1068*/
1069
1070/*!
1071 \fn QList<uint> QStringView::toUcs4() const
1072
1073 Returns a UCS-4/UTF-32 representation of the string view as a QList<uint>.
1074
1075 UCS-4 is a Unicode codec and therefore it is lossless. All characters from
1076 this string view will be encoded in UCS-4. Any invalid sequence of code units in
1077 this string view is replaced by the Unicode replacement character
1078 (QChar::ReplacementCharacter, which corresponds to \c{U+FFFD}).
1079
1080 The returned list is not 0-terminated.
1081
1082 \sa toUtf8(), toLatin1(), toLocal8Bit(), QStringEncoder
1083*/
1084
1085/*!
1086 \fn template <typename QStringLike> qToStringViewIgnoringNull(const QStringLike &s);
1087 \since 5.10
1088 \internal
1089
1090 Convert \a s to a QStringView ignoring \c{s.isNull()}.
1091
1092 Returns a string view that references \a{s}' data, but is never null.
1093
1094 This is a faster way to convert a QString to a QStringView,
1095 if null QStrings can legitimately be treated as empty ones.
1096
1097 \sa QString::isNull(), QStringView
1098*/
1099
1100/*!
1101 \fn bool QStringView::isRightToLeft() const
1102 \since 5.11
1103
1104 Returns \c true if the string view is read right to left.
1105
1106 \sa QString::isRightToLeft()
1107*/
1108
1109/*!
1110 \fn bool QStringView::isValidUtf16() const
1111 \since 5.15
1112
1113 Returns \c true if the string view contains valid UTF-16 encoded data,
1114 or \c false otherwise.
1115
1116 Note that this function does not perform any special validation of the
1117 data; it merely checks if it can be successfully decoded from UTF-16.
1118 The data is assumed to be in host byte order; the presence of a BOM
1119 is meaningless.
1120
1121 \sa QString::isValidUtf16()
1122*/
1123
1124/*!
1125 \fn bool QStringView::isLower() const
1126 \since 6.7
1127 Returns \c true if this view is identical to its lowercase folding.
1128
1129 Note that this does \e not mean that the string view does not contain
1130 uppercase letters (some uppercase letters do not have a lowercase
1131 folding; they are left unchanged by toString().toLower()).
1132 For more information, refer to the Unicode standard, section 3.13.
1133
1134 \sa QChar::toLower(), isUpper()
1135*/
1136
1137/*!
1138 \fn bool QStringView::isUpper() const
1139 \since 6.7
1140 Returns \c true if this view is identical to its uppercase folding.
1141
1142 Note that this does \e not mean that the the string view does not contain
1143 lowercase letters (some lowercase letters do not have a uppercase
1144 folding; they are left unchanged by toString().toUpper()).
1145 For more information, refer to the Unicode standard, section 3.13.
1146
1147 \sa QChar::toUpper(), isLower()
1148*/
1149
1150/*!
1151 \fn QStringView::toWCharArray(wchar_t *array) const
1152 \since 5.14
1153
1154 Transcribes this string view into the given \a array.
1155
1156 The caller is responsible for ensuring \a array is large enough to hold the
1157 \c wchar_t encoding of this string view (allocating the array with the same length
1158 as the string view is always sufficient). The array is encoded in UTF-16 on
1159 platforms where \c wchar_t is 2 bytes wide (e.g. Windows); otherwise (Unix
1160 systems), \c wchar_t is assumed to be 4 bytes wide and the data is written
1161 in UCS-4.
1162
1163 \note This function writes no null terminator to the end of \a array.
1164
1165 Returns the number of \c wchar_t entries written to \a array.
1166
1167 \sa QString::toWCharArray()
1168*/
1169
1170/*!
1171 \fn qsizetype QStringView::count(QChar ch, Qt::CaseSensitivity cs) const noexcept
1172
1173 \since 6.0
1174 \overload count()
1175
1176 Returns the number of occurrences of the character \a ch in the
1177 string view.
1178
1179 \include qstring.qdocinc {search-comparison-case-sensitivity} {search}
1180
1181 \sa QString::count(), contains(), indexOf()
1182*/
1183
1184/*!
1185 \fn qsizetype QStringView::count(QStringView str, Qt::CaseSensitivity cs) const noexcept
1186
1187 \since 6.0
1188 \overload count()
1189
1190 Returns the number of (potentially overlapping) occurrences of the
1191 string view \a str in this string view.
1192
1193 \include qstring.qdocinc {search-comparison-case-sensitivity} {search}
1194
1195 \sa QString::count(), contains(), indexOf()
1196*/
1197
1198/*!
1199 \fn qsizetype QStringView::count(QLatin1StringView l1, Qt::CaseSensitivity cs) const noexcept
1200
1201 \since 6.4
1202 \overload count()
1203
1204 Returns the number of (potentially overlapping) occurrences of the
1205 Latin-1 string viewed by \a l1 in this string view.
1206
1207 \include qstring.qdocinc {search-comparison-case-sensitivity} {search}
1208
1209 \sa QString::count(), contains(), indexOf()
1210*/
1211
1212/*!
1213 \fn qint64 QStringView::toLongLong(bool *ok, int base) const
1214
1215 Returns the string view converted to a \c{long long} using base \a
1216 base, which is 10 by default and must be between 2 and 36, or 0.
1217 Returns 0 if the conversion fails.
1218
1219 If \a ok is not \nullptr, failure is reported by setting *\a{ok}
1220 to \c false, and success by setting *\a{ok} to \c true.
1221
1222 If \a base is 0, the C language convention is used: if the string view
1223 begins with "0x", base 16 is used; otherwise, if the string view begins with "0",
1224 base 8 is used; otherwise, base 10 is used.
1225
1226 The string conversion will always happen in the 'C' locale. For locale
1227 dependent conversion use QLocale::toLongLong()
1228
1229 \sa QString::toLongLong()
1230
1231 \since 6.0
1232*/
1233
1234/*!
1235 \fn quint64 QStringView::toULongLong(bool *ok, int base) const
1236
1237 Returns the string view converted to an \c{unsigned long long} using base \a
1238 base, which is 10 by default and must be between 2 and 36, or 0.
1239 Returns 0 if the conversion fails.
1240
1241 If \a ok is not \nullptr, failure is reported by setting *\a{ok}
1242 to \c false, and success by setting *\a{ok} to \c true.
1243
1244 If \a base is 0, the C language convention is used: if the string view
1245 begins with "0x", base 16 is used; otherwise, if the string view begins with "0",
1246 base 8 is used; otherwise, base 10 is used.
1247
1248 The string conversion will always happen in the 'C' locale. For locale
1249 dependent conversion use QLocale::toULongLong()
1250
1251 \sa QString::toULongLong()
1252
1253 \since 6.0
1254*/
1255
1256/*!
1257 \fn long QStringView::toLong(bool *ok, int base) const
1258
1259 Returns the string view converted to a \c long using base \a
1260 base, which is 10 by default and must be between 2 and 36, or 0.
1261 Returns 0 if the conversion fails.
1262
1263 If \a ok is not \nullptr, failure is reported by setting *\a{ok}
1264 to \c false, and success by setting *\a{ok} to \c true.
1265
1266 If \a base is 0, the C language convention is used: if the string view
1267 begins with "0x", base 16 is used; otherwise, if the string view begins with "0",
1268 base 8 is used; otherwise, base 10 is used.
1269
1270 The string conversion will always happen in the 'C' locale. For locale
1271 dependent conversion use QLocale::toLong()
1272
1273 \sa QString::toLong()
1274
1275 \since 6.0
1276*/
1277
1278/*!
1279 \fn ulong QStringView::toULong(bool *ok, int base) const
1280
1281 Returns the string view converted to an \c{unsigned long} using base \a
1282 base, which is 10 by default and must be between 2 and 36, or 0.
1283 Returns 0 if the conversion fails.
1284
1285 If \a ok is not \nullptr, failure is reported by setting *\a{ok}
1286 to \c false, and success by setting *\a{ok} to \c true.
1287
1288 If \a base is 0, the C language convention is used: if the string view
1289 begins with "0x", base 16 is used; otherwise, if the string view begins with "0",
1290 base 8 is used; otherwise, base 10 is used.
1291
1292 The string conversion will always happen in the 'C' locale. For locale
1293 dependent conversion use QLocale::toULongLong()
1294
1295 \sa QString::toULong()
1296
1297 \since 6.0
1298*/
1299
1300/*!
1301 \fn int QStringView::toInt(bool *ok, int base) const
1302
1303 Returns the string view converted to an \c int using base \a
1304 base, which is 10 by default and must be between 2 and 36, or 0.
1305 Returns 0 if the conversion fails.
1306
1307 If \a ok is not \nullptr, failure is reported by setting *\a{ok}
1308 to \c false, and success by setting *\a{ok} to \c true.
1309
1310 If \a base is 0, the C language convention is used: if the string view
1311 begins with "0x", base 16 is used; otherwise, if the string view begins with "0",
1312 base 8 is used; otherwise, base 10 is used.
1313
1314 The string conversion will always happen in the 'C' locale. For locale
1315 dependent conversion use QLocale::toInt()
1316
1317 \sa QString::toInt()
1318
1319 \since 6.0
1320*/
1321
1322/*!
1323 \fn uint QStringView::toUInt(bool *ok, int base) const
1324
1325 Returns the string view converted to an \c{unsigned int} using base \a
1326 base, which is 10 by default and must be between 2 and 36, or 0.
1327 Returns 0 if the conversion fails.
1328
1329 If \a ok is not \nullptr, failure is reported by setting *\a{ok}
1330 to \c false, and success by setting *\a{ok} to \c true.
1331
1332 If \a base is 0, the C language convention is used: if the string view
1333 begins with "0x", base 16 is used; otherwise, if the string view begins with "0",
1334 base 8 is used; otherwise, base 10 is used.
1335
1336 The string conversion will always happen in the 'C' locale. For locale
1337 dependent conversion use QLocale::toUInt()
1338
1339 \sa QString::toUInt()
1340
1341 \since 6.0
1342*/
1343
1344/*!
1345 \fn short QStringView::toShort(bool *ok, int base) const
1346
1347 Returns the string view converted to a \c short using base \a
1348 base, which is 10 by default and must be between 2 and 36, or 0.
1349 Returns 0 if the conversion fails.
1350
1351 If \a ok is not \nullptr, failure is reported by setting *\a{ok}
1352 to \c false, and success by setting *\a{ok} to \c true.
1353
1354 If \a base is 0, the C language convention is used: if the string view
1355 begins with "0x", base 16 is used; otherwise, if the string view begins with "0",
1356 base 8 is used; otherwise, base 10 is used.
1357
1358 The string conversion will always happen in the 'C' locale. For locale
1359 dependent conversion use QLocale::toShort()
1360
1361 \sa QString::toShort()
1362
1363 \since 6.0
1364*/
1365
1366/*!
1367 \fn ushort QStringView::toUShort(bool *ok, int base) const
1368
1369 Returns the string view converted to an \c{unsigned short} using base \a
1370 base, which is 10 by default and must be between 2 and 36, or 0.
1371 Returns 0 if the conversion fails.
1372
1373 If \a ok is not \nullptr, failure is reported by setting *\a{ok}
1374 to \c false, and success by setting *\a{ok} to \c true.
1375
1376 If \a base is 0, the C language convention is used: if the string view
1377 begins with "0x", base 16 is used; otherwise, if the string view begins with "0",
1378 base 8 is used; otherwise, base 10 is used.
1379
1380 The string conversion will always happen in the 'C' locale. For locale
1381 dependent conversion use QLocale::toUShort()
1382
1383 \sa QString::toUShort()
1384
1385 \since 6.0
1386*/
1387
1388/*!
1389 \fn double QStringView::toDouble(bool *ok) const
1390
1391 Returns the string view converted to a \c double value.
1392
1393 Returns an infinity if the conversion overflows or 0.0 if the
1394 conversion fails for other reasons (e.g. underflow).
1395
1396 If \a ok is not \nullptr, failure is reported by setting *\a{ok}
1397 to \c false, and success by setting *\a{ok} to \c true.
1398
1399 The string conversion will always happen in the 'C' locale. For locale
1400 dependent conversion use QLocale::toDouble()
1401
1402 For historic reasons, this function does not handle
1403 thousands group separators. If you need to convert such numbers,
1404 use QLocale::toDouble().
1405
1406 \sa QString::toDouble()
1407
1408 \since 6.0
1409*/
1410
1411/*!
1412 \fn float QStringView::toFloat(bool *ok) const
1413
1414 Returns the string view converted to a \c float value.
1415
1416 Returns an infinity if the conversion overflows or 0.0 if the
1417 conversion fails for other reasons (e.g. underflow).
1418
1419 If \a ok is not \nullptr, failure is reported by setting *\a{ok}
1420 to \c false, and success by setting *\a{ok} to \c true.
1421
1422 The string conversion will always happen in the 'C' locale. For locale
1423 dependent conversion use QLocale::toFloat()
1424
1425 \sa QString::toFloat()
1426
1427 \since 6.0
1428*/
1429
1430
1431/*!
1432 \fn template <typename Needle, typename...Flags> auto QStringView::tokenize(Needle &&sep, Flags...flags) const
1433 \fn template <typename Needle, typename...Flags> auto QLatin1StringView::tokenize(Needle &&sep, Flags...flags) const
1434 \fn template <typename Needle, typename...Flags> auto QString::tokenize(Needle &&sep, Flags...flags) const &
1435 \fn template <typename Needle, typename...Flags> auto QString::tokenize(Needle &&sep, Flags...flags) const &&
1436 \fn template <typename Needle, typename...Flags> auto QString::tokenize(Needle &&sep, Flags...flags) &&
1437
1438 Splits the string into substring views wherever \a sep occurs, and
1439 returns a lazy sequence of those strings.
1440
1441 Equivalent to
1442
1443 \code
1444 return QStringTokenizer{std::forward<Needle>(sep), flags...};
1445 \endcode
1446
1447 except it works without C++17 Class Template Argument Deduction (CTAD)
1448 enabled in the compiler.
1449
1450 See QStringTokenizer for how \a sep and \a flags interact to form
1451 the result.
1452
1453 \note While this function returns QStringTokenizer, you should never,
1454 ever, name its template arguments explicitly. If you can use C++17 Class
1455 Template Argument Deduction (CTAD), you may write
1456 \code
1457 QStringTokenizer result = sv.tokenize(sep);
1458 \endcode
1459 (without template arguments). If you can't use C++17 CTAD, you must store
1460 the return value only in \c{auto} variables:
1461 \code
1462 auto result = sv.tokenize(sep);
1463 \endcode
1464 This is because the template arguments of QStringTokenizer have a very
1465 subtle dependency on the specific tokenize() overload from which they are
1466 returned, and they don't usually correspond to the type used for the separator.
1467
1468 \since 6.0
1469 \sa QStringTokenizer, qTokenize()
1470*/
1471
1472/*!
1473 \fn QStringView::operator std::u16string_view() const
1474 \since 6.7
1475
1476 Converts this QStringView object to a \c{std::u16string_view} object.
1477 The returned view will have the same data pointer and length of
1478 this view.
1479*/
1480
1481/*!
1482 \fn QStringView::maxSize()
1483 \since 6.8
1484
1485 It returns the maximum number of elements that the view can
1486 theoretically represent. In practice, the number can be much smaller,
1487 limited by the amount of memory available to the system.
1488*/
1489
1490/*!
1491 \fn QStringView::max_size() const
1492 \since 6.8
1493
1494 This function is provided for STL compatibility.
1495
1496 Returns maxSize().
1497*/
1498
1499/*!
1500 \fn Qt::Literals::StringLiterals::operator""_sv(const char16_t *str, size_t size)
1501
1502 \relates QStringView
1503 \since 6.10
1504
1505 Literal operator that creates a QStringView out of the first
1506 \a size characters in the char16_t string literal \a str.
1507
1508 There is rarely need to explicitly construct a QStringView from a
1509 char16_t string literal, as QStringView is implicitly constructible
1510 from one:
1511
1512 \code
1513 QStringView greeting = u"hello"; // OK even without _sv
1514
1515 void print(QStringView s);
1516 print(u"world"); // OK even without _sv
1517 \endcode
1518
1519 To use this operator, you need to be using the corresponding
1520 namespace(s):
1521
1522 \code
1523 using namespace Qt::Literals::StringLiterals;
1524 auto sv = u"peace"_sv;
1525 \endcode
1526
1527 Note that the returned QStringView will span over any NUL embedded
1528 in the string literal. This is different from passing the string
1529 literal to QStringView's constructor (explicitly or implicitly):
1530
1531 \code
1532 QStringView sv1 = u"abc\0def"; // sv1 == "abc"
1533 QStringView sv2 = u"abc\0def"_sv; // sv2 == "abc\0def"
1534 \endcode
1535
1536 \sa Qt::Literals::StringLiterals
1537*/
1538
1539QT_END_NAMESPACE
Combined button and popup list for selecting options.