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
qspan.h
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSPAN_H
5#define QSPAN_H
6
7#include <QtCore/qcompilerdetection.h>
8#include <QtCore/qtypes.h>
9#include <QtCore/qcontainerfwd.h>
10
11#include <array>
12#include <cstddef>
13#include <cassert>
14#include <initializer_list>
15#include <QtCore/q20iterator.h>
16#include <QtCore/q20memory.h>
17#ifdef __cpp_lib_span
18#include <span>
19#endif
20#include <QtCore/q20type_traits.h>
21
22QT_BEGIN_NAMESPACE
23
24// like std::dynamic_extent
25namespace q20 {
26 inline constexpr auto dynamic_extent = std::size_t(-1);
27} // namespace q20
28
29QT_BEGIN_INCLUDE_NAMESPACE
30#ifdef __cpp_lib_span
31#ifdef __cpp_lib_concepts
32namespace std::ranges {
33// Officially, these are defined in <ranges>, but that is a heavy-hitter header.
34// OTOH, <span> must specialize these variable templates, too, so we assume that
35// <span> includes some meaningful subset of <ranges> and just go ahead and use them:
36template <typename T, std::size_t E>
37constexpr inline bool enable_borrowed_range<QT_PREPEND_NAMESPACE(QSpan)<T, E>> = true;
38template <typename T, std::size_t E>
39constexpr inline bool enable_view<QT_PREPEND_NAMESPACE(QSpan)<T, E>> = true;
40} // namespace std::ranges
41#endif // __cpp_lib_concepts
42#endif // __cpp_lib_span
43QT_END_INCLUDE_NAMESPACE
44
45namespace QSpanPrivate {
46
47template <typename From, typename To>
48std::conditional_t<std::is_const_v<From>, const To &, To &> // like [forward]/6.1 COPY_CONST
49const_propagated(To &in) { return in; }
50
51template <typename T, std::size_t E> class QSpanBase;
52
53template <typename T>
55template <typename T, std::size_t E>
57template <typename T, std::size_t E>
58struct is_qspan_helper<QSpanBase<T, E>> : std::true_type {};
59template <typename T>
61
62template <typename T>
64#ifdef __cpp_lib_span
65template <typename T, std::size_t E>
66struct is_std_span_helper<std::span<T, E>> : std::true_type {};
67#endif // __cpp_lib_span
68template <typename T>
70
71template <typename T>
73template <typename T, std::size_t N>
74struct is_std_array_helper<std::array<T, N>> : std::true_type {};
75template <typename T>
77
78template <typename From, typename To>
79using is_qualification_conversion =
80 std::is_convertible<From(*)[], To(*)[]>; // https://eel.is/c++draft/span.cons#note-1
81template <typename From, typename To>
83
84namespace AdlTester {
85#define MAKE_ADL_TEST(what)
86 using std:: what; /* bring into scope */
87 template <typename T> using what ## _result = decltype( what (std::declval<T&&>()));
88 /* end */
89MAKE_ADL_TEST(begin)
90MAKE_ADL_TEST(data)
91MAKE_ADL_TEST(size)
92#undef MAKE_ADL_TEST
93}
94
95// Replacements for std::ranges::XXX(), but only bringing in ADL XXX()s,
96// not doing the extra work C++20 requires
97template <typename Range>
98AdlTester::begin_result<Range> adl_begin(Range &&r) { using std::begin; return begin(r); }
99template <typename Range>
100AdlTester::data_result<Range> adl_data(Range &&r) { using std::data; return data(r); }
101template <typename Range>
102AdlTester::size_result<Range> adl_size(Range &&r) { using std::size; return size(r); }
103
104// Replacement for std::ranges::iterator_t (which depends on C++20 std::ranges::begin)
105// This one uses adl_begin() instead.
106template <typename Range>
107using iterator_t = decltype(QSpanPrivate::adl_begin(std::declval<Range&>()));
108template <typename Range>
110
111template <typename T>
113protected:
114 template <typename Iterator>
116 // ### C++20: extend to contiguous_iteratorss
120 >,
123 T
124 >
125 >;
126 template <typename Iterator, typename End>
128 // ### C++20: extend to contiguous_iterators and real sentinels
131 >;
132 template <typename Range, typename = void> // wrap use of SFINAE-unfriendly iterator_t:
134 template <typename Range>
137 template <typename Range>
139 // ### C++20: extend to contiguous_iterators
145 >;
146
147 // constraints
148 template <typename Iterator>
151 , bool>;
152 template <typename Iterator, typename End>
155 , bool>;
156 template <typename Range>
158}; // class QSpanCommon
159
160template <typename T, std::size_t E>
161class QSpanBase : protected QSpanCommon<T>
162{
163 static_assert(E < size_t{(std::numeric_limits<qsizetype>::max)()},
164 "QSpan only supports extents that fit into the signed size type (qsizetype).");
165
166 template <typename S, std::size_t N>
167 using if_compatible_array = std::enable_if_t<
168 N == E && is_qualification_conversion_v<S, T>
169 , bool>;
170
171 template <typename S>
172 using if_qualification_conversion = std::enable_if_t<
173 is_qualification_conversion_v<S, T>
174 , bool>;
175protected:
176 using Base = QSpanCommon<T>;
177
178 // data members:
180 static constexpr qsizetype m_size = qsizetype(E);
181
182 // types and constants:
183 // (in QSpan only)
184
185 // constructors (need to be public d/t the way ctor inheriting works):
186public:
187 template <std::size_t E2 = E, std::enable_if_t<E2 == 0, bool> = true>
188 Q_IMPLICIT constexpr QSpanBase() noexcept : m_data{nullptr} {}
189
190 template <typename It, typename Base::template if_compatible_iterator<It> = true>
191 explicit constexpr QSpanBase(It first, qsizetype count)
193 {
194 Q_ASSERT(count == m_size);
195 }
196
197 template <typename It, typename End, typename Base::template if_compatible_iterator_and_sentinel<It, End> = true>
198 explicit constexpr QSpanBase(It first, End last)
199 : QSpanBase(first, last - first) {}
200
201 template <size_t N, std::enable_if_t<N == E, bool> = true>
202 Q_IMPLICIT constexpr QSpanBase(q20::type_identity_t<T> (&arr)[N]) noexcept
203 : QSpanBase(arr, N) {}
204
205 template <typename S, size_t N, if_compatible_array<S, N> = true>
206 Q_IMPLICIT constexpr QSpanBase(std::array<S, N> &arr) noexcept
207 : QSpanBase(arr.data(), N) {}
208
209 template <typename S, size_t N, if_compatible_array<S, N> = true>
210 Q_IMPLICIT constexpr QSpanBase(const std::array<S, N> &arr) noexcept
211 : QSpanBase(arr.data(), N) {}
212
213 template <typename Range, typename Base::template if_compatible_range<Range> = true>
214 Q_IMPLICIT constexpr QSpanBase(Range &&r)
215 : QSpanBase(QSpanPrivate::adl_data(QSpanPrivate::const_propagated<T>(r)), // no forward<>() here (std doesn't have it, either)
216 qsizetype(QSpanPrivate::adl_size(r))) // ditto, no forward<>()
217 {}
218
219 template <typename S, if_qualification_conversion<S> = true>
220 Q_IMPLICIT constexpr QSpanBase(QSpan<S, E> other) noexcept
221 : QSpanBase(other.data(), other.size())
222 {}
223
224 template <typename S, if_qualification_conversion<S> = true>
225 Q_IMPLICIT constexpr QSpanBase(QSpan<S> other)
226 : QSpanBase(other.data(), other.size())
227 {}
228
229 template <typename U = T, std::enable_if_t<std::is_const_v<U>, bool> = true>
230 Q_IMPLICIT constexpr QSpanBase(std::initializer_list<std::remove_cv_t<T>> il)
231 : QSpanBase(il.begin(), il.size())
232 {}
233
234#ifdef __cpp_lib_span
235 template <typename S, if_qualification_conversion<S> = true>
236 Q_IMPLICIT constexpr QSpanBase(std::span<S, E> other) noexcept
237 : QSpanBase(other.data(), other.size())
238 {}
239
240 template <typename S, if_qualification_conversion<S> = true>
241 Q_IMPLICIT constexpr QSpanBase(std::span<S> other)
242 : QSpanBase(other.data(), other.size())
243 {}
244#endif // __cpp_lib_span
245}; // class QSpanBase (fixed extent)
246
247template <typename T>
248class QSpanBase<T, q20::dynamic_extent> : protected QSpanCommon<T>
249{
250 template <typename S>
251 using if_qualification_conversion = std::enable_if_t<
252 is_qualification_conversion_v<S, T>
253 , bool>;
254protected:
255 using Base = QSpanCommon<T>;
256
257 // data members:
260
261 // constructors (need to be public d/t the way ctor inheriting works):
262public:
263 Q_IMPLICIT constexpr QSpanBase() noexcept : m_data{nullptr}, m_size{0} {}
264
265 template <typename It, typename Base::template if_compatible_iterator<It> = true>
266 Q_IMPLICIT constexpr QSpanBase(It first, qsizetype count)
267 : m_data{q20::to_address(first)}, m_size{count} {}
268
269 template <typename It, typename End, typename Base::template if_compatible_iterator_and_sentinel<It, End> = true>
270 Q_IMPLICIT constexpr QSpanBase(It first, End last)
271 : QSpanBase(first, last - first) {}
272
273 template <size_t N>
274 Q_IMPLICIT constexpr QSpanBase(q20::type_identity_t<T> (&arr)[N]) noexcept
275 : QSpanBase(arr, N) {}
276
277 template <typename S, size_t N, if_qualification_conversion<S> = true>
278 Q_IMPLICIT constexpr QSpanBase(std::array<S, N> &arr) noexcept
279 : QSpanBase(arr.data(), N) {}
280
281 template <typename S, size_t N, if_qualification_conversion<S> = true>
282 Q_IMPLICIT constexpr QSpanBase(const std::array<S, N> &arr) noexcept
283 : QSpanBase(arr.data(), N) {}
284
285 template <typename Range, typename Base::template if_compatible_range<Range> = true>
286 Q_IMPLICIT constexpr QSpanBase(Range &&r)
287 : QSpanBase(QSpanPrivate::adl_data(QSpanPrivate::const_propagated<T>(r)), // no forward<>() here (std doesn't have it, either)
288 qsizetype(QSpanPrivate::adl_size(r))) // ditto, no forward<>()
289 {}
290
291 template <typename S, size_t N, if_qualification_conversion<S> = true>
292 Q_IMPLICIT constexpr QSpanBase(QSpan<S, N> other) noexcept
293 : QSpanBase(other.data(), other.size())
294 {}
295
296 template <typename U = T, std::enable_if_t<std::is_const_v<U>, bool> = true>
297 Q_IMPLICIT constexpr QSpanBase(std::initializer_list<std::remove_cv_t<T>> il) noexcept
298 : QSpanBase(il.begin(), il.size())
299 {}
300
301#ifdef __cpp_lib_span
302 template <typename S, size_t N, if_qualification_conversion<S> = true>
303 Q_IMPLICIT constexpr QSpanBase(std::span<S, N> other) noexcept
304 : QSpanBase(other.data(), other.size())
305 {}
306#endif // __cpp_lib_span
307}; // class QSpanBase (dynamic extent)
308
309} // namespace QSpanPrivate
310
311template <typename T, std::size_t E>
312class QSpan
313#ifndef Q_QDOC
314 : private QSpanPrivate::QSpanBase<T, E>
315#endif
316{
317 using Base = QSpanPrivate::QSpanBase<T, E>;
318 Q_ALWAYS_INLINE constexpr void verify([[maybe_unused]] qsizetype pos = 0,
319 [[maybe_unused]] qsizetype n = 1) const
320 {
321 Q_ASSERT(pos >= 0);
322 Q_ASSERT(pos <= size());
323 Q_ASSERT(n >= 0);
324 Q_ASSERT(n <= size() - pos);
325 }
326
327 template <std::size_t N>
328 static constexpr bool subspan_always_succeeds_v = N <= E && E != q20::dynamic_extent;
329public:
330 // constants and types
332#ifdef QT_COMPILER_HAS_LWG3346
334 using element_type = T;
335#endif
336 using size_type = qsizetype; // difference to std::span
337 using difference_type = qptrdiff; // difference to std::span
338 using pointer = T*;
339 using const_pointer = const T*;
340 using reference = T&;
341 using const_reference = const T&;
342 using iterator = pointer; // implementation-defined choice
343 using const_iterator = const_pointer; // implementation-defined choice
344 using reverse_iterator = std::reverse_iterator<iterator>;
345 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
346 static constexpr std::size_t extent = E;
347
348 // [span.cons], constructors, copy, and assignment
349 using Base::Base;
350#ifdef Q_QDOC
351 template <typename It> using if_compatible_iterator = bool;
352 template <typename S> using if_qualification_conversion = bool;
353 template <typename Range> using if_compatible_range = bool;
354 template <typename It, if_compatible_iterator<It> = true> constexpr QSpan(It first, qsizetype count);
355 template <typename It, if_compatible_iterator<It> = true> constexpr QSpan(It first, It last);
356 template <size_t N> constexpr QSpan(q20::type_identity_t<T> (&arr)[N]) noexcept;
357 template <typename S, size_t N, if_qualification_conversion<S> = true> constexpr QSpan(std::array<S, N> &arr) noexcept;
358 template <typename S, size_t N, if_qualification_conversion<S> = true> constexpr QSpan(const std::array<S, N> &arr) noexcept;
359 template <typename Range, if_compatible_range<Range> = true> constexpr QSpan(Range &&r);
360 template <typename S, size_t N, if_qualification_conversion<S> = true> constexpr QSpan(QSpan<S, N> other) noexcept;
361 template <typename S, size_t N, if_qualification_conversion<S> = true> constexpr QSpan(std::span<S, N> other) noexcept;
363#endif // Q_QDOC
364
365 // [span.obs]
366 [[nodiscard]] constexpr size_type size() const noexcept { return this->m_size; }
367 [[nodiscard]] constexpr size_type size_bytes() const noexcept { return size() * sizeof(T); }
368 [[nodiscard]] constexpr bool empty() const noexcept { return size() == 0; }
369
370 // [span.elem]
371 [[nodiscard]] constexpr reference operator[](size_type idx) const
372 { verify(idx); return data()[idx]; }
373 [[nodiscard]] constexpr reference front() const { verify(); return *data(); }
374 [[nodiscard]] constexpr reference back() const { verify(); return data()[size() - 1]; }
375 [[nodiscard]] constexpr pointer data() const noexcept { return this->m_data; }
376
377 // [span.iterators]
378 [[nodiscard]] constexpr iterator begin() const noexcept { return data(); }
379 [[nodiscard]] constexpr iterator end() const noexcept { return data() + size(); }
380 [[nodiscard]] constexpr const_iterator cbegin() const noexcept { return begin(); }
381 [[nodiscard]] constexpr const_iterator cend() const noexcept { return end(); }
382 [[nodiscard]] constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator{end()}; }
383 [[nodiscard]] constexpr reverse_iterator rend() const noexcept { return reverse_iterator{begin()}; }
384 [[nodiscard]] constexpr const_reverse_iterator crbegin() const noexcept { return rbegin(); }
385 [[nodiscard]] constexpr const_reverse_iterator crend() const noexcept { return rend(); }
386
387 // [span.sub]
388 template <std::size_t Count>
389 [[nodiscard]] constexpr QSpan<T, Count> first() const
391 {
392 static_assert(Count <= E,
393 "Count cannot be larger than the span's extent.");
394 verify(0, Count);
395 return QSpan<T, Count>{data(), Count};
396 }
397
398 template <std::size_t Count>
399 [[nodiscard]] constexpr QSpan<T, Count> last() const
401 {
402 static_assert(Count <= E,
403 "Count cannot be larger than the span's extent.");
404 verify(0, Count);
405 return QSpan<T, Count>{data() + (size() - Count), Count};
406 }
407
408 template <std::size_t Offset>
409 [[nodiscard]] constexpr auto subspan() const
411 {
412 static_assert(Offset <= E,
413 "Offset cannot be larger than the span's extent.");
414 verify(Offset, 0);
415 if constexpr (E == q20::dynamic_extent)
416 return QSpan<T>{data() + Offset, qsizetype(size() - Offset)};
417 else
418 return QSpan<T, E - Offset>{data() + Offset, qsizetype(E - Offset)};
419 }
420
421 template <std::size_t Offset, std::size_t Count>
422 [[nodiscard]] constexpr auto subspan() const
424 { return subspan<Offset>().template first<Count>(); }
425
426 [[nodiscard]] constexpr QSpan<T> first(size_type n) const { verify(0, n); return {data(), n}; }
427 [[nodiscard]] constexpr QSpan<T> last(size_type n) const { verify(0, n); return {data() + (size() - n), n}; }
428 [[nodiscard]] constexpr QSpan<T> subspan(size_type pos) const { verify(pos, 0); return {data() + pos, size() - pos}; }
429 [[nodiscard]] constexpr QSpan<T> subspan(size_type pos, size_type n) const { return subspan(pos).first(n); }
430
431 // Qt-compatibility API:
432 [[nodiscard]] constexpr bool isEmpty() const noexcept { return empty(); }
433 // nullary first()/last() clash with first<>() and last<>(), so they're not provided for QSpan
434 [[nodiscard]] constexpr QSpan<T> sliced(size_type pos) const { return subspan(pos); }
435 [[nodiscard]] constexpr QSpan<T> sliced(size_type pos, size_type n) const { return subspan(pos, n); }
436 [[nodiscard]] constexpr QSpan<T> chopped(size_type n) const { verify(0, n); return first(size() - n); }
437
438#ifdef __cpp_concepts
439# define QT_ONLY_IF_DYNAMIC_SPAN(DECL)
440 DECL requires(E == q20::dynamic_extent)
441#else
442# define QT_ONLY_IF_DYNAMIC_SPAN(DECL)
443 template <size_t M = E, typename = std::enable_if_t<M == q20::dynamic_extent>> DECL
444#endif
446 constexpr void slice(size_type pos)
447 )
448 { *this = sliced(pos); }
450 constexpr void slice(size_type pos, size_type n)
451 )
452 { *this = sliced(pos, n); }
454 constexpr void chop(size_type n)
455 )
456 { *this = chopped(n); }
457#undef QT_ONLY_IF_DYNAMIC_SPAN
458
459private:
460 // [span.objectrep]
461 [[nodiscard]] friend
462 QSpan<const std::byte, E == q20::dynamic_extent ? q20::dynamic_extent : E * sizeof(T)>
463 as_bytes(QSpan s) noexcept
464 {
465 using R = QSpan<const std::byte, E == q20::dynamic_extent ? q20::dynamic_extent : E * sizeof(T)>;
466 return R{reinterpret_cast<const std::byte *>(s.data()), s.size_bytes()};
467 }
468
469 template <typename U>
470 using if_mutable = std::enable_if_t<!std::is_const_v<U>, bool>;
471
472#ifndef Q_QDOC
473 template <typename T2 = T, if_mutable<T2> = true>
474#endif
475 [[nodiscard]] friend
476 QSpan<std::byte, E == q20::dynamic_extent ? q20::dynamic_extent : E * sizeof(T)>
478 {
479 using R = QSpan<std::byte, E == q20::dynamic_extent ? q20::dynamic_extent : E * sizeof(T)>;
480 return R{reinterpret_cast<std::byte *>(s.data()), s.size_bytes()};
481 }
482}; // class QSpan
483
484// [span.deduct]
485template <class It, class EndOrSize>
486QSpan(It, EndOrSize) -> QSpan<std::remove_reference_t<q20::iter_reference_t<It>>>;
487template <class T, std::size_t N>
488QSpan(T (&)[N]) -> QSpan<T, N>;
489template <class T, std::size_t N>
490QSpan(std::array<T, N> &) -> QSpan<T, N>;
491template <class T, std::size_t N>
492QSpan(const std::array<T, N> &) -> QSpan<const T, N>;
493template <class R>
494QSpan(R&&) -> QSpan<std::remove_reference_t<QSpanPrivate::range_reference_t<R>>>;
495
496QT_END_NAMESPACE
497
498#endif // QSPAN_H
QString convertToQString(QAnyStringView string)
Definition qstring.cpp:5633
Definition qlist.h:80
constexpr QSpanBase(It first, qsizetype count)
Definition qspan.h:191
static constexpr qsizetype m_size
Definition qspan.h:180
constexpr QSpanBase(It first, End last)
Definition qspan.h:198
Definition qspan.h:316
constexpr bool empty() const noexcept
Definition qspan.h:368
constexpr pointer data() const noexcept
Definition qspan.h:375
static constexpr std::size_t extent
Definition qspan.h:346
constexpr reverse_iterator rbegin() const noexcept
Definition qspan.h:382
constexpr reference front() const
Definition qspan.h:373
constexpr QSpan< T > sliced(size_type pos, size_type n) const
Definition qspan.h:435
constexpr QSpan< T > sliced(size_type pos) const
Definition qspan.h:434
constexpr size_type size() const noexcept
Definition qspan.h:366
constexpr iterator end() const noexcept
Definition qspan.h:379
constexpr const_iterator cbegin() const noexcept
Definition qspan.h:380
constexpr QSpan< T > subspan(size_type pos, size_type n) const
Definition qspan.h:429
constexpr const_iterator cend() const noexcept
Definition qspan.h:381
constexpr bool isEmpty() const noexcept
Definition qspan.h:432
constexpr reverse_iterator rend() const noexcept
Definition qspan.h:383
constexpr QSpan< T, Count > last() const noexcept(subspan_always_succeeds_v< Count >)
Definition qspan.h:399
constexpr QSpan< T > last(size_type n) const
Definition qspan.h:427
constexpr const_reverse_iterator crend() const noexcept
Definition qspan.h:385
friend QSpan< const std::byte, E==q20::dynamic_extent ? q20::dynamic_extent :E *sizeof(T)> as_bytes(QSpan s) noexcept
Definition qspan.h:463
constexpr size_type size_bytes() const noexcept
Definition qspan.h:367
constexpr const_reverse_iterator crbegin() const noexcept
Definition qspan.h:384
constexpr reference operator[](size_type idx) const
Definition qspan.h:371
constexpr QSpan< T > first(size_type n) const
Definition qspan.h:426
constexpr reference back() const
Definition qspan.h:374
constexpr QSpan< T > subspan(size_type pos) const
Definition qspan.h:428
constexpr auto subspan() const noexcept(subspan_always_succeeds_v< Offset+Count >)
Definition qspan.h:422
constexpr QSpan< T, Count > first() const noexcept(subspan_always_succeeds_v< Count >)
Definition qspan.h:389
constexpr QSpan< T > chopped(size_type n) const
Definition qspan.h:436
friend QSpan< std::byte, E==q20::dynamic_extent ? q20::dynamic_extent :E *sizeof(T)> as_writable_bytes(QSpan s) noexcept
Definition qspan.h:477
constexpr iterator begin() const noexcept
Definition qspan.h:378
constexpr auto subspan() const noexcept(subspan_always_succeeds_v< Offset >)
Definition qspan.h:409
char32_t next(char32_t invalidAs=QChar::ReplacementCharacter)
bool hasNext() const
\inmodule QtCore
QList< uint > convertToUcs4(QStringView string)
Definition qstring.cpp:5889
QByteArray convertToUtf8(QStringView string)
Definition qstring.cpp:5834
QByteArray convertToLocal8Bit(QStringView string)
Definition qstring.cpp:5791
QByteArray convertToLatin1(QStringView string)
Definition qstring.cpp:5650
AdlTester::size_result< Range > adl_size(Range &&r)
Definition qspan.h:102
std::conditional_t< std::is_const_v< From >, const To &, To & > const_propagated(To &in)
Definition qspan.h:49
AdlTester::data_result< Range > adl_data(Range &&r)
Definition qspan.h:100
AdlTester::begin_result< Range > adl_begin(Range &&r)
Definition qspan.h:98
constexpr bool is_qualification_conversion_v
Definition qspan.h:82
Combined button and popup list for selecting options.
static QString convertCase(T &str, QUnicodeTables::Case which)
Definition qstring.cpp:7242
static constexpr NormalizationCorrection uc_normalization_corrections[]
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Definition qstring.cpp:9760
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Definition qstring.cpp:9800
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isLower(QStringView s) noexcept
Definition qstring.cpp:5570
const QString & asString(const QString &s)
Definition qstring.h:1661
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isValidUtf16(QStringView s) noexcept
Definition qstring.cpp:905
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QStringView lhs, QStringView rhs) noexcept
Definition qstring.cpp:1386
qsizetype findString(QStringView str, qsizetype from, QChar needle, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isRightToLeft(QStringView string) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1StringView s) noexcept
Definition qstring.cpp:850
constexpr bool isLatin1(QLatin1StringView s) noexcept
Definition qstring.h:78
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION const char16_t * qustrcasechr(QStringView str, char16_t ch) noexcept
Definition qstring.cpp:775
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isUpper(QStringView s) noexcept
Definition qstring.cpp:5575
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION const char16_t * qustrchr(QStringView str, char16_t ch) noexcept
Definition qstring.cpp:687
constexpr auto dynamic_extent
Definition qspan.h:26
void qt_to_latin1_unchecked(uchar *dst, const char16_t *uc, qsizetype len)
Definition qstring.cpp:1188
static char16_t foldCase(char16_t ch) noexcept
Definition qchar.cpp:1696
#define __has_feature(x)
uint QT_FASTCALL fetch1Pixel< QPixelLayout::BPP1LSB >(const uchar *src, int index)
bool comparesEqual(const QFileInfo &lhs, const QFileInfo &rhs)
#define MAKE_ADL_TEST(what)
Definition qspan.h:85
QSpan(const std::array< T, N > &) -> QSpan< const T, N >
#define QT_ONLY_IF_DYNAMIC_SPAN(DECL)
Definition qspan.h:442
QSpan(T(&)[N]) -> QSpan< T, N >
QSpan(std::array< T, N > &) -> QSpan< T, N >
static bool isAscii_helper(const char16_t *&ptr, const char16_t *end)
Definition qstring.cpp:858
static Int toIntegral(QStringView string, bool *ok, int base)
Definition qstring.cpp:7725
void qt_to_latin1(uchar *dst, const char16_t *src, qsizetype length)
Definition qstring.cpp:1183
Qt::strong_ordering compareThreeWay(const QByteArray &lhs, const QChar &rhs) noexcept
Definition qstring.cpp:6807
static void append_utf8(QString &qs, const char *cs, qsizetype len)
Definition qstring.cpp:7359
#define ATTRIBUTE_NO_SANITIZE
Definition qstring.cpp:366
bool qt_is_ascii(const char *&ptr, const char *end) noexcept
Definition qstring.cpp:786
static void replace_in_place(QString &str, QSpan< size_t > indices, qsizetype blen, QStringView after)
Definition qstring.cpp:3707
static bool checkCase(QStringView s, QUnicodeTables::Case c) noexcept
Definition qstring.cpp:5559
static void replace_helper(QString &str, QSpan< size_t > indices, qsizetype blen, QStringView after)
Definition qstring.cpp:3751
Q_CORE_EXPORT void qt_from_latin1(char16_t *dst, const char *str, size_t size) noexcept
Definition qstring.cpp:920
static int ucstrcmp(const char16_t *a, size_t alen, const Char2 *b, size_t blen)
Definition qstring.cpp:1359
bool comparesEqual(const QByteArray &lhs, char16_t rhs) noexcept
Definition qstring.cpp:6813
Q_DECLARE_TYPEINFO(Part, Q_PRIMITIVE_TYPE)
static void removeStringImpl(QString &s, const T &needle, Qt::CaseSensitivity cs)
Definition qstring.cpp:3487
static bool needsReallocate(const QString &str, qsizetype newSize)
Definition qstring.cpp:2623
static int qArgDigitValue(QChar ch) noexcept
Definition qstring.cpp:1626
bool comparesEqual(const QByteArray &lhs, const QChar &rhs) noexcept
Definition qstring.cpp:6802
#define REHASH(a)
Definition qstring.cpp:65
static void replace_with_copy(QString &str, QSpan< size_t > indices, qsizetype blen, QStringView after)
Definition qstring.cpp:3684
bool comparesEqual(const QByteArrayView &lhs, char16_t rhs) noexcept
Definition qstring.cpp:6791
static int ucstrncmp(const char16_t *a, const char16_t *b, size_t l)
Definition qstring.cpp:1277
static Q_NEVER_INLINE int ucstricmp(qsizetype alen, const char16_t *a, qsizetype blen, const char *b)
Definition qstring.cpp:1221
static QByteArray qt_convert_to_latin1(QStringView string)
Definition qstring.cpp:5656
static bool ucstreq(const char16_t *a, size_t alen, const Char2 *b)
Definition qstring.cpp:1352
static QList< uint > qt_convert_to_ucs4(QStringView string)
Definition qstring.cpp:5861
qsizetype qFindStringBoyerMoore(QStringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs)
static QByteArray qt_convert_to_local_8bit(QStringView string)
Definition qstring.cpp:5768
static LengthMod parse_length_modifier(const char *&c) noexcept
Definition qstring.cpp:7415
static ArgEscapeData findArgEscapes(QStringView s)
Definition qstring.cpp:8607
static QByteArray qt_convert_to_utf8(QStringView str)
Definition qstring.cpp:5814
static void qt_to_latin1_internal(uchar *dst, const char16_t *src, qsizetype length)
Definition qstring.cpp:1004
LengthMod
Definition qstring.cpp:7404
@ lm_z
Definition qstring.cpp:7404
@ lm_none
Definition qstring.cpp:7404
@ lm_t
Definition qstring.cpp:7404
@ lm_l
Definition qstring.cpp:7404
@ lm_ll
Definition qstring.cpp:7404
@ lm_hh
Definition qstring.cpp:7404
@ lm_L
Definition qstring.cpp:7404
@ lm_h
Definition qstring.cpp:7404
@ lm_j
Definition qstring.cpp:7404
static void insert_helper(QString &str, qsizetype i, const T &toInsert)
Definition qstring.cpp:2962
static int latin1nicmp(const char *lhsChar, qsizetype lSize, const char *rhsChar, qsizetype rSize)
Definition qstring.cpp:1368
Qt::strong_ordering compareThreeWay(const QByteArrayView &lhs, const QChar &rhs) noexcept
Definition qstring.cpp:6785
static char16_t to_unicode(const char c)
Definition qstring.cpp:9002
Qt::strong_ordering compareThreeWay(const QByteArray &lhs, char16_t rhs) noexcept
Definition qstring.cpp:6818
static QString replaceArgEscapes(QStringView s, const ArgEscapeData &d, qsizetype field_width, QStringView arg, QStringView larg, QChar fillChar)
Definition qstring.cpp:8683
static QVarLengthArray< char16_t > qt_from_latin1_to_qvla(QLatin1StringView str)
Definition qstring.cpp:995
static Q_NEVER_INLINE int ucstricmp8(const char *utf8, const char *utf8end, const QChar *utf16, const QChar *utf16end)
Definition qstring.cpp:1239
void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar::UnicodeVersion version, qsizetype from)
Definition qstring.cpp:8497
static uint parse_flag_characters(const char *&c) noexcept
Definition qstring.cpp:7367
static Q_NEVER_INLINE int ucstricmp(qsizetype alen, const char16_t *a, qsizetype blen, const char16_t *b)
Definition qstring.cpp:1194
static char16_t to_unicode(const QChar c)
Definition qstring.cpp:9001
QDataStream & operator>>(QDataStream &in, QString &str)
Definition qstring.cpp:9534
static int getEscape(const Char *uc, qsizetype *pos, qsizetype len)
Definition qstring.cpp:9005
static int ucstrncmp(const char16_t *a, const char *b, size_t l)
Definition qstring.cpp:1330
static bool can_consume(const char *&c, char ch) noexcept
Definition qstring.cpp:7406
static int parse_field_width(const char *&c, qsizetype size)
Definition qstring.cpp:7387
Qt::strong_ordering compareThreeWay(const QByteArrayView &lhs, char16_t rhs) noexcept
Definition qstring.cpp:6796
#define qUtf16Printable(string)
Definition qstring.h:1678
qsizetype occurrences
Definition qstring.cpp:8601
qsizetype escape_len
Definition qstring.cpp:8604
qsizetype locale_occurrences
Definition qstring.cpp:8602
\inmodule QtCore \reentrant
Definition qchar.h:17
constexpr char16_t unicode() const noexcept
Converts a Latin-1 character to an 16-bit-encoded Unicode representation of the character.
Definition qchar.h:21
constexpr QLatin1Char(char c) noexcept
Constructs a Latin-1 character for c.
Definition qchar.h:19
@ BlankBeforePositive
Definition qlocale_p.h:264
@ AddTrailingZeroes
Definition qlocale_p.h:261
static int difference(char lhs, char rhs)