60 using DataPointer = QByteArrayData;
62 typedef QTypedArrayData<
char> Data;
65 static const char _empty;
67 friend class ::tst_QByteArray;
69 template <
typename InputIterator>
70 using if_input_iterator = QtPrivate::IfIsInputIterator<InputIterator>;
74 Base64UrlEncoding = 1,
76 KeepTrailingEquals = 0,
77 OmitTrailingEquals = 2,
79 IgnoreBase64DecodingErrors = 0,
80 AbortOnBase64DecodingErrors = 4,
82 Q_DECLARE_FLAGS(Base64Options, Base64Option)
84 enum class Base64DecodingStatus {
91 constexpr QByteArray()
noexcept =
default;
92 QByteArray(
const char *, qsizetype size = -1);
93 QByteArray(qsizetype size,
char c);
94 QByteArray(qsizetype size, Qt::Initialization);
95 explicit QByteArray(QByteArrayView v) : QByteArray(v.data(), v.size()) {}
96 Q_DECL_CONSTEXPR_DTOR QByteArray(
const QByteArray &other)
noexcept : d(other.d) {}
97#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
) && !defined(QT_BOOTSTRAPPED)
98 Q_DECL_CONSTEXPR_DTOR ~QByteArray() =
default;
101 QT_CORE_CONSTEXPR_DTOR_INLINE_SINCE(6, 13)
102 QByteArray &operator=(
const QByteArray &)
noexcept;
103 QByteArray &operator=(
const char *str);
104 Q_DECL_CONSTEXPR_DTOR QByteArray(QByteArray &&other)
noexcept =
default;
105 Q_DECL_CONSTEXPR_DTOR
106 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QByteArray)
107 constexpr void swap(QByteArray &other)
noexcept
110 constexpr bool isEmpty()
const noexcept {
return size() == 0; }
111 void resize(qsizetype size);
112 void resize(qsizetype size,
char c);
113 void resizeForOverwrite(qsizetype size);
115 QByteArray &fill(
char ch);
116 QByteArray &fill(
char c, qsizetype size);
118 inline qsizetype capacity()
const;
119 inline void reserve(qsizetype size);
120 inline void squeeze();
122#ifndef QT_NO_CAST_FROM_BYTEARRAY
123 inline operator
const char *()
const;
124 inline operator
const void *()
const;
131#if (!defined(Q_OS_QNX) || !defined(Q_CC_GNU_ONLY) || Q_CC_GNU_ONLY > 803
) &&
132 (!defined(Q_CC_GHS) || !defined(__GHS_VERSION_NUMBER) || __GHS_VERSION_NUMBER > 202214
)
133# define QT_BYTEARRAY_CONVERTS_TO_STD_STRING_VIEW
134 constexpr Q_IMPLICIT operator std::string_view()
const noexcept
135 {
return std::string_view(data(), std::size_t(size())); }
140 inline const char *data()
const noexcept;
142 const char *constData()
const noexcept {
return data(); }
143 inline void detach();
144 inline bool isDetached()
const;
145 inline bool isSharedWith(
const QByteArray &other)
const noexcept
146 {
return data() == other.data() && size() == other.size(); }
150 inline char at(qsizetype i)
const;
152 inline char operator[](qsizetype i)
const;
153 [[nodiscard]]
inline char &operator[](qsizetype i);
154 [[nodiscard]]
constexpr char front()
const {
return at(0); }
155 [[nodiscard]]
inline char &front();
156 [[nodiscard]]
constexpr char back()
const {
return at(size() - 1); }
157 [[nodiscard]]
inline char &back();
159 QT_CORE_INLINE_SINCE(6, 8)
160 qsizetype indexOf(
char c, qsizetype from = 0)
const;
161 qsizetype indexOf(QByteArrayView bv, qsizetype from = 0)
const
162 {
return QByteArrayView(begin(), size()).indexOf(bv, from); }
164 QT_CORE_INLINE_SINCE(6, 8)
165 qsizetype lastIndexOf(
char c, qsizetype from = -1)
const;
166 qsizetype lastIndexOf(QByteArrayView bv)
const
167 {
return lastIndexOf(bv, size()); }
168 qsizetype lastIndexOf(QByteArrayView bv, qsizetype from)
const
169 {
return QByteArrayView(begin(), size()).lastIndexOf(bv, from); }
171 inline bool contains(
char c)
const;
172 inline bool contains(QByteArrayView bv)
const;
173 qsizetype count(
char c)
const;
174 qsizetype count(QByteArrayView bv)
const
175 {
return QByteArrayView(begin(), size()).count(bv); }
177 inline int compare(QByteArrayView a)
const noexcept;
178 inline int compare(QByteArrayView a, Qt::CaseSensitivity cs)
const noexcept;
180#if QT_CORE_REMOVED_SINCE(6
, 7
)
181 QByteArray left(qsizetype len)
const;
182 QByteArray right(qsizetype len)
const;
183 QByteArray mid(qsizetype index, qsizetype len = -1)
const;
184 QByteArray first(qsizetype n)
const;
185 QByteArray last(qsizetype n)
const;
186 QByteArray sliced(qsizetype pos)
const;
187 QByteArray sliced(qsizetype pos, qsizetype n)
const;
188 QByteArray chopped(qsizetype len)
const;
190 [[nodiscard]] QByteArray left(qsizetype n)
const &
194 return first(qMax(n, 0));
196 [[nodiscard]] QByteArray left(qsizetype n) &&
199 return std::move(*
this);
200 return std::move(*
this).first(qMax(n, 0));
202 [[nodiscard]] QByteArray right(qsizetype n)
const &
206 return last(qMax(n, 0));
208 [[nodiscard]] QByteArray right(qsizetype n) &&
211 return std::move(*
this);
212 return std::move(*
this).last(qMax(n, 0));
214 [[nodiscard]] QByteArray mid(qsizetype index, qsizetype len = -1)
const &;
215 [[nodiscard]] QByteArray mid(qsizetype index, qsizetype len = -1) &&;
217 [[nodiscard]] QByteArray first(qsizetype n)
const &
218 { verify(0, n);
return sliced(0, n); }
219 [[nodiscard]] QByteArray last(qsizetype n)
const &
220 { verify(0, n);
return sliced(size() - n, n); }
221 [[nodiscard]] QByteArray sliced(qsizetype pos)
const &
222 { verify(pos, 0);
return sliced(pos, size() - pos); }
223 [[nodiscard]] QByteArray sliced(qsizetype pos, qsizetype n)
const &
224 { verify(pos, n);
return QByteArray(d.data() + pos, n); }
225 [[nodiscard]] QByteArray chopped(qsizetype len)
const &
226 { verify(0, len);
return sliced(0, size() - len); }
228 [[nodiscard]] QByteArray first(qsizetype n) &&
232 return std::move(*
this);
234 [[nodiscard]] QByteArray last(qsizetype n) &&
235 { verify(0, n);
return sliced_helper(*
this, size() - n, n); }
236 [[nodiscard]] QByteArray sliced(qsizetype pos) &&
237 { verify(pos, 0);
return sliced_helper(*
this, pos, size() - pos); }
238 [[nodiscard]] QByteArray sliced(qsizetype pos, qsizetype n) &&
239 { verify(pos, n);
return sliced_helper(*
this, pos, n); }
240 [[nodiscard]] QByteArray chopped(qsizetype len) &&
241 { verify(0, len); chop(len);
return std::move(*
this); }
244 bool startsWith(QByteArrayView bv)
const
245 {
return QByteArrayView(begin(), size()).startsWith(bv); }
246 bool startsWith(
char c)
const {
return size() > 0 && front() == c; }
248 bool endsWith(
char c)
const {
return size() > 0 && back() == c; }
249 bool endsWith(QByteArrayView bv)
const
250 {
return QByteArrayView(begin(), size()).endsWith(bv); }
252 bool isUpper()
const;
253 bool isLower()
const;
255 [[nodiscard]]
bool isValidUtf8()
const noexcept
257 return QtPrivate::isValidUtf8(qToByteArrayViewIgnoringNull(*
this));
260 void truncate(qsizetype pos);
261 void chop(qsizetype n);
263 QByteArray &slice(qsizetype pos)
264 { verify(pos, 0);
return remove(0, pos); }
265 QByteArray &slice(qsizetype pos, qsizetype n)
271 return remove(0, pos);
275 [[nodiscard]] QByteArray toLower()
const &
276 {
return toLower_helper(*
this); }
277 [[nodiscard]] QByteArray toLower() &&
278 {
return toLower_helper(*
this); }
279 [[nodiscard]] QByteArray toUpper()
const &
280 {
return toUpper_helper(*
this); }
281 [[nodiscard]] QByteArray toUpper() &&
282 {
return toUpper_helper(*
this); }
283 [[nodiscard]] QByteArray trimmed()
const &
284 {
return trimmed_helper(*
this); }
285 [[nodiscard]] QByteArray trimmed() &&
286 {
return trimmed_helper(*
this); }
287 [[nodiscard]] QByteArray simplified()
const &
288 {
return simplified_helper(*
this); }
289 [[nodiscard]] QByteArray simplified() &&
290 {
return simplified_helper(*
this); }
292 [[nodiscard]] QByteArray toLower()
const;
293 [[nodiscard]] QByteArray toUpper()
const;
294 [[nodiscard]] QByteArray trimmed()
const;
295 [[nodiscard]] QByteArray simplified()
const;
298 [[nodiscard]] QByteArray leftJustified(qsizetype width,
char fill =
' ',
bool truncate =
false)
const;
299 [[nodiscard]] QByteArray rightJustified(qsizetype width,
char fill =
' ',
bool truncate =
false)
const;
301 QByteArray &prepend(
char c)
302 {
return insert(0, QByteArrayView(&c, 1)); }
303 inline QByteArray &prepend(qsizetype count,
char c);
304 QByteArray &prepend(
const char *s)
305 {
return insert(0, QByteArrayView(s, qsizetype(qstrlen(s)))); }
306 QByteArray &prepend(
const char *s, qsizetype len)
307 {
return insert(0, QByteArrayView(s, len)); }
308 QByteArray &prepend(
const QByteArray &a);
309 QByteArray &prepend(QByteArrayView a)
310 {
return insert(0, a); }
312 QByteArray &append(
char c);
313 inline QByteArray &append(qsizetype count,
char c);
314 QByteArray &append(
const char *s)
315 {
return append(s, -1); }
316 QByteArray &append(
const char *s, qsizetype len)
317 {
return append(QByteArrayView(s, len < 0 ? qsizetype(qstrlen(s)) : len)); }
318 QByteArray &append(
const QByteArray &a);
319 QByteArray &append(QByteArrayView a)
320 {
return insert(size(), a); }
322 QByteArray &assign(QByteArrayView v);
323 QByteArray &assign(qsizetype n,
char c)
326 resizeForOverwrite(n);
329 template <
typename InputIterator, if_input_iterator<InputIterator> =
true>
330 QByteArray &assign(InputIterator first, InputIterator last)
332 if constexpr (QtPrivate::IsCompatibleByteArrayPointer<InputIterator>::value) {
333 return assign(QByteArrayView(first, last));
335 d->assign(first, last);
337 d.data()[d.size] =
'\0';
342 QByteArray &insert(qsizetype i, QByteArrayView data);
343 inline QByteArray &insert(qsizetype i,
const char *s)
344 {
return insert(i, QByteArrayView(s)); }
345 inline QByteArray &insert(qsizetype i,
const QByteArray &data)
346 {
return insert(i, QByteArrayView(data)); }
347 QByteArray &insert(qsizetype i, qsizetype count,
char c);
348 QByteArray &insert(qsizetype i,
char c)
349 {
return insert(i, QByteArrayView(&c, 1)); }
350 QByteArray &insert(qsizetype i,
const char *s, qsizetype len)
351 {
return insert(i, QByteArrayView(s, len)); }
353 QByteArray &remove(qsizetype index, qsizetype len);
354 QByteArray &removeAt(qsizetype pos)
355 {
return size_t(pos) < size_t(size()) ? remove(pos, 1) : *
this; }
356 QByteArray &removeFirst() {
return !isEmpty() ? remove(0, 1) : *
this; }
357 QByteArray &removeLast() {
return !isEmpty() ? remove(size() - 1, 1) : *
this; }
359 template <
typename Predicate>
360 QByteArray &removeIf(Predicate pred)
362 removeIf_helper(pred);
366 QByteArray &replace(qsizetype index, qsizetype len,
const char *s, qsizetype alen)
367 {
return replace(index, len, QByteArrayView(s, alen)); }
368 QByteArray &replace(qsizetype index, qsizetype len, QByteArrayView s);
369 QByteArray &replace(
char before, QByteArrayView after)
370 {
return replace(QByteArrayView(&before, 1), after); }
371 QByteArray &replace(
const char *before, qsizetype bsize,
const char *after, qsizetype asize)
372 {
return replace(QByteArrayView(before, bsize), QByteArrayView(after, asize)); }
373 QByteArray &replace(QByteArrayView before, QByteArrayView after);
374 QByteArray &replace(
char before,
char after);
376 QByteArray &operator+=(
char c)
377 {
return append(c); }
378 QByteArray &operator+=(
const char *s)
379 {
return append(s); }
380 QByteArray &operator+=(
const QByteArray &a)
381 {
return append(a); }
382 QByteArray &operator+=(QByteArrayView a)
383 {
return append(a); }
385 QList<QByteArray> split(
char sep)
const;
387 [[nodiscard]] QByteArray repeated(qsizetype times)
const;
389#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
390#if QT_CORE_REMOVED_SINCE(6
, 8
)
391 QT_ASCII_CAST_WARN
inline bool operator==(
const QString &s2)
const;
392 QT_ASCII_CAST_WARN
inline bool operator!=(
const QString &s2)
const;
393 QT_ASCII_CAST_WARN
inline bool operator<(
const QString &s2)
const;
394 QT_ASCII_CAST_WARN
inline bool operator>(
const QString &s2)
const;
395 QT_ASCII_CAST_WARN
inline bool operator<=(
const QString &s2)
const;
396 QT_ASCII_CAST_WARN
inline bool operator>=(
const QString &s2)
const;
400 short toShort(
bool *ok =
nullptr,
int base = 10)
const;
401 ushort toUShort(
bool *ok =
nullptr,
int base = 10)
const;
402 int toInt(
bool *ok =
nullptr,
int base = 10)
const;
403 uint toUInt(
bool *ok =
nullptr,
int base = 10)
const;
404 long toLong(
bool *ok =
nullptr,
int base = 10)
const;
405 ulong toULong(
bool *ok =
nullptr,
int base = 10)
const;
406 qlonglong toLongLong(
bool *ok =
nullptr,
int base = 10)
const;
407 qulonglong toULongLong(
bool *ok =
nullptr,
int base = 10)
const;
408 float toFloat(
bool *ok =
nullptr)
const;
409 double toDouble(
bool *ok =
nullptr)
const;
410 QByteArray toBase64(Base64Options options = Base64Encoding)
const;
411 QByteArray toHex(
char separator =
'\0')
const;
412 QByteArray toPercentEncoding(
const QByteArray &exclude = QByteArray(),
413 const QByteArray &include = QByteArray(),
414 char percent =
'%')
const;
415#if QT_CORE_REMOVED_SINCE(6
, 11
)
416 [[nodiscard]] QByteArray percentDecoded(
char percent =
'%')
const;
418 [[nodiscard]] QByteArray percentDecoded(
char percent =
'%')
const &
419 {
return fromPercentEncoding(*
this, percent); }
420 [[nodiscard]] QByteArray percentDecoded(
char percent =
'%') &&
421 {
return fromPercentEncoding(std::move(*
this), percent); }
424 inline QByteArray &setNum(
short,
int base = 10);
425 inline QByteArray &setNum(ushort,
int base = 10);
426 inline QByteArray &setNum(
int,
int base = 10);
427 inline QByteArray &setNum(uint,
int base = 10);
428 inline QByteArray &setNum(
long,
int base = 10);
429 inline QByteArray &setNum(ulong,
int base = 10);
430 QByteArray &setNum(qlonglong,
int base = 10);
431 QByteArray &setNum(qulonglong,
int base = 10);
432 inline QByteArray &setNum(
float,
char format =
'g',
int precision = 6);
433 QByteArray &setNum(
double,
char format =
'g',
int precision = 6);
434 QByteArray &setRawData(
const char *a, qsizetype n);
436 [[nodiscard]]
static QByteArray number(
int,
int base = 10);
437 [[nodiscard]]
static QByteArray number(uint,
int base = 10);
438 [[nodiscard]]
static QByteArray number(
long,
int base = 10);
439 [[nodiscard]]
static QByteArray number(ulong,
int base = 10);
440 [[nodiscard]]
static QByteArray number(qlonglong,
int base = 10);
441 [[nodiscard]]
static QByteArray number(qulonglong,
int base = 10);
442 [[nodiscard]]
static QByteArray number(
double,
char format =
'g',
int precision = 6);
443 [[nodiscard]]
static QByteArray fromRawData(
const char *data, qsizetype size)
445 return QByteArray(DataPointer::fromRawData(data, size));
448 class FromBase64Result;
449 [[nodiscard]]
static FromBase64Result fromBase64Encoding(QByteArray &&base64, Base64Options options = Base64Encoding);
450 [[nodiscard]]
static FromBase64Result fromBase64Encoding(
const QByteArray &base64, Base64Options options = Base64Encoding);
451 [[nodiscard]]
static QByteArray fromBase64(
const QByteArray &base64, Base64Options options = Base64Encoding);
452 [[nodiscard]]
static QByteArray fromHex(
const QByteArray &hexEncoded);
453 [[nodiscard]]
static QByteArray fromPercentEncoding(
const QByteArray &pctEncoded,
char percent =
'%');
454 [[nodiscard]]
static QByteArray fromPercentEncoding(QByteArray &&pctEncoded,
char percent =
'%');
456#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
457 static QByteArray fromCFData(CFDataRef data);
458 static QByteArray fromRawCFData(CFDataRef data);
459 CFDataRef toCFData()
const Q_DECL_CF_RETURNS_RETAINED;
460 CFDataRef toRawCFData()
const Q_DECL_CF_RETURNS_RETAINED;
461 static QByteArray fromNSData(
const NSData *data);
462 static QByteArray fromRawNSData(
const NSData *data);
463 NSData *toNSData()
const Q_DECL_NS_RETURNS_AUTORELEASED;
464 NSData *toRawNSData()
const Q_DECL_NS_RETURNS_AUTORELEASED;
467#if defined(Q_OS_WASM) || defined(Q_QDOC)
468 static QByteArray fromEcmaUint8Array(emscripten::val uint8array);
469 emscripten::val toEcmaUint8Array();
472 typedef char *iterator;
473 typedef const char *const_iterator;
474 typedef iterator Iterator;
475 typedef const_iterator ConstIterator;
476 typedef std::reverse_iterator<iterator> reverse_iterator;
477 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
478 iterator begin() {
return data(); }
480 const_iterator begin()
const noexcept {
return d.data(); }
482 const_iterator cbegin()
const noexcept {
return begin(); }
484 const_iterator constBegin()
const noexcept {
return begin(); }
485 iterator end() {
return begin() + size(); }
487 const_iterator end()
const noexcept {
return begin() + size(); }
489 const_iterator cend()
const noexcept {
return end(); }
491 const_iterator constEnd()
const noexcept {
return end(); }
492 reverse_iterator rbegin() {
return reverse_iterator(end()); }
493 reverse_iterator rend() {
return reverse_iterator(begin()); }
495 const_reverse_iterator rbegin()
const noexcept {
return const_reverse_iterator(end()); }
497 const_reverse_iterator rend()
const noexcept {
return const_reverse_iterator(begin()); }
499 const_reverse_iterator crbegin()
const noexcept {
return rbegin(); }
501 const_reverse_iterator crend()
const noexcept {
return rend(); }
504 typedef qsizetype size_type;
505 typedef qptrdiff difference_type;
506 typedef const char & const_reference;
507 typedef char & reference;
508 typedef char *pointer;
509 typedef const char *const_pointer;
510 typedef char value_type;
511 void push_back(
char c)
513 void push_back(
const char *s)
515 void push_back(
const QByteArray &a)
517 void push_back(QByteArrayView a)
519 void push_front(
char c)
521 void push_front(
const char *c)
523 void push_front(
const QByteArray &a)
525 void push_front(QByteArrayView a)
527 void shrink_to_fit() { squeeze(); }
528 iterator erase(const_iterator first, const_iterator last);
529 inline iterator erase(const_iterator it) {
return erase(it, it + 1); }
530 constexpr qsizetype max_size()
const noexcept
535 static QByteArray fromStdString(
const std::string &s);
536 std::string toStdString()
const;
538 static constexpr qsizetype maxSize()
noexcept
541 return Data::maxSize() - 1;
543 constexpr qsizetype size()
const noexcept
545 constexpr size_t MaxSize = maxSize();
546 Q_PRESUME(size_t(d.size) <= MaxSize);
549#if QT_DEPRECATED_SINCE(6
, 4
)
550 QT_DEPRECATED_VERSION_X_6_4(
"Use size() or length() instead.")
551 constexpr qsizetype count()
const noexcept {
return size(); }
553 constexpr qsizetype length()
const noexcept {
return size(); }
554 QT_CORE_CONSTEXPR_INLINE_SINCE(6, 4)
555 bool isNull()
const noexcept;
557 inline const DataPointer &data_ptr()
const {
return d; }
558 inline DataPointer &data_ptr() {
return d; }
559#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
560 explicit inline QByteArray(
const DataPointer &dd) : d(dd) {}
562 explicit Q_DECL_CONSTEXPR_DTOR QByteArray(DataPointer &&dd) : d(std::move(dd)) {}
564 [[nodiscard]] QByteArray nullTerminated()
const &;
565 [[nodiscard]] QByteArray nullTerminated() &&;
566 QByteArray &nullTerminate();
569 friend bool comparesEqual(
const QByteArray &lhs,
char rhs)
noexcept
570 {
return QByteArrayView(lhs) == rhs; }
571 friend bool comparesEqual(
const QByteArray &lhs,
const QByteArrayView &rhs)
noexcept
572 {
return QByteArrayView(lhs) == rhs; }
573 friend Qt::strong_ordering
574 compareThreeWay(
const QByteArray &lhs,
char rhs)
noexcept
576 return compareThreeWay(QByteArrayView(lhs), rhs);
578 friend Qt::strong_ordering
579 compareThreeWay(
const QByteArray &lhs,
const QByteArrayView &rhs)
noexcept
581 const int res = QtPrivate::compareMemory(QByteArrayView(lhs), rhs);
582 return Qt::compareThreeWay(res, 0);
584 Q_DECLARE_STRONGLY_ORDERED(QByteArray)
585 Q_DECLARE_STRONGLY_ORDERED(QByteArray,
char)
586 Q_DECLARE_STRONGLY_ORDERED(QByteArray,
const char *)
587#if defined(__GLIBCXX__
) && defined(__cpp_lib_three_way_comparison)
592 friend bool operator<(
const QByteArray &lhs,
const QByteArray &rhs)
noexcept
593 {
return is_lt(compareThreeWay(lhs, rhs)); }
594 friend bool operator<=(
const QByteArray &lhs,
const QByteArray &rhs)
noexcept
595 {
return is_lteq(compareThreeWay(lhs, rhs)); }
596 friend bool operator>(
const QByteArray &lhs,
const QByteArray &rhs)
noexcept
597 {
return is_gt(compareThreeWay(lhs, rhs)); }
598 friend bool operator>=(
const QByteArray &lhs,
const QByteArray &rhs)
noexcept
599 {
return is_gteq(compareThreeWay(lhs, rhs)); }
603 friend bool comparesEqual(
const QByteArray &lhs, std::nullptr_t)
noexcept
604 {
return lhs.isEmpty(); }
605 friend Qt::strong_ordering compareThreeWay(
const QByteArray &lhs, std::nullptr_t)
noexcept
606 {
return lhs.isEmpty() ? Qt::strong_ordering::equivalent : Qt::strong_ordering::greater; }
607 Q_DECLARE_STRONGLY_ORDERED(QByteArray, std::nullptr_t)
610 friend Q_CORE_EXPORT
bool comparesEqual(
const QByteArray &lhs,
const QChar &rhs)
noexcept;
611 friend Q_CORE_EXPORT Qt::strong_ordering
612 compareThreeWay(
const QByteArray &lhs,
const QChar &rhs)
noexcept;
613 friend Q_CORE_EXPORT
bool comparesEqual(
const QByteArray &lhs,
char16_t rhs)
noexcept;
614 friend Q_CORE_EXPORT Qt::strong_ordering
615 compareThreeWay(
const QByteArray &lhs,
char16_t rhs)
noexcept;
616#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
617 Q_DECLARE_STRONGLY_ORDERED(QByteArray, QChar, QT_ASCII_CAST_WARN)
618 Q_DECLARE_STRONGLY_ORDERED(QByteArray,
char16_t, QT_ASCII_CAST_WARN)
622 void reallocData(qsizetype alloc, QArrayData::AllocationOption option);
623 void reallocGrowData(qsizetype n);
624 void expand(qsizetype i);
626 Q_ALWAYS_INLINE
constexpr void verify([[maybe_unused]] qsizetype pos = 0,
627 [[maybe_unused]] qsizetype n = 1)
const
630 Q_ASSERT(pos <= d.size);
632 Q_ASSERT(n <= d.size - pos);
635 static QByteArray sliced_helper(QByteArray &a, qsizetype pos, qsizetype n);
636 static QByteArray toLower_helper(
const QByteArray &a);
637 static QByteArray toLower_helper(QByteArray &a);
638 static QByteArray toUpper_helper(
const QByteArray &a);
639 static QByteArray toUpper_helper(QByteArray &a);
640 static QByteArray trimmed_helper(
const QByteArray &a);
641 static QByteArray trimmed_helper(QByteArray &a);
642 static QByteArray simplified_helper(
const QByteArray &a);
643 static QByteArray simplified_helper(QByteArray &a);
644 template <
typename Predicate>
645 qsizetype removeIf_helper(Predicate pred)
647 const qsizetype result = d->eraseIf(pred);
649 d.data()[d.size] =
'\0';
653 friend class QString;
654 friend Q_CORE_EXPORT QByteArray qUncompress(
const uchar *data, qsizetype nbytes);
656 template <
typename T>
friend qsizetype erase(QByteArray &ba,
const T &t);
657 template <
typename Predicate>
friend qsizetype erase_if(QByteArray &ba, Predicate pred);