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 c, qsizetype size = -1);
117 inline qsizetype capacity()
const;
118 inline void reserve(qsizetype size);
119 inline void squeeze();
121#ifndef QT_NO_CAST_FROM_BYTEARRAY
122 inline operator
const char *()
const;
123 inline operator
const void *()
const;
130#if (!defined(Q_OS_QNX) || !defined(Q_CC_GNU_ONLY) || Q_CC_GNU_ONLY > 803
) &&
131 (!defined(Q_CC_GHS) || !defined(__GHS_VERSION_NUMBER) || __GHS_VERSION_NUMBER > 202214
)
132# define QT_BYTEARRAY_CONVERTS_TO_STD_STRING_VIEW
133 constexpr Q_IMPLICIT operator std::string_view()
const noexcept
134 {
return std::string_view(data(), std::size_t(size())); }
139 inline const char *data()
const noexcept;
141 const char *constData()
const noexcept {
return data(); }
142 inline void detach();
143 inline bool isDetached()
const;
144 inline bool isSharedWith(
const QByteArray &other)
const noexcept
145 {
return data() == other.data() && size() == other.size(); }
149 inline char at(qsizetype i)
const;
151 inline char operator[](qsizetype i)
const;
152 [[nodiscard]]
inline char &operator[](qsizetype i);
153 [[nodiscard]]
constexpr char front()
const {
return at(0); }
154 [[nodiscard]]
inline char &front();
155 [[nodiscard]]
constexpr char back()
const {
return at(size() - 1); }
156 [[nodiscard]]
inline char &back();
158 QT_CORE_INLINE_SINCE(6, 8)
159 qsizetype indexOf(
char c, qsizetype from = 0)
const;
160 qsizetype indexOf(QByteArrayView bv, qsizetype from = 0)
const
161 {
return QByteArrayView(begin(), size()).indexOf(bv, from); }
163 QT_CORE_INLINE_SINCE(6, 8)
164 qsizetype lastIndexOf(
char c, qsizetype from = -1)
const;
165 qsizetype lastIndexOf(QByteArrayView bv)
const
166 {
return lastIndexOf(bv, size()); }
167 qsizetype lastIndexOf(QByteArrayView bv, qsizetype from)
const
168 {
return QByteArrayView(begin(), size()).lastIndexOf(bv, from); }
170 inline bool contains(
char c)
const;
171 inline bool contains(QByteArrayView bv)
const;
172 qsizetype count(
char c)
const;
173 qsizetype count(QByteArrayView bv)
const
174 {
return QByteArrayView(begin(), size()).count(bv); }
176 inline int compare(QByteArrayView a)
const noexcept;
177 inline int compare(QByteArrayView a, Qt::CaseSensitivity cs)
const noexcept;
179#if QT_CORE_REMOVED_SINCE(6
, 7
)
180 QByteArray left(qsizetype len)
const;
181 QByteArray right(qsizetype len)
const;
182 QByteArray mid(qsizetype index, qsizetype len = -1)
const;
183 QByteArray first(qsizetype n)
const;
184 QByteArray last(qsizetype n)
const;
185 QByteArray sliced(qsizetype pos)
const;
186 QByteArray sliced(qsizetype pos, qsizetype n)
const;
187 QByteArray chopped(qsizetype len)
const;
189 [[nodiscard]] QByteArray left(qsizetype n)
const &
193 return first(qMax(n, 0));
195 [[nodiscard]] QByteArray left(qsizetype n) &&
198 return std::move(*
this);
199 return std::move(*
this).first(qMax(n, 0));
201 [[nodiscard]] QByteArray right(qsizetype n)
const &
205 return last(qMax(n, 0));
207 [[nodiscard]] QByteArray right(qsizetype n) &&
210 return std::move(*
this);
211 return std::move(*
this).last(qMax(n, 0));
213 [[nodiscard]] QByteArray mid(qsizetype index, qsizetype len = -1)
const &;
214 [[nodiscard]] QByteArray mid(qsizetype index, qsizetype len = -1) &&;
216 [[nodiscard]] QByteArray first(qsizetype n)
const &
217 { verify(0, n);
return sliced(0, n); }
218 [[nodiscard]] QByteArray last(qsizetype n)
const &
219 { verify(0, n);
return sliced(size() - n, n); }
220 [[nodiscard]] QByteArray sliced(qsizetype pos)
const &
221 { verify(pos, 0);
return sliced(pos, size() - pos); }
222 [[nodiscard]] QByteArray sliced(qsizetype pos, qsizetype n)
const &
223 { verify(pos, n);
return QByteArray(d.data() + pos, n); }
224 [[nodiscard]] QByteArray chopped(qsizetype len)
const &
225 { verify(0, len);
return sliced(0, size() - len); }
227 [[nodiscard]] QByteArray first(qsizetype n) &&
231 return std::move(*
this);
233 [[nodiscard]] QByteArray last(qsizetype n) &&
234 { verify(0, n);
return sliced_helper(*
this, size() - n, n); }
235 [[nodiscard]] QByteArray sliced(qsizetype pos) &&
236 { verify(pos, 0);
return sliced_helper(*
this, pos, size() - pos); }
237 [[nodiscard]] QByteArray sliced(qsizetype pos, qsizetype n) &&
238 { verify(pos, n);
return sliced_helper(*
this, pos, n); }
239 [[nodiscard]] QByteArray chopped(qsizetype len) &&
240 { verify(0, len); chop(len);
return std::move(*
this); }
243 bool startsWith(QByteArrayView bv)
const
244 {
return QByteArrayView(begin(), size()).startsWith(bv); }
245 bool startsWith(
char c)
const {
return size() > 0 && front() == c; }
247 bool endsWith(
char c)
const {
return size() > 0 && back() == c; }
248 bool endsWith(QByteArrayView bv)
const
249 {
return QByteArrayView(begin(), size()).endsWith(bv); }
251 bool isUpper()
const;
252 bool isLower()
const;
254 [[nodiscard]]
bool isValidUtf8()
const noexcept
256 return QtPrivate::isValidUtf8(qToByteArrayViewIgnoringNull(*
this));
259 void truncate(qsizetype pos);
260 void chop(qsizetype n);
262 QByteArray &slice(qsizetype pos)
263 { verify(pos, 0);
return remove(0, pos); }
264 QByteArray &slice(qsizetype pos, qsizetype n)
270 return remove(0, pos);
274 [[nodiscard]] QByteArray toLower()
const &
275 {
return toLower_helper(*
this); }
276 [[nodiscard]] QByteArray toLower() &&
277 {
return toLower_helper(*
this); }
278 [[nodiscard]] QByteArray toUpper()
const &
279 {
return toUpper_helper(*
this); }
280 [[nodiscard]] QByteArray toUpper() &&
281 {
return toUpper_helper(*
this); }
282 [[nodiscard]] QByteArray trimmed()
const &
283 {
return trimmed_helper(*
this); }
284 [[nodiscard]] QByteArray trimmed() &&
285 {
return trimmed_helper(*
this); }
286 [[nodiscard]] QByteArray simplified()
const &
287 {
return simplified_helper(*
this); }
288 [[nodiscard]] QByteArray simplified() &&
289 {
return simplified_helper(*
this); }
291 [[nodiscard]] QByteArray toLower()
const;
292 [[nodiscard]] QByteArray toUpper()
const;
293 [[nodiscard]] QByteArray trimmed()
const;
294 [[nodiscard]] QByteArray simplified()
const;
297 [[nodiscard]] QByteArray leftJustified(qsizetype width,
char fill =
' ',
bool truncate =
false)
const;
298 [[nodiscard]] QByteArray rightJustified(qsizetype width,
char fill =
' ',
bool truncate =
false)
const;
300 QByteArray &prepend(
char c)
301 {
return insert(0, QByteArrayView(&c, 1)); }
302 inline QByteArray &prepend(qsizetype count,
char c);
303 QByteArray &prepend(
const char *s)
304 {
return insert(0, QByteArrayView(s, qsizetype(qstrlen(s)))); }
305 QByteArray &prepend(
const char *s, qsizetype len)
306 {
return insert(0, QByteArrayView(s, len)); }
307 QByteArray &prepend(
const QByteArray &a);
308 QByteArray &prepend(QByteArrayView a)
309 {
return insert(0, a); }
311 QByteArray &append(
char c);
312 inline QByteArray &append(qsizetype count,
char c);
313 QByteArray &append(
const char *s)
314 {
return append(s, -1); }
315 QByteArray &append(
const char *s, qsizetype len)
316 {
return append(QByteArrayView(s, len < 0 ? qsizetype(qstrlen(s)) : len)); }
317 QByteArray &append(
const QByteArray &a);
318 QByteArray &append(QByteArrayView a)
319 {
return insert(size(), a); }
321 QByteArray &assign(QByteArrayView v);
322 QByteArray &assign(qsizetype n,
char c)
327 template <
typename InputIterator, if_input_iterator<InputIterator> =
true>
328 QByteArray &assign(InputIterator first, InputIterator last)
330 if constexpr (std::is_same_v<InputIterator, iterator> || std::is_same_v<InputIterator, const_iterator>)
331 return assign(QByteArrayView(first, last));
332 d->assign(first, last);
334 d.data()[d.size] =
'\0';
338 QByteArray &insert(qsizetype i, QByteArrayView data);
339 inline QByteArray &insert(qsizetype i,
const char *s)
340 {
return insert(i, QByteArrayView(s)); }
341 inline QByteArray &insert(qsizetype i,
const QByteArray &data)
342 {
return insert(i, QByteArrayView(data)); }
343 QByteArray &insert(qsizetype i, qsizetype count,
char c);
344 QByteArray &insert(qsizetype i,
char c)
345 {
return insert(i, QByteArrayView(&c, 1)); }
346 QByteArray &insert(qsizetype i,
const char *s, qsizetype len)
347 {
return insert(i, QByteArrayView(s, len)); }
349 QByteArray &remove(qsizetype index, qsizetype len);
350 QByteArray &removeAt(qsizetype pos)
351 {
return size_t(pos) < size_t(size()) ? remove(pos, 1) : *
this; }
352 QByteArray &removeFirst() {
return !isEmpty() ? remove(0, 1) : *
this; }
353 QByteArray &removeLast() {
return !isEmpty() ? remove(size() - 1, 1) : *
this; }
355 template <
typename Predicate>
356 QByteArray &removeIf(Predicate pred)
358 removeIf_helper(pred);
362 QByteArray &replace(qsizetype index, qsizetype len,
const char *s, qsizetype alen)
363 {
return replace(index, len, QByteArrayView(s, alen)); }
364 QByteArray &replace(qsizetype index, qsizetype len, QByteArrayView s);
365 QByteArray &replace(
char before, QByteArrayView after)
366 {
return replace(QByteArrayView(&before, 1), after); }
367 QByteArray &replace(
const char *before, qsizetype bsize,
const char *after, qsizetype asize)
368 {
return replace(QByteArrayView(before, bsize), QByteArrayView(after, asize)); }
369 QByteArray &replace(QByteArrayView before, QByteArrayView after);
370 QByteArray &replace(
char before,
char after);
372 QByteArray &operator+=(
char c)
373 {
return append(c); }
374 QByteArray &operator+=(
const char *s)
375 {
return append(s); }
376 QByteArray &operator+=(
const QByteArray &a)
377 {
return append(a); }
378 QByteArray &operator+=(QByteArrayView a)
379 {
return append(a); }
381 QList<QByteArray> split(
char sep)
const;
383 [[nodiscard]] QByteArray repeated(qsizetype times)
const;
385#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
386#if QT_CORE_REMOVED_SINCE(6
, 8
)
387 QT_ASCII_CAST_WARN
inline bool operator==(
const QString &s2)
const;
388 QT_ASCII_CAST_WARN
inline bool operator!=(
const QString &s2)
const;
389 QT_ASCII_CAST_WARN
inline bool operator<(
const QString &s2)
const;
390 QT_ASCII_CAST_WARN
inline bool operator>(
const QString &s2)
const;
391 QT_ASCII_CAST_WARN
inline bool operator<=(
const QString &s2)
const;
392 QT_ASCII_CAST_WARN
inline bool operator>=(
const QString &s2)
const;
396 short toShort(
bool *ok =
nullptr,
int base = 10)
const;
397 ushort toUShort(
bool *ok =
nullptr,
int base = 10)
const;
398 int toInt(
bool *ok =
nullptr,
int base = 10)
const;
399 uint toUInt(
bool *ok =
nullptr,
int base = 10)
const;
400 long toLong(
bool *ok =
nullptr,
int base = 10)
const;
401 ulong toULong(
bool *ok =
nullptr,
int base = 10)
const;
402 qlonglong toLongLong(
bool *ok =
nullptr,
int base = 10)
const;
403 qulonglong toULongLong(
bool *ok =
nullptr,
int base = 10)
const;
404 float toFloat(
bool *ok =
nullptr)
const;
405 double toDouble(
bool *ok =
nullptr)
const;
406 QByteArray toBase64(Base64Options options = Base64Encoding)
const;
407 QByteArray toHex(
char separator =
'\0')
const;
408 QByteArray toPercentEncoding(
const QByteArray &exclude = QByteArray(),
409 const QByteArray &include = QByteArray(),
410 char percent =
'%')
const;
411#if QT_CORE_REMOVED_SINCE(6
, 11
)
412 [[nodiscard]] QByteArray percentDecoded(
char percent =
'%')
const;
414 [[nodiscard]] QByteArray percentDecoded(
char percent =
'%')
const &
415 {
return fromPercentEncoding(*
this, percent); }
416 [[nodiscard]] QByteArray percentDecoded(
char percent =
'%') &&
417 {
return fromPercentEncoding(std::move(*
this), percent); }
420 inline QByteArray &setNum(
short,
int base = 10);
421 inline QByteArray &setNum(ushort,
int base = 10);
422 inline QByteArray &setNum(
int,
int base = 10);
423 inline QByteArray &setNum(uint,
int base = 10);
424 inline QByteArray &setNum(
long,
int base = 10);
425 inline QByteArray &setNum(ulong,
int base = 10);
426 QByteArray &setNum(qlonglong,
int base = 10);
427 QByteArray &setNum(qulonglong,
int base = 10);
428 inline QByteArray &setNum(
float,
char format =
'g',
int precision = 6);
429 QByteArray &setNum(
double,
char format =
'g',
int precision = 6);
430 QByteArray &setRawData(
const char *a, qsizetype n);
432 [[nodiscard]]
static QByteArray number(
int,
int base = 10);
433 [[nodiscard]]
static QByteArray number(uint,
int base = 10);
434 [[nodiscard]]
static QByteArray number(
long,
int base = 10);
435 [[nodiscard]]
static QByteArray number(ulong,
int base = 10);
436 [[nodiscard]]
static QByteArray number(qlonglong,
int base = 10);
437 [[nodiscard]]
static QByteArray number(qulonglong,
int base = 10);
438 [[nodiscard]]
static QByteArray number(
double,
char format =
'g',
int precision = 6);
439 [[nodiscard]]
static QByteArray fromRawData(
const char *data, qsizetype size)
441 return QByteArray(DataPointer::fromRawData(data, size));
444 class FromBase64Result;
445 [[nodiscard]]
static FromBase64Result fromBase64Encoding(QByteArray &&base64, Base64Options options = Base64Encoding);
446 [[nodiscard]]
static FromBase64Result fromBase64Encoding(
const QByteArray &base64, Base64Options options = Base64Encoding);
447 [[nodiscard]]
static QByteArray fromBase64(
const QByteArray &base64, Base64Options options = Base64Encoding);
448 [[nodiscard]]
static QByteArray fromHex(
const QByteArray &hexEncoded);
449 [[nodiscard]]
static QByteArray fromPercentEncoding(
const QByteArray &pctEncoded,
char percent =
'%');
450 [[nodiscard]]
static QByteArray fromPercentEncoding(QByteArray &&pctEncoded,
char percent =
'%');
452#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
453 static QByteArray fromCFData(CFDataRef data);
454 static QByteArray fromRawCFData(CFDataRef data);
455 CFDataRef toCFData()
const Q_DECL_CF_RETURNS_RETAINED;
456 CFDataRef toRawCFData()
const Q_DECL_CF_RETURNS_RETAINED;
457 static QByteArray fromNSData(
const NSData *data);
458 static QByteArray fromRawNSData(
const NSData *data);
459 NSData *toNSData()
const Q_DECL_NS_RETURNS_AUTORELEASED;
460 NSData *toRawNSData()
const Q_DECL_NS_RETURNS_AUTORELEASED;
463#if defined(Q_OS_WASM) || defined(Q_QDOC)
464 static QByteArray fromEcmaUint8Array(emscripten::val uint8array);
465 emscripten::val toEcmaUint8Array();
468 typedef char *iterator;
469 typedef const char *const_iterator;
470 typedef iterator Iterator;
471 typedef const_iterator ConstIterator;
472 typedef std::reverse_iterator<iterator> reverse_iterator;
473 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
474 iterator begin() {
return data(); }
476 const_iterator begin()
const noexcept {
return d.data(); }
478 const_iterator cbegin()
const noexcept {
return begin(); }
480 const_iterator constBegin()
const noexcept {
return begin(); }
481 iterator end() {
return begin() + size(); }
483 const_iterator end()
const noexcept {
return begin() + size(); }
485 const_iterator cend()
const noexcept {
return end(); }
487 const_iterator constEnd()
const noexcept {
return end(); }
488 reverse_iterator rbegin() {
return reverse_iterator(end()); }
489 reverse_iterator rend() {
return reverse_iterator(begin()); }
491 const_reverse_iterator rbegin()
const noexcept {
return const_reverse_iterator(end()); }
493 const_reverse_iterator rend()
const noexcept {
return const_reverse_iterator(begin()); }
495 const_reverse_iterator crbegin()
const noexcept {
return rbegin(); }
497 const_reverse_iterator crend()
const noexcept {
return rend(); }
500 typedef qsizetype size_type;
501 typedef qptrdiff difference_type;
502 typedef const char & const_reference;
503 typedef char & reference;
504 typedef char *pointer;
505 typedef const char *const_pointer;
506 typedef char value_type;
507 void push_back(
char c)
509 void push_back(
const char *s)
511 void push_back(
const QByteArray &a)
513 void push_back(QByteArrayView a)
515 void push_front(
char c)
517 void push_front(
const char *c)
519 void push_front(
const QByteArray &a)
521 void push_front(QByteArrayView a)
523 void shrink_to_fit() { squeeze(); }
524 iterator erase(const_iterator first, const_iterator last);
525 inline iterator erase(const_iterator it) {
return erase(it, it + 1); }
526 constexpr qsizetype max_size()
const noexcept
531 static QByteArray fromStdString(
const std::string &s);
532 std::string toStdString()
const;
534 static constexpr qsizetype maxSize()
noexcept
537 return Data::maxSize() - 1;
539 constexpr qsizetype size()
const noexcept
541 constexpr size_t MaxSize = maxSize();
542 Q_PRESUME(size_t(d.size) <= MaxSize);
545#if QT_DEPRECATED_SINCE(6
, 4
)
546 QT_DEPRECATED_VERSION_X_6_4(
"Use size() or length() instead.")
547 constexpr qsizetype count()
const noexcept {
return size(); }
549 constexpr qsizetype length()
const noexcept {
return size(); }
550 QT_CORE_CONSTEXPR_INLINE_SINCE(6, 4)
551 bool isNull()
const noexcept;
553 inline const DataPointer &data_ptr()
const {
return d; }
554 inline DataPointer &data_ptr() {
return d; }
555#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
556 explicit inline QByteArray(
const DataPointer &dd) : d(dd) {}
558 explicit Q_DECL_CONSTEXPR_DTOR QByteArray(DataPointer &&dd) : d(std::move(dd)) {}
560 [[nodiscard]] QByteArray nullTerminated()
const &;
561 [[nodiscard]] QByteArray nullTerminated() &&;
562 QByteArray &nullTerminate();
565 friend bool comparesEqual(
const QByteArray &lhs,
char rhs)
noexcept
566 {
return QByteArrayView(lhs) == rhs; }
567 friend bool comparesEqual(
const QByteArray &lhs,
const QByteArrayView &rhs)
noexcept
568 {
return QByteArrayView(lhs) == rhs; }
569 friend Qt::strong_ordering
570 compareThreeWay(
const QByteArray &lhs,
char rhs)
noexcept
572 return compareThreeWay(QByteArrayView(lhs), rhs);
574 friend Qt::strong_ordering
575 compareThreeWay(
const QByteArray &lhs,
const QByteArrayView &rhs)
noexcept
577 const int res = QtPrivate::compareMemory(QByteArrayView(lhs), rhs);
578 return Qt::compareThreeWay(res, 0);
580 Q_DECLARE_STRONGLY_ORDERED(QByteArray)
581 Q_DECLARE_STRONGLY_ORDERED(QByteArray,
char)
582 Q_DECLARE_STRONGLY_ORDERED(QByteArray,
const char *)
583#if defined(__GLIBCXX__
) && defined(__cpp_lib_three_way_comparison)
588 friend bool operator<(
const QByteArray &lhs,
const QByteArray &rhs)
noexcept
589 {
return is_lt(compareThreeWay(lhs, rhs)); }
590 friend bool operator<=(
const QByteArray &lhs,
const QByteArray &rhs)
noexcept
591 {
return is_lteq(compareThreeWay(lhs, rhs)); }
592 friend bool operator>(
const QByteArray &lhs,
const QByteArray &rhs)
noexcept
593 {
return is_gt(compareThreeWay(lhs, rhs)); }
594 friend bool operator>=(
const QByteArray &lhs,
const QByteArray &rhs)
noexcept
595 {
return is_gteq(compareThreeWay(lhs, rhs)); }
599 friend bool comparesEqual(
const QByteArray &lhs, std::nullptr_t)
noexcept
600 {
return lhs.isEmpty(); }
601 friend Qt::strong_ordering compareThreeWay(
const QByteArray &lhs, std::nullptr_t)
noexcept
602 {
return lhs.isEmpty() ? Qt::strong_ordering::equivalent : Qt::strong_ordering::greater; }
603 Q_DECLARE_STRONGLY_ORDERED(QByteArray, std::nullptr_t)
606 friend Q_CORE_EXPORT
bool comparesEqual(
const QByteArray &lhs,
const QChar &rhs)
noexcept;
607 friend Q_CORE_EXPORT Qt::strong_ordering
608 compareThreeWay(
const QByteArray &lhs,
const QChar &rhs)
noexcept;
609 friend Q_CORE_EXPORT
bool comparesEqual(
const QByteArray &lhs,
char16_t rhs)
noexcept;
610 friend Q_CORE_EXPORT Qt::strong_ordering
611 compareThreeWay(
const QByteArray &lhs,
char16_t rhs)
noexcept;
612#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
613 Q_DECLARE_STRONGLY_ORDERED(QByteArray, QChar, QT_ASCII_CAST_WARN)
614 Q_DECLARE_STRONGLY_ORDERED(QByteArray,
char16_t, QT_ASCII_CAST_WARN)
618 void reallocData(qsizetype alloc, QArrayData::AllocationOption option);
619 void reallocGrowData(qsizetype n);
620 void expand(qsizetype i);
622 Q_ALWAYS_INLINE
constexpr void verify([[maybe_unused]] qsizetype pos = 0,
623 [[maybe_unused]] qsizetype n = 1)
const
626 Q_ASSERT(pos <= d.size);
628 Q_ASSERT(n <= d.size - pos);
631 static QByteArray sliced_helper(QByteArray &a, qsizetype pos, qsizetype n);
632 static QByteArray toLower_helper(
const QByteArray &a);
633 static QByteArray toLower_helper(QByteArray &a);
634 static QByteArray toUpper_helper(
const QByteArray &a);
635 static QByteArray toUpper_helper(QByteArray &a);
636 static QByteArray trimmed_helper(
const QByteArray &a);
637 static QByteArray trimmed_helper(QByteArray &a);
638 static QByteArray simplified_helper(
const QByteArray &a);
639 static QByteArray simplified_helper(QByteArray &a);
640 template <
typename Predicate>
641 qsizetype removeIf_helper(Predicate pred)
643 const qsizetype result = d->eraseIf(pred);
645 d.data()[d.size] =
'\0';
649 friend class QString;
650 friend Q_CORE_EXPORT QByteArray qUncompress(
const uchar *data, qsizetype nbytes);
652 template <
typename T>
friend qsizetype erase(QByteArray &ba,
const T &t);
653 template <
typename Predicate>
friend qsizetype erase_if(QByteArray &ba, Predicate pred);