7#if QT_CONFIG(regularexpression)
11#include <private/qstringconverter_p.h>
12#include <private/qtools_p.h>
14#include "private/qsimd_p.h"
29#include <private/qcore_mac_p.h>
32#include <private/qfunctions_p.h>
60#define LLONG_MAX qint64_C(9223372036854775807)
63#define LLONG_MIN (-LLONG_MAX - qint64_C(1))
66#define ULLONG_MAX quint64_C(18446744073709551615)
70 if (sl_minus_1 < sizeof(std::size_t) * CHAR_BIT) \
71 hashHaystack -= std::size_t(a) << sl_minus_1; \
79const char16_t QString::_empty = 0;
85enum StringComparisonMode {
86 CompareStringsForEquality,
87 CompareStringsForOrdering
90template <
typename Po
inter>
91char32_t foldCaseHelper(Pointer
ch, Pointer
start) =
delete;
96 return foldCase(
reinterpret_cast<const char16_t*
>(
ch),
97 reinterpret_cast<const char16_t*
>(
start));
101char32_t foldCaseHelper<const char*>(
const char*
ch,
const char*)
107char16_t valueTypeToUtf16(T
t) =
delete;
110char16_t valueTypeToUtf16<QChar>(
QChar t)
116char16_t valueTypeToUtf16<char>(
char t)
118 return char16_t{
uchar(
t)};
122static inline bool foldAndCompare(
const T
a,
const T
b)
143 char16_t c =
ch.unicode();
144 const char16_t *
n =
s + from;
152 auto it = std::find_if(
n,
e, [
c](
const auto &
ch) {
return foldAndCompare(
ch,
c); });
154 return std::distance(
s,
it);
160template <
typename Haystack>
161static inline qsizetype qLastIndexOf(Haystack haystack,
QChar needle,
164 if (haystack.size() == 0)
167 from += haystack.size();
168 else if (std::size_t(from) > std::size_t(haystack.size()))
169 from = haystack.size() - 1;
171 char16_t c = needle.unicode();
172 const auto b = haystack.data();
176 if (valueTypeToUtf16(*
n) ==
c)
190template<
typename Haystack,
typename Needle>
196 return qLastIndexOf(haystack0, needle0.front(), from, cs);
201 if (from == l && sl == 0)
204 if (std::size_t(from) > std::size_t(l) || delta < 0)
209 auto sv = [sl](
const typename Haystack::value_type *
v) {
return Haystack(
v, sl); };
211 auto haystack = haystack0.data();
212 const auto needle = needle0.data();
213 const auto *
end = haystack;
215 const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
216 const auto *
n = needle + sl_minus_1;
217 const auto *
h = haystack + sl_minus_1;
218 std::size_t hashNeedle = 0, hashHaystack = 0;
221 for (
qsizetype idx = 0; idx < sl; ++idx) {
222 hashNeedle = (hashNeedle << 1) + valueTypeToUtf16(*(
n - idx));
223 hashHaystack = (hashHaystack << 1) + valueTypeToUtf16(*(
h - idx));
225 hashHaystack -= valueTypeToUtf16(*haystack);
227 while (haystack >=
end) {
228 hashHaystack += valueTypeToUtf16(*haystack);
229 if (hashHaystack == hashNeedle
231 return haystack -
end;
233 REHASH(valueTypeToUtf16(haystack[sl]));
236 for (
qsizetype idx = 0; idx < sl; ++idx) {
237 hashNeedle = (hashNeedle << 1) + foldCaseHelper(
n - idx, needle);
238 hashHaystack = (hashHaystack << 1) + foldCaseHelper(
h - idx,
end);
240 hashHaystack -= foldCaseHelper(haystack,
end);
242 while (haystack >=
end) {
243 hashHaystack += foldCaseHelper(haystack,
end);
244 if (hashHaystack == hashNeedle
246 return haystack -
end;
248 REHASH(foldCaseHelper(haystack + sl,
end));
254template <
typename Haystack,
typename Needle>
257 if (haystack.isNull())
258 return needle.isNull();
259 const auto haystackLen = haystack.size();
260 const auto needleLen = needle.size();
261 if (haystackLen == 0)
262 return needleLen == 0;
263 if (needleLen > haystackLen)
269template <
typename Haystack,
typename Needle>
272 if (haystack.isNull())
273 return needle.isNull();
274 const auto haystackLen = haystack.size();
275 const auto needleLen = needle.size();
276 if (haystackLen == 0)
277 return needleLen == 0;
278 if (haystackLen < needleLen)
287 const auto strData =
view.data();
290 if (strData && strSize > 0) {
297 auto dst = std::next(
d.data(),
d.size);
298 if constexpr (std::is_same_v<T, QUtf8StringView>) {
300 }
else if constexpr (std::is_same_v<T, QLatin1StringView>) {
305 "Can only operate on UTF-8 and Latin-1");
308 }
else if (
d.isNull() && !
view.isNull()) {
313template <u
int MaxCount>
struct UnrollTailLoop
315 template <
typename RetType,
typename Functor1,
typename Functor2,
typename Number>
316 static inline RetType
exec(Number
count, RetType returnIfExited, Functor1 loopCheck, Functor2 returnIfFailed, Number
i = 0)
327 return returnIfExited;
329 bool check = loopCheck(
i);
331 return returnIfFailed(
i);
333 return UnrollTailLoop<MaxCount - 1>::exec(
count - 1, returnIfExited, loopCheck, returnIfFailed,
i + 1);
336 template <
typename Functor,
typename Number>
343 exec(
count, 0, [=](Number
i) ->
bool {
code(
i);
return false; }, [](Number) {
return 0; });
346template <>
template <
typename RetType,
typename Functor1,
typename Functor2,
typename Number>
347inline RetType UnrollTailLoop<0>::exec(Number, RetType returnIfExited, Functor1, Functor2, Number)
349 return returnIfExited;
383#if defined(__mips_dsp)
385extern "C" void qt_fromlatin1_mips_asm_unroll4 (
char16_t*,
const char*,
uint);
386extern "C" void qt_fromlatin1_mips_asm_unroll8 (
char16_t*,
const char*,
uint);
387extern "C" void qt_toLatin1_mips_dsp_asm(
uchar *
dst,
const char16_t *
src,
int length);
390#if defined(__SSE2__) && defined(Q_CC_GNU)
393# define ATTRIBUTE_NO_SANITIZE __attribute__((__no_sanitize_address__))
395# define ATTRIBUTE_NO_SANITIZE
400static constexpr bool UseAvx2 = UseSse4_1 &&
406 const __m128i *dataptr =
static_cast<const __m128i *
>(
ptr);
407 if constexpr (UseSse4_1) {
410 __m128i
data = _mm_loadl_epi64(dataptr);
411 return _mm_cvtepu8_epi16(
data);
415 __m128i
data = _mm_loadl_epi64(dataptr);
416 return _mm_unpacklo_epi8(
data, _mm_setzero_si128());
420static qsizetype qustrlen_sse2(
const char16_t *
str)
noexcept
425 const char16_t *
ptr =
str - (misalignment / 2);
429 const __m128i zeroes = _mm_setzero_si128();
430 __m128i
data = _mm_load_si128(
reinterpret_cast<const __m128i *
>(
ptr));
431 __m128i comparison = _mm_cmpeq_epi16(
data, zeroes);
432 uint mask = _mm_movemask_epi8(comparison);
435 mask >>= misalignment;
442 constexpr qsizetype Step =
sizeof(__m128i) /
sizeof(
char16_t);
448 data = _mm_load_si128(
reinterpret_cast<const __m128i *
>(
str +
size));
450 comparison = _mm_cmpeq_epi16(
data, zeroes);
451 mask = _mm_movemask_epi8(comparison);
462static bool simdTestMask(
const char *&
ptr,
const char *
end,
quint32 maskval)
471 if constexpr (UseSse4_1) {
474 auto updatePtrSimd = [&](__m128i
data) {
475 __m128i masked = _mm_and_si128(
mask,
data);
476 __m128i comparison = _mm_cmpeq_epi16(masked, _mm_setzero_si128());
481 if constexpr (UseAvx2) {
483 const __m256i mask256 = _mm256_broadcastd_epi32(_mm_cvtsi32_si128(maskval));
485 __m256i
data = _mm256_loadu_si256(
reinterpret_cast<const __m256i *
>(
ptr));
486 if (!_mm256_testz_si256(mask256,
data)) {
488 __m256i masked256 = _mm256_and_si256(mask256,
data);
489 __m256i comparison256 = _mm256_cmpeq_epi16(masked256, _mm256_setzero_si256());
490 return updatePtr(_mm256_movemask_epi8(comparison256));
495 mask = _mm256_castsi256_si128(mask256);
499 mask = _mm_set1_epi32(maskval);
501 __m128i data1 = _mm_loadu_si128(
reinterpret_cast<const __m128i *
>(
ptr));
502 __m128i data2 = _mm_loadu_si128(
reinterpret_cast<const __m128i *
>(
ptr + 16));
503 if (!_mm_testz_si128(
mask, data1))
504 return updatePtrSimd(data1);
507 if (!_mm_testz_si128(
mask, data2))
508 return updatePtrSimd(data2);
515 __m128i data1 = _mm_loadu_si128(
reinterpret_cast<const __m128i *
>(
ptr));
516 if (!_mm_testz_si128(
mask, data1))
517 return updatePtrSimd(data1);
523 __m128i data1 = _mm_loadl_epi64(
reinterpret_cast<const __m128i *
>(
ptr));
524 if (!_mm_testz_si128(
mask, data1))
525 return updatePtrSimd(data1);
534 const __m128i
mask = _mm_set1_epi32(maskval);
536 __m128i
data = _mm_loadu_si128(
reinterpret_cast<const __m128i *
>(
ptr));
537 __m128i masked = _mm_and_si128(
mask,
data);
538 __m128i comparison = _mm_cmpeq_epi16(masked, _mm_setzero_si128());
547 __m128i
data = _mm_loadl_epi64(
reinterpret_cast<const __m128i *
>(
ptr));
548 __m128i masked = _mm_and_si128(
mask,
data);
549 __m128i comparison = _mm_cmpeq_epi16(masked, _mm_setzero_si128());
559template <StringComparisonMode Mode,
typename Char> [[maybe_unused]]
560static int ucstrncmp_sse2(
const char16_t *
a,
const Char *
b,
size_t l)
562 static_assert(std::is_unsigned_v<Char>);
566 static const auto codeUnitAt = [](
const auto *
n,
qptrdiff idx) ->
int {
567 constexpr int Stride = 2;
574 auto ptr =
reinterpret_cast<const uchar *
>(
n);
575 ptr += idx / (Stride /
sizeof(*n));
576 return *
reinterpret_cast<decltype(
n)
>(
ptr);
579 if (
Mode == CompareStringsForEquality)
585 static const auto load8Chars = [](
const auto *
ptr) {
586 if (
sizeof(*
ptr) == 2)
587 return _mm_loadu_si128(
reinterpret_cast<const __m128i *
>(
ptr));
588 __m128i chunk = _mm_loadl_epi64(
reinterpret_cast<const __m128i *
>(
ptr));
589 return _mm_unpacklo_epi8(chunk, _mm_setzero_si128());
591 static const auto load4Chars = [](
const auto *
ptr) {
592 if (
sizeof(*
ptr) == 2)
593 return _mm_loadl_epi64(
reinterpret_cast<const __m128i *
>(
ptr));
594 __m128i chunk = _mm_cvtsi32_si128(qFromUnaligned<quint32>(
ptr));
595 return _mm_unpacklo_epi8(chunk, _mm_setzero_si128());
600 if constexpr (UseAvx2) {
601 __m256i a_data = _mm256_loadu_si256(
reinterpret_cast<const __m256i *
>(
a +
offset));
603 if (
sizeof(
Char) == 1) {
605 __m128i chunk = _mm_loadu_si128(
reinterpret_cast<const __m128i *
>(
b +
offset));
606 b_data = _mm256_cvtepu8_epi16(chunk);
608 b_data = _mm256_loadu_si256(
reinterpret_cast<const __m256i *
>(
b +
offset));
610 __m256i
result = _mm256_cmpeq_epi16(a_data, b_data);
611 return _mm256_movemask_epi8(
result);
614 __m128i a_data1 = load8Chars(
a +
offset);
615 __m128i a_data2 = load8Chars(
a +
offset + 8);
616 __m128i b_data1, b_data2;
617 if (
sizeof(
Char) == 1) {
619 __m128i b_data = _mm_loadu_si128(
reinterpret_cast<const __m128i *
>(
b +
offset));
620 b_data1 = _mm_unpacklo_epi8(b_data, _mm_setzero_si128());
621 b_data2 = _mm_unpackhi_epi8(b_data, _mm_setzero_si128());
623 b_data1 = load8Chars(
b +
offset);
624 b_data2 = load8Chars(
b +
offset + 8);
626 __m128i result1 = _mm_cmpeq_epi16(a_data1, b_data1);
627 __m128i result2 = _mm_cmpeq_epi16(a_data2, b_data2);
628 return _mm_movemask_epi8(result1) | _mm_movemask_epi8(result2) << 16;
631 if (l >=
sizeof(__m256i) /
sizeof(
char16_t)) {
633 for ( ; l >=
offset +
sizeof(__m256i) /
sizeof(
char16_t);
offset +=
sizeof(__m256i) /
sizeof(
char16_t)) {
641 offset = l -
sizeof(__m256i) /
sizeof(
char16_t);
646 __m128i a_data1, b_data1;
647 __m128i a_data2, b_data2;
651 a_data1 = load8Chars(
a);
652 b_data1 = load8Chars(
b);
653 a_data2 = load8Chars(
a + l -
width);
654 b_data2 = load8Chars(
b + l -
width);
658 a_data1 = load4Chars(
a);
659 b_data1 = load4Chars(
b);
660 a_data2 = load4Chars(
a + l -
width);
661 b_data2 = load4Chars(
b + l -
width);
664 __m128i
result = _mm_cmpeq_epi16(a_data1, b_data1);
667 return difference(
mask, 0);
669 result = _mm_cmpeq_epi16(a_data2, b_data2);
677 const auto lambda = [=](
size_t i) ->
int {
680 return UnrollTailLoop<3>::exec(l, 0, lambda, lambda);
688#if defined(__SSE2__) && !(defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer))
689 return qustrlen_sse2(
str);
692 if (
sizeof(
wchar_t) ==
sizeof(
char16_t))
693 return wcslen(
reinterpret_cast<const wchar_t *
>(
str));
724 if constexpr (UseAvx2) {
726 __m256i mch256 = _mm256_set1_epi32(
c | (
c << 16));
728 __m256i
data = _mm256_loadu_si256(
reinterpret_cast<const __m256i *
>(
n));
729 __m256i
result = _mm256_cmpeq_epi16(
data, mch256);
737 mch = _mm256_castsi256_si128(mch256);
739 mch = _mm_set1_epi32(
c | (
c << 16));
742 auto hasMatch = [mch, &
n](__m128i
data,
ushort validityMask) {
745 if ((
mask & validityMask) == 0)
754 __m128i
data = _mm_loadu_si128(
reinterpret_cast<const __m128i *
>(
n));
755 if (hasMatch(
data, 0xffff))
764# if !defined(__OPTIMIZE_SIZE__)
767 __m128i
data = _mm_loadl_epi64(
reinterpret_cast<const __m128i *
>(
n));
768 if (hasMatch(
data, 0xff))
774 return UnrollTailLoop<3>::exec(
e -
n,
e,
778#elif defined(__ARM_NEON__)
779 const uint16x8_t vmask = { 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7 };
780 const uint16x8_t ch_vec = vdupq_n_u16(
c);
782 uint16x8_t
data = vld1q_u16(
reinterpret_cast<const uint16_t *
>(
n));
783 uint mask = vaddvq_u16(vandq_u16(vceqq_u16(
data, ch_vec), vmask));
791 return std::find(
n,
e,
c);
801 if constexpr (UseAvx2) {
803 __m256i
data = _mm256_loadu_si256(
reinterpret_cast<const __m256i *
>(
ptr));
816 __m128i
data = _mm_loadu_si128(
reinterpret_cast<const __m128i *
>(
ptr));
829 __m128i
data = _mm_loadl_epi64(
reinterpret_cast<const __m128i *
>(
ptr));
842 if (
data &= 0x80808080U) {
862 const char *
ptr =
s.begin();
863 const char *
end =
s.end();
871 const char *ptr8 =
reinterpret_cast<const char *
>(
ptr);
872 const char *end8 =
reinterpret_cast<const char *
>(
end);
873 bool ok = simdTestMask(ptr8, end8, 0xff80ff80);
874 ptr =
reinterpret_cast<const char16_t *
>(ptr8);
889 const char16_t *
ptr =
s.utf16();
890 const char16_t *
end =
ptr +
s.size();
897 const char16_t *
ptr =
s.utf16();
898 const char16_t *
end =
ptr +
s.size();
901 const char *ptr8 =
reinterpret_cast<const char *
>(
ptr);
902 const char *end8 =
reinterpret_cast<const char *
>(
end);
903 if (!simdTestMask(ptr8, end8, 0xff00ff00))
905 ptr =
reinterpret_cast<const char16_t *
>(ptr8);
917 constexpr char32_t InvalidCodePoint = UINT_MAX;
920 while (
i.hasNext()) {
921 const char32_t c =
i.next(InvalidCodePoint);
922 if (
c == InvalidCodePoint)
939 const __m128i nullMask = _mm_setzero_si128();
941 const __m128i chunk = _mm_loadu_si128((
const __m128i*)(
str +
offset));
942 if constexpr (UseAvx2) {
944 const __m256i extended = _mm256_cvtepu8_epi16(chunk);
947 _mm256_storeu_si256((__m256i*)(
dst +
offset), extended);
950 const __m128i firstHalf = _mm_unpacklo_epi8(chunk, nullMask);
951 _mm_storeu_si128((__m128i*)(
dst +
offset), firstHalf);
954 const __m128i secondHalf = _mm_unpackhi_epi8 (chunk, nullMask);
955 _mm_storeu_si128((__m128i*)(
dst +
offset + 8), secondHalf);
960 if (
size >=
sizeof(__m128i)) {
965 processOneChunk(
size -
sizeof(__m128i));
969# if !defined(__OPTIMIZE_SIZE__)
973 const __m128i unpacked1 = mm_load8_zero_extend(
str);
974 const __m128i unpacked2 = mm_load8_zero_extend(
str +
size - 8);
975 _mm_storeu_si128(
reinterpret_cast<__m128i *
>(
dst), unpacked1);
976 _mm_storeu_si128(
reinterpret_cast<__m128i *
>(
dst +
size - 8), unpacked2);
978 const __m128i chunk1 = _mm_cvtsi32_si128(qFromUnaligned<quint32>(
str));
979 const __m128i chunk2 = _mm_cvtsi32_si128(qFromUnaligned<quint32>(
str +
size - 4));
980 const __m128i unpacked1 = _mm_unpacklo_epi8(chunk1, nullMask);
981 const __m128i unpacked2 = _mm_unpacklo_epi8(chunk2, nullMask);
982 _mm_storel_epi64(
reinterpret_cast<__m128i *
>(
dst), unpacked1);
983 _mm_storel_epi64(
reinterpret_cast<__m128i *
>(
dst +
size - 4), unpacked2);
992#if defined(__mips_dsp)
993 static_assert(
sizeof(
qsizetype) ==
sizeof(
int),
994 "oops, the assembler implementation needs to be called in a loop");
996 qt_fromlatin1_mips_asm_unroll8(
dst,
str,
size);
998 qt_fromlatin1_mips_asm_unroll4(
dst,
str,
size);
1013template <
bool Checked>
1016#if defined(__SSE2__)
1017 auto questionMark256 = []() {
1018 if constexpr (UseAvx2)
1019 return _mm256_broadcastw_epi16(_mm_cvtsi32_si128(
'?'));
1023 auto outOfRange256 = []() {
1024 if constexpr (UseAvx2)
1025 return _mm256_broadcastw_epi16(_mm_cvtsi32_si128(0x100));
1029 __m128i questionMark, outOfRange;
1030 if constexpr (UseAvx2) {
1031 questionMark = _mm256_castsi256_si128(questionMark256);
1032 outOfRange = _mm256_castsi256_si128(outOfRange256);
1034 questionMark = _mm_set1_epi16(
'?');
1035 outOfRange = _mm_set1_epi16(0x100);
1038 auto mergeQuestionMarks = [=](__m128i chunk) {
1043 if constexpr (UseSse4_1) {
1045 chunk = _mm_min_epu16(chunk, outOfRange);
1046 const __m128i offLimitMask = _mm_cmpeq_epi16(chunk, outOfRange);
1047 chunk = _mm_blendv_epi8(chunk, questionMark, offLimitMask);
1051 const __m128i signedBitOffset = _mm_set1_epi16(
short(0x8000));
1052 const __m128i thresholdMask = _mm_set1_epi16(
short(0xff + 0x8000));
1054 const __m128i signedChunk = _mm_add_epi16(chunk, signedBitOffset);
1055 const __m128i offLimitMask = _mm_cmpgt_epi16(signedChunk, thresholdMask);
1059 const __m128i offLimitQuestionMark = _mm_and_si128(offLimitMask, questionMark);
1063 const __m128i correctBytes = _mm_andnot_si128(offLimitMask, chunk);
1066 chunk = _mm_or_si128(correctBytes, offLimitQuestionMark);
1074 __m128i chunk1, chunk2;
1075 if constexpr (UseAvx2) {
1076 __m256i chunk = _mm256_loadu_si256(
reinterpret_cast<const __m256i *
>(
src +
offset));
1079 chunk = _mm256_min_epu16(chunk, outOfRange256);
1080 const __m256i offLimitMask = _mm256_cmpeq_epi16(chunk, outOfRange256);
1081 chunk = _mm256_blendv_epi8(chunk, questionMark256, offLimitMask);
1084 chunk2 = _mm256_extracti128_si256(chunk, 1);
1085 chunk1 = _mm256_castsi256_si128(chunk);
1087 chunk1 = _mm_loadu_si128((
const __m128i*)(
src +
offset));
1088 chunk1 = mergeQuestionMarks(chunk1);
1090 chunk2 = _mm_loadu_si128((
const __m128i*)(
src +
offset + 8));
1091 chunk2 = mergeQuestionMarks(chunk2);
1095 return _mm_packus_epi16(chunk1, chunk2);
1098 if (
size_t(
length) >=
sizeof(__m128i)) {
1102 _mm_storeu_si128(
reinterpret_cast<__m128i *
>(
dst +
offset), loadChunkAt(
offset));
1105 __m128i last1 = loadChunkAt(
offset);
1106 __m128i last2 = loadChunkAt(
length -
sizeof(__m128i));
1107 _mm_storeu_si128(
reinterpret_cast<__m128i *
>(
dst +
offset), last1);
1108 _mm_storeu_si128(
reinterpret_cast<__m128i *
>(
dst +
length -
sizeof(__m128i)), last2);
1112# if !defined(__OPTIMIZE_SIZE__)
1117 __m128i chunk1 = _mm_loadu_si128(
reinterpret_cast<const __m128i *
>(
src));
1118 __m128i chunk2 = _mm_loadu_si128(
reinterpret_cast<const __m128i *
>(
src +
length - 8));
1119 chunk1 = mergeQuestionMarks(chunk1);
1120 chunk2 = mergeQuestionMarks(chunk2);
1123 const __m128i result1 = _mm_packus_epi16(chunk1, chunk1);
1124 const __m128i result2 = _mm_packus_epi16(chunk2, chunk2);
1125 _mm_storel_epi64(
reinterpret_cast<__m128i *
>(
dst), result1);
1126 _mm_storel_epi64(
reinterpret_cast<__m128i *
>(
dst +
length - 8), result2);
1128 __m128i chunk1 = _mm_loadl_epi64(
reinterpret_cast<const __m128i *
>(
src));
1129 __m128i chunk2 = _mm_loadl_epi64(
reinterpret_cast<const __m128i *
>(
src +
length - 4));
1130 chunk1 = mergeQuestionMarks(chunk1);
1131 chunk2 = mergeQuestionMarks(chunk2);
1134 const __m128i result1 = _mm_packus_epi16(chunk1, chunk1);
1135 const __m128i result2 = _mm_packus_epi16(chunk2, chunk2);
1152#elif defined(__ARM_NEON__)
1159 const uint16x8_t questionMark = vdupq_n_u16(
'?');
1160 const uint16x8_t thresholdMask = vdupq_n_u16(0xff);
1162 uint16x8_t chunk = vld1q_u16((uint16_t *)
src);
1166 const uint16x8_t offLimitMask = vcgtq_u16(chunk, thresholdMask);
1167 const uint16x8_t offLimitQuestionMark = vandq_u16(offLimitMask, questionMark);
1168 const uint16x8_t correctBytes = vbicq_u16(chunk, offLimitMask);
1169 chunk = vorrq_u16(correctBytes, offLimitQuestionMark);
1171 const uint8x8_t
result = vmovn_u16(chunk);
1178#if defined(__mips_dsp)
1179 static_assert(
sizeof(
qsizetype) ==
sizeof(
int),
1180 "oops, the assembler implementation needs to be called in a loop");
1213 for (
i = 0;
i < l; ++
i) {
1235 for (
i = 0;
i < l; ++
i) {
1251 auto src1 =
reinterpret_cast<const uchar *
>(utf8);
1252 auto end1 =
reinterpret_cast<const uchar *
>(utf8end);
1255 while (src1 < end1 && src2.
hasNext()) {
1268 int diff = uc1 - uc2;
1274 return (end1 > src1) - int(src2.
hasNext());
1277#if defined(__mips_dsp)
1279extern "C" int qt_ucstrncmp_mips_dsp_asm(
const char16_t *
a,
1285template <StringComparisonMode Mode>
1292#ifndef __OPTIMIZE_SIZE__
1293# if defined(__mips_dsp)
1294 static_assert(
sizeof(
uint) ==
sizeof(
size_t));
1296 return qt_ucstrncmp_mips_dsp_asm(
a,
b, l);
1298# elif defined(__SSE2__)
1299 return ucstrncmp_sse2<Mode>(
a,
b, l);
1300# elif defined(__ARM_NEON__)
1302 const char16_t *
end =
a + l;
1303 const uint16x8_t
mask = { 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7 };
1304 while (
end -
a > 7) {
1305 uint16x8_t da = vld1q_u16(
reinterpret_cast<const uint16_t *
>(
a));
1306 uint16x8_t
db = vld1q_u16(
reinterpret_cast<const uint16_t *
>(
b));
1308 uint8_t
r = ~(uint8_t)vaddvq_u16(vandq_u16(vceqq_u16(da,
db),
mask));
1311 if (
Mode == CompareStringsForEquality)
1314 return a[idx] -
b[idx];
1321 const auto lambda = [=](
size_t i) ->
int {
1324 return UnrollTailLoop<7>::exec(l, 0, lambda, lambda);
1329 return memcmp(
a,
b, l *
sizeof(
char16_t));
1331 for (
size_t i = 0;
i < l; ++
i) {
1332 if (
int diff =
a[
i] -
b[
i])
1338template <StringComparisonMode Mode>
1342 const char16_t *uc =
a;
1343 const char16_t *
e = uc + l;
1345#if defined(__SSE2__) && !defined(__OPTIMIZE_SIZE__)
1346 return ucstrncmp_sse2<Mode>(uc,
c, l);
1350 int diff = *uc - *
c;
1360template <
typename Char2>
1361static bool ucstreq(
const char16_t *
a,
size_t alen,
const Char2 *
b,
size_t blen)
1365 if constexpr (std::is_same_v<
decltype(
a),
decltype(
b)>) {
1369 return ucstrncmp<CompareStringsForEquality>(
a,
b, alen) == 0;
1373template <
typename Char2>
1374static int ucstrcmp(
const char16_t *
a,
size_t alen,
const Char2 *
b,
size_t blen)
1376 if constexpr (std::is_same_v<
decltype(
a),
decltype(
b)>) {
1377 if (
a ==
b && alen == blen)
1380 const size_t l =
qMin(alen, blen);
1381 int cmp = ucstrncmp<CompareStringsForOrdering>(
a,
b, l);
1382 return cmp ? cmp :
qt_lencmp(alen, blen);
1390 Q_ASSERT(lSize >= 0 && rSize >= 0);
1392 return rSize ? -1 : 0;
1407 return ucstreq(lhs.utf16(), lhs.size(), rhs.utf16(), rhs.size());
1412 return ucstreq(lhs.utf16(), lhs.size(), rhs.latin1(), rhs.size());
1447 return lhs.size() == rhs.size() && (!lhs.size() || memcmp(lhs.data(), rhs.data(), lhs.size()) == 0);
1452 if (lhs.size() != rhs.size() && lhs.isUtf8() == rhs.isUtf8())
1454 return lhs.visit([rhs](
auto lhs) {
1455 return rhs.visit([lhs](
auto rhs) {
1479 return ucstrcmp(lhs.utf16(), lhs.size(), rhs.utf16(), rhs.size());
1480 return ucstricmp(lhs.size(), lhs.utf16(), rhs.size(), rhs.utf16());
1502 return ucstrcmp(lhs.utf16(), lhs.size(), rhs.latin1(), rhs.size());
1503 return ucstricmp(lhs.size(), lhs.utf16(), rhs.size(), rhs.latin1());
1514 return -compareStrings(rhs, lhs, cs);
1525 return -compareStrings(rhs, lhs, cs);
1549 return latin1nicmp(lhs.data(), lhs.size(), rhs.data(), rhs.size());
1550 const auto l = std::min(lhs.size(), rhs.size());
1551 int r = memcmp(lhs.data(), rhs.data(), l);
1576 return ucstricmp8(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
1587 return -compareStrings(rhs, lhs, cs);
1603 return lhs.visit([rhs, cs](
auto lhs) {
1604 return rhs.visit([lhs, cs](
auto rhs) {
1612#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
1613static bool supportUnicodeDigitValuesInArg()
1615 static const bool result = []() {
1616 static const char supportUnicodeDigitValuesEnvVar[]
1617 =
"QT_USE_UNICODE_DIGIT_VALUES_IN_STRING_ARG";
1622#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
1635#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
1636 if (supportUnicodeDigitValuesInArg())
1637 return ch.digitValue();
1639 if (
ch >= u
'0' &&
ch <= u
'9')
1640 return int(
ch.unicode() - u
'0');
1644#if QT_CONFIG(regularexpression)
2517 char16_t *
b = d.
data();
2519 const char16_t value =
ch.unicode();
2555 d.
data()[0] =
ch.unicode();
2620 return newSize > capacityAtEnd;
2682 std::fill_n(d.
data() + oldSize, difference, fillChar.
unicode());
2768 ::memcpy(dd.data(), d.
data(), dd.size *
sizeof(
QChar));
2769 dd.data()[dd.size] = 0;
2772 d->reallocate(alloc,
option);
2785 dd.data()[dd.size] = 0;
2874 d.
data()[0] =
ch.unicode();
2946template <
typename T>
2952 difference =
i - str_d.size;
2954 const qsizetype insert_size = toInsert.size();
2955 const qsizetype newSize = str_d.size + difference + insert_size;
2961 const auto insert_start = difference == 0 ? std::next(cbegin,
i) : cend;
2965 other.data_ptr().detachAndGrow(side, newSize,
nullptr,
nullptr);
2968 other.append(toInsert);
2974 str_d.detachAndGrow(side, difference + insert_size,
nullptr,
nullptr);
2978 auto begin = str_d.begin();
2979 auto old_end = std::next(
begin, oldSize);
2980 std::fill_n(old_end, difference, u
' ');
2981 auto insert_start = std::next(
begin,
i);
2982 if (difference == 0)
2983 std::move_backward(insert_start, old_end, str_d.end());
2985 using Char = std::remove_cv_t<typename T::value_type>;
2986 if constexpr(std::is_same_v<Char, QChar>)
2987 std::copy_n(
reinterpret_cast<const char16_t *
>(toInsert.data()), insert_size, insert_start);
2988 else if constexpr (std::is_same_v<Char, char16_t>)
2989 std::copy_n(toInsert.data(), insert_size, insert_start);
2990 else if constexpr (std::is_same_v<Char, char>)
3004 const char *
s =
str.latin1();
3005 if (
i < 0 || !
s || !(*
s))
3027 auto insert_size =
s.
size();
3028 if (
i < 0 || insert_size <= 0)
3033 difference =
i - d.
size;
3035 const qsizetype newSize = d.
size + difference + insert_size;
3039 const auto insert_start = difference == 0 ? std::next(
cbegin,
i) :
cend();
3041 other.reserve(newSize);
3085 if (
i < 0 ||
size <= 0)
3164 static_assert(
sizeof(
QChar) ==
sizeof(
char16_t),
"Unexpected difference in sizes");
3166 const char16_t *char16String =
reinterpret_cast<const char16_t *
>(
str);
3180 append_helper(*
this,
str);
3192 append_helper(*
this,
str);
3384 s.visit([
this](
auto input) {
3388 *
this =
s.toString();
3396 const auto requiredCapacity =
len * 2;
3440 if (
size_t(
pos) >=
size_t(
size()) ||
len <= 0)
3455 auto toRemove_start = d.
begin() +
pos;
3456 copy.d->copyRanges({{
begin, toRemove_start},
3457 {toRemove_start +
len, d.
end()}});
3466 const auto needleSize = needle.size();
3479 auto copyFunc = [&](
auto &
dst) {
3482 i =
s.indexOf(needle, std::distance(
begin,
src), cs);
3485 src = hit + needleSize;
3496 auto copy_begin =
copy.begin();
3499 copy.resize(std::distance(copy_begin,
dst));
3603 ch = isCase ?
ch :
ch.toCaseFolded();
3605 return ch == (isCase ?
x :
x.toCaseFolded());
3610 auto first_match =
begin + idx;
3613 auto it = std::remove_if(first_match,
end,
match);
3622 auto it = std::copy(
begin, first_match,
dst);
3623 it = std::remove_copy_if(first_match + 1,
end,
it,
match);
3625 copy.d.data()[
copy.d.size] = u
'\0';
3665 const char16_t *after_b = after.
utf16();
3668 auto src_start = str_d.
begin();
3669 const qsizetype newSize = str_d.
size + nIndices * (alen - blen);
3673 for (
int i = 0;
i < nIndices; ++
i) {
3675 dst = std::copy(src_start, hit,
dst);
3676 dst = std::copy_n(after_b, alen,
dst);
3677 src_start = hit + blen;
3679 dst = std::copy(src_start, str_d.
end(),
dst);
3688 const char16_t *after_b = after.
utf16();
3689 const char16_t *after_e = after.
utf16() + after.
size();
3694 }
else if (blen > alen) {
3698 to = std::copy_n(after_b, alen, to);
3699 char16_t *movestart = hit + blen;
3702 to = std::move(movestart, hit, to);
3703 to = std::copy_n(after_b, alen, to);
3704 movestart = hit + blen;
3710 const qsizetype adjust = nIndices * (alen - blen);
3711 const qsizetype newSize = oldSize + adjust;
3715 char16_t *moveend =
begin + oldSize;
3721 char16_t *movestart = hit + blen;
3722 to = std::move_backward(movestart, moveend, to);
3723 to = std::copy_backward(after_b, after_e, to);
3733 const qsizetype newSize = oldSize + adjust;
3777 if (
size_t(
pos) >
size_t(this->
size()))
3779 if (len > this->
size() - pos)
3842 if (alen == 0 && blen == 0)
3844 if (alen == 1 && blen == 1)
3845 return replace(*before, *after, cs);
3875 if (after.
size() == 0)
3878 if (after.
size() == 1)
3889 const char16_t *
end = d.
end();
3891 const char16_t *hit =
nullptr;
3921 const char16_t achar = after.
unicode();
3922 char16_t bchar = before.
unicode();
3924 auto matchesCIS = [](
char16_t beforeChar) {
3925 return [beforeChar](
char16_t ch) {
return foldAndCompare(
ch, beforeChar); };
3928 auto hit = d.
begin() + idx;
3932 std::replace(hit, d.
end(), bchar, achar);
3935 std::replace_if(hit, d.
end(), matchesCIS(bchar), achar);
3939 auto dest = std::copy(d.
begin(), hit,
other.d.begin());
3943 std::replace_copy(hit, d.
end(), dest, bchar, achar);
3946 std::replace_copy_if(hit, d.
end(), dest, matchesCIS(bchar), achar);
3970 if (blen == 1 && alen == 1)
3993 if (blen == 1 && after.
size() == 1)
4014 if (before.
size() == 1 && alen == 1)
4569#if QT_CONFIG(regularexpression)
4570struct QStringCapture
4619 if (ac[
i] == u
'\\') {
4621 if (no > 0 && no <= numCaptures) {
4622 QStringCapture backReference;
4623 backReference.pos =
i;
4624 backReference.len = 2;
4628 if (secondDigit != -1 && ((no * 10) + secondDigit) <= numCaptures) {
4629 no = (no * 10) + secondDigit;
4630 ++backReference.len;
4634 backReference.no = no;
4635 backReferences.
append(backReference);
4652 len =
match.capturedStart() - lastEnd;
4654 chunks << copyView.
mid(lastEnd,
len);
4660 for (
const QStringCapture &backReference :
std::as_const(backReferences)) {
4662 len = backReference.pos - lastEnd;
4664 chunks << afterView.
mid(lastEnd,
len);
4669 len =
match.capturedLength(backReference.no);
4671 chunks << copyView.
mid(
match.capturedStart(backReference.no),
len);
4675 lastEnd = backReference.pos + backReference.len;
4679 len = afterView.size() - lastEnd;
4681 chunks << afterView.
mid(lastEnd,
len);
4685 lastEnd =
match.capturedEnd();
4689 if (copyView.size() > lastEnd) {
4690 chunks << copyView.
mid(lastEnd);
4691 newLength += copyView.size() - lastEnd;
4700 memcpy(uc +
i, chunk.constData(),
len *
sizeof(
QChar));
4794#if QT_CONFIG(regularexpression)
4887 return QtPrivate::contains(
QStringView(*
this),
this, re, rmatch);
4914#if QT_DEPRECATED_SINCE(6, 4)
4994 start += sectionsSize;
4996 end += sectionsSize;
4999 for (
qsizetype k = 0; k < sectionsSize; ++k) {
5000 if (sections.
at(k).isEmpty())
5004 start += sectionsSize - skip;
5006 end += sectionsSize - skip;
5008 if (
start >= sectionsSize || end < 0 || start >
end)
5035#if QT_CONFIG(regularexpression)
5036class qt_section_chunk {
5038 qt_section_chunk() {}
5046 QString::SectionFlags
flags)
5052 start += sectionsSize;
5054 end += sectionsSize;
5057 for (
qsizetype k = 0; k < sectionsSize; ++k) {
5058 const qt_section_chunk §ion = sections.
at(k);
5059 if (section.length == section.string.size())
5063 start += sectionsSize - skip;
5065 end += sectionsSize - skip;
5067 if (
start >= sectionsSize || end < 0 || start >
end)
5074 const qt_section_chunk §ion = sections.
at(
i);
5075 const bool empty = (section.length == section.string.size());
5082 ret += section.string;
5084 ret += section.string.mid(section.length);
5091 const qt_section_chunk §ion = sections.
at(first_i);
5092 ret.prepend(section.string.left(section.length));
5096 && last_i < sectionsSize - 1) {
5097 const qt_section_chunk §ion = sections.
at(last_i+1);
5098 ret += section.string.left(section.length);
5138 m =
match.capturedStart();
5141 last_len =
match.capturedLength();
5163 if (
size_t(
n) >=
size_t(
size()))
5182 if (
size_t(
n) >=
size_t(
size()))
5209 switch (QContainerImplHelper::mid(
size(), &
p, &l)) {
5210 case QContainerImplHelper::Null:
5212 case QContainerImplHelper::Empty:
5214 case QContainerImplHelper::Full:
5216 case QContainerImplHelper::Subset:
5219 Q_UNREACHABLE_RETURN(
QString());
5407 while (
it.hasNext()) {
5408 const char32_t uc =
it.next();
5433 while (
it.hasNext()) {
5434 const char32_t uc =
it.next();
5461 return string.visit([] (
auto string) {
return string.toString(); });
5492 string.utf16(),
string.size());
5498 if (!
s.isDetached())
5508 char16_t *sdata =
s.d->data();
5514 auto ba_d = std::move(
s.d).reinterpreted<
char>();
5517 Q_ASSERT(ba_d.d->allocatedCapacity() >= ba_d.size);
5530 return std::next(
out,
len);
5576 if (
string.isNull())
5672 while (
it.hasNext())
5674 v.resize(
a -
v.constData());
5715 }
else if (
ba.
size() == 0) {
5721 char16_t *
dst =
d.data();
5989 template <
typename StringView>
5990 StringView qt_trimmed(StringView
s)
noexcept
6016 return qt_trimmed(
s);
6021 return qt_trimmed(
s);
6204 std::fill(
b,
i,
ch);
6628#if !defined(CSTR_LESS_THAN)
6629#define CSTR_LESS_THAN 1
6631#define CSTR_GREATER_THAN 3
6658int QString::localeAwareCompare_helper(
const QChar *data1,
qsizetype length1,
6667 if (length1 == 0 || length2 == 0)
6676# if defined(Q_OS_WIN)
6687# elif defined (Q_OS_DARWIN)
6692 const CFStringRef thisString =
6693 CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault,
6694 reinterpret_cast<const UniChar *
>(lhs.
constData()), lhs.
length(), kCFAllocatorNull);
6695 const CFStringRef otherString =
6696 CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault,
6697 reinterpret_cast<const UniChar *
>(rhs.
constData()), rhs.
length(), kCFAllocatorNull);
6699 const int result = CFStringCompare(thisString, otherString, kCFCompareLocalized);
6700 CFRelease(thisString);
6701 CFRelease(otherString);
6703# elif defined(Q_OS_UNIX)
6707# error "This case shouldn't happen"
6743 return reinterpret_cast<const ushort *
>(d.
data());
6814 memcpy(
static_cast<void *
>(uc),
static_cast<const void *
>(d.
data()),
sizeof(
QChar)*
len);
6863template <
typename T>
6869 QChar *pp =
s.begin() +
it.index();
6874 if (folded.chars[0] == *pp && folded.size() == 2) {
6878 *pp++ = folded.chars[1];
6884 s.replace(outpos, 1,
reinterpret_cast<const QChar *
>(folded.data()), folded.size());
6885 pp =
const_cast<QChar *
>(
s.constBegin()) + outpos + folded.size();
6888 if constexpr (!std::is_const<T>::value)
6892 *pp++ = folded.chars[0];
6894 }
while (
it.hasNext());
6899template <
typename T>
6906 while (
e !=
p &&
e[-1].isHighSurrogate())
6910 while (
it.hasNext()) {
6911 const char32_t uc =
it.next();
6912 if (
qGetProp(uc)->cases[which].diff) {
6917 return std::move(
str);
7008 va_start(ap, cformat);
7036 default:
return flags;
7045 const char *
const stop =
c +
size;
7075 case 'L':
return lm_L;
7076 case 'j':
return lm_j;
7078 case 'Z':
return lm_z;
7079 case 't':
return lm_t;
7101 if (!cformat || !*cformat) {
7109 const char *
c = cformat;
7110 const char *formatEnd = cformat +
qstrlen(cformat);
7114 while (*
c !=
'\0' && *
c !=
'%')
7122 const char *escape_start =
c;
7146 }
else if (*
c ==
'*') {
7147 width = va_arg(ap,
int);
7165 }
else if (*
c ==
'*') {
7191 switch (length_mod) {
7192 case lm_none:
i = va_arg(ap,
int);
break;
7193 case lm_hh:
i = va_arg(ap,
int);
break;
7194 case lm_h:
i = va_arg(ap,
int);
break;
7195 case lm_l:
i = va_arg(ap,
long int);
break;
7197 case lm_j:
i = va_arg(ap,
long int);
break;
7202 default:
i = 0;
break;
7213 switch (length_mod) {
7215 case lm_hh: u = va_arg(ap,
uint);
break;
7216 case lm_h: u = va_arg(ap,
uint);
break;
7217 case lm_l: u = va_arg(ap,
ulong);
break;
7219 case lm_t: u = va_arg(ap,
size_t);
break;
7220 case lm_z: u = va_arg(ap,
size_t);
break;
7221 default: u = 0;
break;
7250 if (length_mod ==
lm_L)
7251 d = va_arg(ap,
long double);
7253 d = va_arg(ap,
double);
7271 if (length_mod ==
lm_l)
7279 if (length_mod ==
lm_l) {
7290 const char *buff = va_arg(ap,
const char*);
7297 void *
arg = va_arg(ap,
void*);
7305 switch (length_mod) {
7307 signed char *
n = va_arg(ap,
signed char*);
7312 short int *
n = va_arg(ap,
short int*);
7317 long int *
n = va_arg(ap,
long int*);
7327 int *
n = va_arg(ap,
int*);
7336 for (
const char *cc = escape_start; cc !=
c; ++cc)
7379template <
typename Int>
7382#if defined(QT_CHECK_RANGE)
7383 if (
base != 0 && (base < 2 || base > 36)) {
7384 qWarning(
"QString::toIntegral: Invalid base (%d)",
base);
7391 if constexpr (std::is_signed_v<Int>)
7399 return toIntegral<qlonglong>(
string,
ok,
base);
7433 return toIntegral<qulonglong>(
string,
ok,
base);
7840#if defined(QT_CHECK_RANGE)
7841 if (base < 2 || base > 36) {
7846 bool negative =
n < 0;
7859#if defined(QT_CHECK_RANGE)
7860 if (base < 2 || base > 36) {
7895#if defined(QT_CHECK_RANGE)
7905template<
class ResultList,
class StringSource>
7910 typename StringSource::size_type
start = 0;
7911 typename StringSource::size_type
end;
7912 typename StringSource::size_type extra = 0;
7917 extra = (
sep.size() == 0 ? 1 : 0);
7958 return splitString<QStringList>(*
this,
sep, behavior, cs);
7967 return splitString<QStringList>(*
this,
QStringView(&
sep, 1), behavior, cs);
7989 return splitString<QList<QStringView>>(
QStringView(*
this),
sep, behavior, cs);
7997#if QT_CONFIG(regularexpression)
7999template<
class ResultList,
typename String,
typename MatchingFunction>
8001 MatchingFunction matchingFunction,
8002 Qt::SplitBehavior behavior)
8057#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
8058 const auto matchingFunction = qOverload<const QString &, qsizetype, QRegularExpression::MatchType, QRegularExpression::MatchOptions>(&
QRegularExpression::globalMatch);
8062 return splitString<QStringList>(*
this,
8126 result.reserve(resultSize);
8127 if (
result.capacity() != resultSize)
8133 char16_t *
end =
result.d.data() + sizeSoFar;
8135 const qsizetype halfResultSize = resultSize >> 1;
8136 while (sizeSoFar <= halfResultSize) {
8141 memcpy(
end,
result.d.data(), (resultSize - sizeSoFar) *
sizeof(
QChar));
8142 result.d.data()[resultSize] =
'\0';
8143 result.d.size = resultSize;
8151 auto start =
reinterpret_cast<const char16_t *
>(
data->constData());
8152 const char16_t *
p =
start + from;
8165 if (
n.version > version) {
8172 while (
pos <
s.size() - 1) {
8173 if (
s.at(
pos).unicode() == ucs4High &&
s.at(
pos + 1).unicode() == ucs4Low) {
8182 while (
pos <
s.size()) {
8183 if (
s.at(
pos).unicode() ==
n.ucs4) {
8219#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
8225 if (!supportUnicodeDigitValuesInArg())
8228 const auto isNonAsciiDigit = [](
QChar c) {
8229 return c.unicode() < u
'0' ||
c.unicode() > u
'9';
8232 if (std::any_of(
s.begin(),
s.end(), isNonAsciiDigit)) {
8233 const auto accumulateDigit = [](
int partial,
QChar digit) {
8234 return partial * 10 + digit.digitValue();
8236 const int parsedNumber = std::accumulate(
s.begin(),
s.end(), 0, accumulateDigit);
8238 qWarning(
"QString::arg(): the replacement \"%%%ls\" contains non-ASCII digits;\n"
8239 " it is currently being interpreted as the %d-th substitution.\n"
8240 " This is deprecated; support for non-ASCII digits will be dropped\n"
8241 " in a future version of Qt.",
8259 const QChar *uc_begin =
s.begin();
8260 const QChar *uc_end =
s.end();
8264 d.min_escape = INT_MAX;
8267 d.locale_occurrences = 0;
8269 const QChar *
c = uc_begin;
8270 while (
c != uc_end) {
8271 while (
c != uc_end &&
c->
unicode() !=
'%')
8276 const QChar *escape_start =
c;
8280 bool locale_arg =
false;
8281 if (
c->unicode() ==
'L') {
8293#if QT_VERSION <= QT_VERSION_CHECK(7, 0, 0)
8294 const QChar *escapeBegin =
c;
8295 const QChar *escapeEnd = escapeBegin + 1;
8302 if (next_escape != -1) {
8305#if QT_VERSION <= QT_VERSION_CHECK(7, 0, 0)
8311#if QT_VERSION <= QT_VERSION_CHECK(7, 0, 0)
8312 checkArgEscape(
QStringView(escapeBegin, escapeEnd));
8322 d.locale_occurrences = 0;
8327 ++
d.locale_occurrences;
8328 d.escape_len +=
c - escape_start;
8339 s.size() -
d.escape_len
8340 + (
d.occurrences -
d.locale_occurrences) *
qMax(abs_field_width,
arg.size())
8341 +
d.locale_occurrences *
qMax(abs_field_width, larg.
size());
8345 QChar *
const result_end = rc + result_len;
8349 const QChar *
const uc_end =
s.end();
8350 while (
c != uc_end) {
8356 const QChar *text_start =
c;
8357 while (
c->unicode() !=
'%')
8360 const QChar *escape_start =
c++;
8361 const bool localize =
c->
unicode() ==
'L';
8366 if (
escape != -1 &&
c + 1 != uc_end) {
8375 memcpy(rc, text_start, (
c - text_start) *
sizeof(
QChar));
8376 rc +=
c - text_start;
8380 memcpy(rc, text_start, (escape_start - text_start) *
sizeof(
QChar));
8381 rc += escape_start - text_start;
8387 if (field_width > 0) {
8388 rc = std::fill_n(rc, pad_chars, fillChar);
8394 if (field_width < 0) {
8395 rc = std::fill_n(rc, pad_chars, fillChar);
8398 if (++repl_cnt ==
d.occurrences) {
8399 memcpy(rc,
c, (uc_end -
c) *
sizeof(
QChar));
8610 if (
d.occurrences == 0) {
8611 qWarning() <<
"QString::arg: Argument missing:" << *
this <<
',' <<
a;
8617 if (fillChar == u
'0')
8621 if (
d.occurrences >
d.locale_occurrences) {
8624 || fieldWidth <=
arg.size());
8628 if (
d.locale_occurrences > 0) {
8632 localeArg = locale.d->m_data->longLongToString(
a, -1,
base, fieldWidth,
flags);
8634 || fieldWidth <= localeArg.
size());
8658 if (
d.occurrences == 0) {
8659 qWarning() <<
"QString::arg: Argument missing:" << *
this <<
',' <<
a;
8665 if (fillChar == u
'0')
8669 if (
d.occurrences >
d.locale_occurrences) {
8672 || fieldWidth <=
arg.size());
8676 if (
d.locale_occurrences > 0) {
8680 localeArg = locale.d->m_data->unsLongLongToString(
a, -1,
base, fieldWidth,
flags);
8682 || fieldWidth <= localeArg.
size());
8758 if (
d.occurrences == 0) {
8765 if (fillChar == u
'0')
8783#if defined(QT_CHECK_RANGE)
8790 if (
d.occurrences >
d.locale_occurrences) {
8794 || fieldWidth <=
arg.size());
8798 if (
d.locale_occurrences > 0) {
8801 const QLocale::NumberOptions numberOptions = locale.numberOptions();
8810 || fieldWidth <= localeArg.
size());
8819template <
typename Char>
8824 if (
i <
len && uc[
i] == u
'L')
8833 if (
uint(digit) >= 10U)
8838 if (
escape <= maxNumber) {
8903enum { ExpectedParts = 32 };
8906typedef QVarLengthArray<int, ExpectedParts/2> ArgIndexToPlaceholderMap;
8908template <
typename StringView>
8909static ParseResult parseMultiArgFormatString(StringView
s)
8913 const auto uc =
s.data();
8914 const auto len =
s.size();
8915 const auto end =
len - 1;
8920 if (uc[
i] == u
'%') {
8924 if (last != percent)
8925 result.push_back(Part{
s.sliced(last, percent - last)});
8935 result.push_back(Part{
s.sliced(last,
len - last)});
8940static ArgIndexToPlaceholderMap makeArgIndexToPlaceholderMap(
const ParseResult &parts)
8942 ArgIndexToPlaceholderMap
result;
8944 for (
const Part &part : parts) {
8945 if (part.number >= 0)
8946 result.push_back(part.number);
8956static qsizetype resolveStringRefsAndReturnTotalSize(ParseResult &parts,
const ArgIndexToPlaceholderMap &argIndexToPlaceholderMap,
const QtPrivate::ArgBase *
args[])
8960 for (Part &part : parts) {
8961 if (part.number != -1) {
8962 const auto it = std::find(argIndexToPlaceholderMap.begin(), argIndexToPlaceholderMap.end(), part.number);
8963 if (
it != argIndexToPlaceholderMap.
end()) {
8978 totalSize += part.size;
8988template <
typename StringView>
8992 ParseResult parts = parseMultiArgFormatString(
pattern);
8995 ArgIndexToPlaceholderMap argIndexToPlaceholderMap = makeArgIndexToPlaceholderMap(parts);
8997 if (
static_cast<size_t>(argIndexToPlaceholderMap.size()) > numArgs)
8998 argIndexToPlaceholderMap.resize(
qsizetype(numArgs));
8999 else if (
Q_UNLIKELY(
static_cast<size_t>(argIndexToPlaceholderMap.size()) < numArgs))
9000 qWarning(
"QString::arg: %d argument(s) missing in %ls",
9004 const qsizetype totalSize = resolveStringRefsAndReturnTotalSize(parts, argIndexToPlaceholderMap,
args);
9010 for (
const Part &part : parts) {
9015 reinterpret_cast<const char*
>(part.data), part.size);
9023 memcpy(
out, part.data, part.size *
sizeof(
QChar));
9048 const char16_t *
p = d.
data();
9049 const char16_t *
const end =
p + d.
size;
9053 if (uc > 0x058f && (uc < 0x1100 || uc > 0xfb0f)) {
9308#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED)
9320 if (
out.version() == 1) {
9325 out.writeBytes(
reinterpret_cast<const char *
>(
str.
unicode()),
9330 out.writeBytes(
reinterpret_cast<const char *
>(
buffer.data()),
9331 static_cast<uint>(
sizeof(
char16_t) *
buffer.size()));
9352 if (
in.version() == 1) {
9359 if (bytes == 0xffffffff) {
9361 }
else if (bytes > 0) {
9368 const quint32 Step = 1024 * 1024;
9372 while (allocated <
len) {
9375 if (
in.readRawData(
reinterpret_cast<char *
>(
str.
data()) + allocated * 2,
9386 char16_t *
data =
reinterpret_cast<char16_t *
>(
str.
data());
9423 int isolateLevel = 0;
9426 const char32_t c =
i.next();
9473 if (haystack.size() > 500 && needle.size() > 5) {
9475 while ((
i =
matcher.indexIn(haystack,
i + 1)) != -1)
9487 return std::count(haystack.cbegin(), haystack.cend(), needle);
9490 return std::count_if(haystack.cbegin(), haystack.cend(),
9491 [needle](
const QChar c) { return foldAndCompare(c, needle); });
9500 while ((
i =
matcher.indexIn(haystack,
i + 1)) != -1)
9508 if (haystack.
size() < needle.
size())
9522 while ((
i =
matcher.indexIn(haystack,
i + 1)) != -1)
9530 if (haystack.
size() < needle.
size())
9540 if (needle.unicode() > 0xff)
9544 return std::count(haystack.cbegin(), haystack.cend(), needle.toLatin1());
9546 return std::count_if(haystack.cbegin(), haystack.cend(),
9573 return qt_starts_with_impl(haystack, needle, cs);
9578 return qt_starts_with_impl(haystack, needle, cs);
9583 return qt_starts_with_impl(haystack, needle, cs);
9588 return qt_starts_with_impl(haystack, needle, cs);
9613 return qt_ends_with_impl(haystack, needle, cs);
9618 return qt_ends_with_impl(haystack, needle, cs);
9623 return qt_ends_with_impl(haystack, needle, cs);
9628 return qt_ends_with_impl(haystack, needle, cs);
9637 if (std::size_t(sl + from) > std::size_t(l))
9645 return qFindChar(haystack0, needle0[0], from, cs);
9652 if (l > 500 && sl > 5)
9655 auto sv = [sl](
const char16_t *
v) {
return QStringView(
v, sl); };
9662 const char16_t *needle = needle0.utf16();
9663 const char16_t *haystack = haystack0.utf16() + from;
9664 const char16_t *
end = haystack0.utf16() + (l - sl);
9665 const std::size_t sl_minus_1 = sl - 1;
9666 std::size_t hashNeedle = 0, hashHaystack = 0;
9670 for (idx = 0; idx < sl; ++idx) {
9671 hashNeedle = ((hashNeedle<<1) + needle[idx]);
9672 hashHaystack = ((hashHaystack<<1) + haystack[idx]);
9674 hashHaystack -= haystack[sl_minus_1];
9676 while (haystack <=
end) {
9677 hashHaystack += haystack[sl_minus_1];
9678 if (hashHaystack == hashNeedle
9680 return haystack - haystack0.utf16();
9686 const char16_t *haystack_start = haystack0.utf16();
9687 for (idx = 0; idx < sl; ++idx) {
9688 hashNeedle = (hashNeedle<<1) +
foldCase(needle + idx, needle);
9689 hashHaystack = (hashHaystack<<1) +
foldCase(haystack + idx, haystack_start);
9691 hashHaystack -=
foldCase(haystack + sl_minus_1, haystack_start);
9693 while (haystack <=
end) {
9694 hashHaystack +=
foldCase(haystack + sl_minus_1, haystack_start);
9695 if (hashHaystack == hashNeedle
9697 return haystack - haystack0.utf16();
9708 if (haystack.size() < needle.size())
9717 if (haystack.size() < needle.size())
9723 if (needle.size() == 1) {
9724 const char n = needle.front().toLatin1();
9736 from += haystack.size();
9739 qsizetype adjustedSize = haystack.size() - from;
9740 if (adjustedSize < needle.size())
9742 if (needle.size() == 0)
9747 if (needle.size() == 1) {
9748 Q_ASSUME(haystack.data() !=
nullptr);
9749 if (
auto it = memchr(haystack.data() + from, needle.front().toLatin1(), adjustedSize))
9750 return static_cast<const char *
>(
it) - haystack.data();
9755 return matcher.indexIn(haystack, from);
9772 if (needle.size() <= threshold) {
9773 const auto begin = haystack.begin();
9774 const auto end = haystack.end() - needle.size() + 1;
9776 const qsizetype nlen1 = needle.size() - 1;
9778 it = std::find_if(
it + 1,
end, ciMatch)) {
9781 return std::distance(
begin,
it);
9787 return matcher.indexIn(haystack, from);
9792 return qLastIndexOf(haystack, from, needle, cs);
9797 return qLastIndexOf(haystack, from, needle, cs);
9802 return qLastIndexOf(haystack, from, needle, cs);
9807 return qLastIndexOf(haystack, from, needle, cs);
9810#if QT_CONFIG(regularexpression)
9819 ? re.
match(*stringHaystack, from)
9821 if (
match.hasMatch()) {
9824 *rmatch = std::move(
match);
9833 return indexOf(haystack,
nullptr, re, from, rmatch);
9843 qsizetype endpos = (from < 0) ? (viewHaystack.
size() + from + 1) : (from + 1);
9851 if (
start < endpos) {
9854 *rmatch = std::move(
match);
9865 return lastIndexOf(haystack,
nullptr, re, from, rmatch);
9875 ? re.
match(*stringHaystack)
9878 if (hasMatch && rmatch)
9879 *rmatch = std::move(
m);
9885 return contains(haystack,
nullptr, re, rmatch);
9899 if (!
match.hasMatch())
9934 else if (
ch == u
'>')
9936 else if (
ch == u
'&')
9938 else if (
ch == u
'"')
9939 rich +=
"""_L1;
9991#if QT_DEPRECATED_SINCE(6, 8)
static Q_CORE_EXPORT int compare(QAnyStringView lhs, QAnyStringView rhs, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Returns an integer that compares to zero as lhs compares to rhs.
static Q_CORE_EXPORT bool equal(QAnyStringView lhs, QAnyStringView rhs) noexcept
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
bool isNull() const noexcept
Returns true if this byte array is null; otherwise returns false.
static constexpr QChar fromUcs2(char16_t c) noexcept
static constexpr bool requiresSurrogates(char32_t ucs4) noexcept
Returns true if the UCS-4-encoded character specified by ucs4 can be split into the high and low part...
int digitValue() const noexcept
Returns the numeric value of the digit, or -1 if the character is not a digit.
Direction direction() const noexcept
Returns the character's direction.
UnicodeVersion
Specifies which version of the \l{Unicode standard} introduced a certain character.
static constexpr char16_t highSurrogate(char32_t ucs4) noexcept
Returns the high surrogate part of a UCS-4-encoded code point.
constexpr char16_t unicode() const noexcept
Returns the numeric Unicode value of the QChar.
QChar toCaseFolded() const noexcept
Returns the case folded equivalent of the character.
static constexpr char16_t lowSurrogate(char32_t ucs4) noexcept
Returns the low surrogate part of a UCS-4-encoded code point.
static UnicodeVersion QT_FASTCALL currentUnicodeVersion() noexcept Q_DECL_CONST_FUNCTION
Returns the most recent supported Unicode version.
static int defaultCompare(QStringView s1, QStringView s2)
\inmodule QtCore\reentrant
constexpr QLatin1Char front() const
int compare(QStringView other, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr qsizetype size() const noexcept
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
QList< T > mid(qsizetype pos, qsizetype len=-1) const
void append(parameter_type t)
@ IncludeTrailingZeroesAfterDot
@ OmitLeadingZeroInExponent
\inmodule QtCore \reentrant
\inmodule QtCore \reentrant
bool hasMatch() const
Returns true if the regular expression matched against the subject string, or false otherwise.
\inmodule QtCore \reentrant
bool isValid() const
Returns true if the regular expression is a valid regular expression (that is, it contains no syntax ...
int captureCount() const
Returns the number of capturing groups inside the pattern string, or -1 if the regular expression is ...
QRegularExpressionMatch matchView(QStringView subjectView, qsizetype offset=0, MatchType matchType=NormalMatch, MatchOptions matchOptions=NoMatchOption) const
QString pattern() const
Returns the pattern string of the regular expression.
QRegularExpressionMatch match(const QString &subject, qsizetype offset=0, MatchType matchType=NormalMatch, MatchOptions matchOptions=NoMatchOption) const
Attempts to match the regular expression against the given subject string, starting at the position o...
QRegularExpressionMatchIterator globalMatchView(QStringView subjectView, qsizetype offset=0, MatchType matchType=NormalMatch, MatchOptions matchOptions=NoMatchOption) const
QRegularExpressionMatchIterator globalMatch(const QString &subject, qsizetype offset=0, MatchType matchType=NormalMatch, MatchOptions matchOptions=NoMatchOption) const
Attempts to perform a global match of the regular expression against the given subject string,...
char32_t next(char32_t invalidAs=QChar::ReplacementCharacter)
Q_CORE_EXPORT double toDouble(bool *ok=nullptr) const
Returns the string view converted to a double value.
Q_CORE_EXPORT float toFloat(bool *ok=nullptr) const
Returns the string view converted to a float value.
constexpr const storage_type * utf16() const noexcept
constexpr qsizetype size() const noexcept
Returns the size of this string view, in UTF-16 code units (that is, surrogate pairs count as two for...
const_pointer data() const noexcept
const_iterator begin() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first character in the st...
Q_CORE_EXPORT QList< QStringView > split(QStringView sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the view into substring views wherever sep occurs, and returns the list of those string views.
constexpr QStringView() noexcept
Constructs a null string view.
constexpr QStringView sliced(qsizetype pos) const noexcept
const_iterator end() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary character after...
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString right(qsizetype n) const
Returns a substring that contains the n rightmost characters of the string.
bool isSimpleText() const
iterator begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first character in the string.
QByteArray toLatin1() const &
QString repeated(qsizetype times) const
double toDouble(bool *ok=nullptr) const
Returns the string converted to a double value.
QString last(qsizetype n) const
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QString & fill(QChar c, qsizetype size=-1)
Sets every character in the string to character ch.
QString & replace(qsizetype i, qsizetype len, QChar after)
void reserve(qsizetype size)
Ensures the string has space for at least size characters.
QString rightJustified(qsizetype width, QChar fill=u' ', bool trunc=false) const
Returns a string of size() width that contains the fill character followed by the string.
void chop(qsizetype n)
Removes n characters from the end of the string.
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
const ushort * utf16() const
Returns the QString as a '\0\'-terminated array of unsigned shorts.
QStringList split(const QString &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the string into substrings wherever sep occurs, and returns the list of those strings.
void truncate(qsizetype pos)
Truncates the string at the given position index.
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString fromUtf16(const char16_t *, qsizetype size=-1)
static QString fromUcs4(const char32_t *, qsizetype size=-1)
void clear()
Clears the contents of the string and makes it null.
const QChar * constData() const
Returns a pointer to the data stored in the QString.
const_iterator cbegin() const
QString & operator=(QChar c)
bool isNull() const
Returns true if this string is null; otherwise returns false.
QString & setUnicode(const QChar *unicode, qsizetype size)
Resizes the string to size characters and copies unicode into the string.
qsizetype size() const
Returns the number of characters in this string.
QList< uint > toUcs4() const
const_iterator cend() const
QStringPrivate DataPointer
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isLower() const
Returns true if the string is lowercase, that is, it's identical to its toLower() folding.
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
@ SectionCaseInsensitiveSeps
@ SectionIncludeLeadingSep
@ SectionIncludeTrailingSep
void swap(QString &other) noexcept
QString section(QChar sep, qsizetype start, qsizetype end=-1, SectionFlags flags=SectionDefault) const
This function returns a section of the string.
static QString fromRawData(const QChar *, qsizetype size)
Constructs a QString that uses the first size Unicode characters in the array unicode.
constexpr QString() noexcept
Constructs a null string.
qsizetype capacity() const
Returns the maximum number of characters that can be stored in the string without forcing a reallocat...
iterator end()
Returns an \l{STL-style iterators}{STL-style iterator} pointing just after the last character in the ...
QString leftJustified(qsizetype width, QChar fill=u' ', bool trunc=false) const
Returns a string of size width that contains this string padded by the fill character.
QString & assign(QAnyStringView s)
bool isUpper() const
Returns true if the string is uppercase, that is, it's identical to its toUpper() folding.
float toFloat(bool *ok=nullptr) const
Returns the string converted to a float value.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
int compare(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QString & insert(qsizetype i, QChar c)
friend qsizetype erase(QString &s, const T &t)
QByteArray toLocal8Bit() const &
QChar * data()
Returns a pointer to the data stored in the QString.
qsizetype count(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static QString vasprintf(const char *format, va_list ap) Q_ATTRIBUTE_FORMAT_PRINTF(1
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & append(QChar c)
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
void squeeze()
Releases any memory not required to store the character data.
static QString static QString qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString & setUtf16(const ushort *utf16, qsizetype size)
Resizes the string to size characters and copies unicode into the string.
int localeAwareCompare(const QString &s) const
bool isRightToLeft() const
Returns true if the string is read right to left.
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & setRawData(const QChar *unicode, qsizetype size)
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
const_iterator constBegin() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first character in the st...
static QString static QString asprintf(const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
QString toHtmlEscaped() const
NormalizationForm
This enum describes the various normalized forms of Unicode text.
qsizetype length() const
Returns the number of characters in this string.
const QChar * unicode() const
Returns a Unicode representation of the string.
QString normalized(NormalizationForm mode, QChar::UnicodeVersion version=QChar::Unicode_Unassigned) const
Returns the string in the given Unicode normalization mode, according to the given version of the Uni...
void resize(qsizetype size)
Sets the size of the string to size characters.
QSet< QString >::iterator it
typename C::iterator iterator
Combined button and popup list for selecting options.
@ NormalizationCorrectionsVersionMax
static QString convertCase(T &str, QUnicodeTables::Case which)
static Q_NEVER_INLINE QString detachAndConvertCase(T &str, QStringIterator it, QUnicodeTables::Case which)
static Q_DECL_CONST_FUNCTION const Properties * qGetProp(char32_t ucs4) noexcept
static constexpr NormalizationCorrection uc_normalization_corrections[]
constexpr bool isAsciiDigit(char32_t c) noexcept
constexpr bool isAsciiUpper(char32_t c) noexcept
constexpr int qt_lencmp(qsizetype lhs, qsizetype rhs) noexcept
constexpr char toAsciiLower(char ch) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QByteArrayView haystack, QByteArrayView needle) noexcept
Q_CORE_EXPORT QString convertToQString(QAnyStringView s)
static constexpr bool q_points_into_range(const T *p, const T *b, const T *e, Cmp less={}) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype qustrlen(const char16_t *str) noexcept
Q_CORE_EXPORT QList< uint > convertToUcs4(QStringView str)
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isValidUtf16(QStringView s) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QByteArrayView trimmed(QByteArrayView s) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QByteArrayView haystack, QByteArrayView needle) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QByteArrayView haystack, qsizetype from, QByteArrayView needle) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype count(QByteArrayView haystack, QByteArrayView needle) noexcept
Q_CORE_EXPORT QByteArray convertToLocal8Bit(QStringView str)
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QStringView lhs, QStringView rhs) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isRightToLeft(QStringView string) noexcept
Q_CORE_EXPORT QByteArray convertToLatin1(QStringView str)
Q_CORE_EXPORT QString argToQString(QStringView pattern, size_t n, const ArgBase **args)
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype qustrnlen(const char16_t *str, qsizetype maxlen) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
qsizetype indexOf(const QList< V > &list, const U &u, qsizetype from) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION const char16_t * qustrchr(QStringView str, char16_t ch) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1StringView s) noexcept
Q_CORE_EXPORT QByteArray convertToUtf8(QStringView str)
constexpr bool isLatin1(QLatin1StringView s) noexcept
constexpr Initialization Uninitialized
QT_POPCOUNT_RELAXED_CONSTEXPR uint qCountLeadingZeroBits(quint32 v) noexcept
constexpr uint qCountTrailingZeroBits(quint32 v) noexcept
static jboolean copy(JNIEnv *, jobject)
size_t qstrlen(const char *str)
size_t qstrnlen(const char *str, size_t maxlen)
static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, qsizetype from)
static auto fullConvertCase(char32_t uc, QUnicodeTables::Case which) noexcept
static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion version, qsizetype from)
static void composeHelper(QString *str, QChar::UnicodeVersion version, qsizetype from)
static bool normalizationQuickCheckHelper(QString *str, QString::NormalizationForm mode, qsizetype from, qsizetype *lastStable)
static char32_t foldCase(const char16_t *ch, const char16_t *start)
#define Q_DECL_COLD_FUNCTION
AudioChannelLayoutTag tag
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
QT_BEGIN_NAMESPACE Q_ALWAYS_INLINE void qToUnaligned(const T src, void *dest)
bool qIsFinite(qfloat16 f) noexcept
static ControlElement< T > * ptr(QWidget *widget)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
GLenum GLuint GLenum GLsizei length
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
GLsizei GLenum const void * indices
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLsizei GLchar * source
GLenum GLenum GLenum input
GLenum GLint GLint * precision
GLsizei const GLchar *const * string
[0]
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
Q_DECL_COLD_FUNCTION void qtWarnAboutInvalidRegularExpression(const QString &pattern, const char *where)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
static constexpr QChar sep
static const uint64_t qCompilerCpuFeatures
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
static QString argToQStringImpl(StringView pattern, size_t numArgs, const QtPrivate::ArgBase **args)
static bool isAscii_helper(const char16_t *&ptr, const char16_t *end)
static Int toIntegral(QStringView string, bool *ok, int base)
void qt_to_latin1(uchar *dst, const char16_t *src, qsizetype length)
static void append_utf8(QString &qs, const char *cs, qsizetype len)
#define ATTRIBUTE_NO_SANITIZE
bool qt_is_ascii(const char *&ptr, const char *end) noexcept
QDataStream & operator<<(QDataStream &out, const QString &str)
static int ucstrcmp(const char16_t *a, size_t alen, const Char2 *b, size_t blen)
static void removeStringImpl(QString &s, const T &needle, Qt::CaseSensitivity cs)
Q_ALWAYS_INLINE QString to_string(QLatin1StringView s) noexcept
static bool needsReallocate(const QString &str, qsizetype newSize)
static void replace_helper(QString &str, size_t *indices, qsizetype nIndices, qsizetype blen, QStringView after)
static int qArgDigitValue(QChar ch) noexcept
static void replace_with_copy(QString &str, size_t *indices, qsizetype nIndices, qsizetype blen, QStringView after)
static int ucstrncmp(const char16_t *a, const char16_t *b, size_t l)
static bool ucstreq(const char16_t *a, size_t alen, const Char2 *b, size_t blen)
static QByteArray qt_convert_to_latin1(QStringView string)
static void replace_in_place(QString &str, size_t *indices, qsizetype nIndices, qsizetype blen, QStringView after)
static QList< uint > qt_convert_to_ucs4(QStringView string)
qsizetype qFindStringBoyerMoore(QStringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs)
static QByteArray qt_convert_to_local_8bit(QStringView string)
static LengthMod parse_length_modifier(const char *&c) noexcept
static ArgEscapeData findArgEscapes(QStringView s)
static QByteArray qt_convert_to_utf8(QStringView str)
static void qt_to_latin1_internal(uchar *dst, const char16_t *src, qsizetype length)
static void insert_helper(QString &str, qsizetype i, const T &toInsert)
static int latin1nicmp(const char *lhsChar, qsizetype lSize, const char *rhsChar, qsizetype rSize)
static QString replaceArgEscapes(QStringView s, const ArgEscapeData &d, qsizetype field_width, QStringView arg, QStringView larg, QChar fillChar)
static QVarLengthArray< char16_t > qt_from_latin1_to_qvla(QLatin1StringView str)
static Q_NEVER_INLINE int ucstricmp8(const char *utf8, const char *utf8end, const QChar *utf16, const QChar *utf16end)
void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar::UnicodeVersion version, qsizetype from)
static uint parse_flag_characters(const char *&c) noexcept
static Q_NEVER_INLINE int ucstricmp(qsizetype alen, const char16_t *a, qsizetype blen, const char16_t *b)
#define CSTR_GREATER_THAN
void qt_to_latin1_unchecked(uchar *dst, const char16_t *src, qsizetype length)
static char16_t to_unicode(const QChar c)
Q_CORE_EXPORT void qt_from_latin1(char16_t *dst, const char *str, size_t size) noexcept
QDataStream & operator>>(QDataStream &in, QString &str)
static int getEscape(const Char *uc, qsizetype *pos, qsizetype len, int maxNumber=999)
static bool can_consume(const char *&c, char ch) noexcept
static int parse_field_width(const char *&c, qsizetype size)
#define qUtf16Printable(string)
QBasicUtf8StringView< false > QUtf8StringView
QStringView qToStringViewIgnoringNull(const QStringLike &s) noexcept
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
unsigned long long quint64
static QString escape(const QString &input)
QT_BEGIN_NAMESPACE typedef uchar * output
Q_CHECK_PTR(a=new int[80])
QTextStream out(stdout)
[7]
static const auto matcher
[0]
qsizetype locale_occurrences
static void appendLatin1To(QLatin1StringView in, QChar *out) noexcept
void detachAndGrow(QArrayData::GrowthPosition where, qsizetype n, const T **data, QArrayDataPointer *old)
bool isShared() const noexcept
qsizetype freeSpaceAtBegin() const noexcept
bool needsDetach() const noexcept
qsizetype allocatedCapacity() noexcept
void setBegin(T *begin) noexcept
qsizetype constAllocatedCapacity() const noexcept
void clear() noexcept(std::is_nothrow_destructible< T >::value)
static QArrayDataPointer allocateGrow(const QArrayDataPointer &from, qsizetype n, QArrayData::GrowthPosition position)
bool isMutable() const noexcept
static Q_NODISCARD_CTOR QArrayDataPointer fromRawData(const char16_t *rawData, qsizetype length) noexcept
\inmodule QtCore \reentrant
constexpr char16_t unicode() const noexcept
Converts a Latin-1 character to an 16-bit-encoded Unicode representation of the character.
static char16_t * convertToUnicode(char16_t *dst, QLatin1StringView in) noexcept
static char * convertFromUnicode(char *out, QStringView in, QStringConverter::State *state) noexcept
static quint64 bytearrayToUnsLongLong(QByteArrayView num, int base, bool *ok)
static float convertDoubleToFloat(double d, bool *ok)
QString doubleToString(double d, int precision=-1, DoubleForm form=DFSignificantDigits, int width=-1, unsigned flags=NoFlags) const
static const QLocaleData * c()
QString longLongToString(qint64 l, int precision=-1, int base=10, int width=-1, unsigned flags=NoFlags) const
static Q_CORE_EXPORT qint64 bytearrayToLongLong(QByteArrayView num, int base, bool *ok)
QString unsLongLongToString(quint64 l, int precision=-1, int base=10, int width=-1, unsigned flags=NoFlags) const
static StringType trimmed_helper(StringType &str)
static void trimmed_helper_positions(const Char *&begin, const Char *&end)
static StringType simplified_helper(StringType &str)
static QPair< QTypedArrayData *, char16_t * > allocate(qsizetype capacity, AllocationOption option=QArrayData::KeepSize)
static QChar * convertToUnicode(QChar *out, QByteArrayView, QStringConverter::State *state, DataEndianness endian)
static Q_CORE_EXPORT QByteArray convertFromUnicode(QStringView in)
static int compareUtf8(QByteArrayView utf8, QStringView utf16, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
static QChar * convertToUnicode(QChar *buffer, QByteArrayView in) noexcept
static auto matcher(char ch)
static int difference(char lhs, char rhs)
void growAppend(const T *b, const T *e)
void copyAppend(const T *b, const T *e)
void erase(T *b, qsizetype n)