5 #if __has_include(<bit>) // C++20
13 #if defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L
23 static constexpr std::array<uint8_t,256> leading_ones =
25 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
26 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
27 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
28 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
30 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
31 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
32 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
34 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
35 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
36 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
37 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
38 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
39 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
40 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
41 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8,
43 return leading_ones[x];
45 #endif // C++20 feature test macro
49 const auto*
p = (
const unsigned char*)data.data();
50 const unsigned char*
const end =
p + data.size();
55 switch (code_point_length)
57 case 0:
p++;
continue;
62 default:
return false;
68 if (end < code_point_length +
p)
74 switch (code_point_length)
98 switch (code_point_length)
102 if (*
p == 0xC0 || *
p == 0xC1)
110 if (
p[0] == 0xED &&
p[1] >= 0xA0)
115 if (
p[0] == 0xE0 &&
p[1] < 0xA0)
124 if (*
p > 0xF4 || (
p[0] == 0xF4 &&
p[1] >= 0x90))
129 if (
p[0] == 0xF0 &&
p[1] < 0x90)
137 p += code_point_length;
165 if (caseSensitivity == Qt::CaseSensitive)
176 const QChar* currA = a.unicode();
177 const QChar* currB = b.unicode();
184 while (!currA->isNull() && !currB->isNull())
186 const QChar* begSeqA = currA;
187 const QChar* begSeqB = currB;
189 if (currA->unicode() == QChar::ObjectReplacementCharacter)
194 if (currB->unicode() == QChar::ObjectReplacementCharacter)
199 if (currA->unicode() == QChar::ReplacementCharacter)
204 if (currB->unicode() == QChar::ReplacementCharacter)
210 while (!currA->isNull() && !currA->isDigit() && !currA->isPunct() &&
216 while (!currB->isNull() && !currB->isDigit() && !currB->isPunct() &&
223 const QString& subA(a.mid(begSeqA - a.unicode(), currA - begSeqA));
224 const QString& subB(b.mid(begSeqB - b.unicode(), currB - begSeqB));
225 int cmp = QString::localeAwareCompare(subA, subB);
229 return cmp < 0 ? -1 : +1;
232 if (currA->isNull() || currB->isNull())
238 while ((currA->isPunct() || currA->isSpace()) &&
239 (currB->isPunct() || currB->isSpace()))
248 if (currA->isNull() || currB->isNull())
255 if ((*currA == QLatin1Char(
'0')) || (*currB == QLatin1Char(
'0')))
261 if (!currA->isDigit() && !currB->isDigit())
265 if (!currA->isDigit())
269 if (!currB->isDigit())
294 bool isFirstRun =
true;
299 if (!currA->isDigit() && !currB->isDigit())
307 if (!currA->isDigit())
311 return *currA < *currB ? -1 : +1;
315 if (!currB->isDigit())
319 return *currA < *currB ? -1 : +1;
323 if ((*currA < *currB) && (weight == 0))
327 else if ((*currA > *currB) && (weight == 0))
338 if (currA->isNull() && currB->isNull())
343 return currA->isNull() ? -1 : + 1;
362 return QObject::tr(
"%1 TB").arg(sizeTB, 0,
'f', (sizeTB>10)?0:precision);
367 return QObject::tr(
"%1 GB").arg(sizeGB, 0,
'f', (sizeGB>10)?0:precision);
372 return QObject::tr(
"%1 MB").arg(sizeMB, 0,
'f', (sizeMB>10)?0:precision);
375 return QObject::tr(
"%1 KB").arg(sizeKB);
382 return QString(
"%1 B").arg(sizeB);