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