52 #ifndef QT_NO_COMPRESS 60 #define IS_RAW_DATA(d) ((d)->data != (d)->array) 66 const char *haystack0,
int haystackLen,
int from,
67 const char *needle0,
int needleLen);
73 Q_ASSERT_X(alloc < (1 << 30) - extra,
"qAllocMore",
"Requested size is too large!");
75 if (alloc == 0 && extra == 0)
77 const int page = 1 << 12;
81 nalloc = (1<<3) + ((alloc >>3) << 3);
86 nalloc = (alloc < page) ? 1 << 3 : page;
87 while (nalloc < alloc) {
93 return nalloc - extra;
118 char *dst =
new char[strlen(src) + 1];
141 #if defined(_MSC_VER) && _MSC_VER >= 1400 145 if (len >= 0 && strcpy_s(dst, len+1, src) == 0)
149 return strcpy(dst, src);
179 #if defined(_MSC_VER) && _MSC_VER >= 1400 180 strncpy_s(dst, len, src, len-1);
182 strncpy(dst, src, len);
231 int qstrcmp(
const char *str1,
const char *str2)
233 return (str1 && str2) ? strcmp(str1, str2)
234 : (str1 ? 1 : (str2 ? -1 : 0));
281 register const uchar *s1 =
reinterpret_cast<const uchar *
>(str1);
282 register const uchar *s2 =
reinterpret_cast<const uchar *
>(str2);
286 return s1 ? 1 : (s2 ? -1 : 0);
318 register const uchar *s1 =
reinterpret_cast<const uchar *
>(str1);
319 register const uchar *s2 =
reinterpret_cast<const uchar *
>(str2);
323 return s1 ? 1 : (s2 ? -1 : 0);
324 for (; len--; s1++, s2++) {
339 return str1.
isEmpty() ? 0 : +1;
342 const char *str1end = str1data + str1.
length();
343 for ( ; str1data < str1end && *str2; ++str1data, ++str2) {
354 if (str1data < str1end)
367 int ret = memcmp(str1, str2,
qMin(l1, l2));
378 static void createCRC16Table()
380 register unsigned int i;
381 register unsigned int j;
383 unsigned int v0, v1, v2, v3;
384 for (i = 0; i < 16; i++) {
391 #define SET_BIT(x, b, v) (x) |= (v) << (b) 406 printf(
"static const quint16 crc_tbl[16] = {\n");
407 for (
int i = 0; i < 16; i +=4)
408 printf(
" 0x%04x, 0x%04x, 0x%04x, 0x%04x,\n", crc_tbl[i], crc_tbl[i+1], crc_tbl[i+2], crc_tbl[i+3]);
414 0x0000, 0x1081, 0x2102, 0x3183,
415 0x4204, 0x5285, 0x6306, 0x7387,
416 0x8408, 0x9489, 0xa50a, 0xb58b,
417 0xc60c, 0xd68d, 0xe70e, 0xf78f
441 crc = ((crc >> 4) & 0x0fff) ^
crc_tbl[((crc ^
c) & 15)];
443 crc = ((crc >> 4) & 0x0fff) ^
crc_tbl[((crc ^
c) & 15)];
445 return ~crc & 0xffff;
482 #ifndef QT_NO_COMPRESS 489 qWarning(
"qCompress: Data is null");
492 if (compressionLevel < -1 || compressionLevel > 9)
493 compressionLevel = -1;
495 ulong len = nbytes + nbytes / 100 + 13;
500 res = ::compress2((
uchar*)bazip.
data()+4, &len, (
uchar*)data, nbytes, compressionLevel);
505 bazip[0] = (nbytes & 0xff000000) >> 24;
506 bazip[1] = (nbytes & 0x00ff0000) >> 16;
507 bazip[2] = (nbytes & 0x0000ff00) >> 8;
508 bazip[3] = (nbytes & 0x000000ff);
511 qWarning(
"qCompress: Z_MEM_ERROR: Not enough memory");
518 }
while (res == Z_BUF_ERROR);
561 #ifndef QT_NO_COMPRESS 565 qWarning(
"qUncompress: Data is null");
569 if (nbytes < 4 || (data[0]!=0 || data[1]!=0 || data[2]!=0 || data[3]!=0))
570 qWarning(
"qUncompress: Input data is corrupted");
573 ulong expectedSize = (data[0] << 24) | (data[1] << 16) |
574 (data[2] << 8) | (data[3] );
582 qWarning(
"qUncompress: Input data is corrupted");
588 qWarning(
"qUncompress: could not allocate enough memory to uncompress data");
594 int res = ::uncompress((
uchar*)d->
array, &len,
595 (
uchar*)data+4, nbytes-4);
602 qWarning(
"qUncompress: Input data is corrupted");
608 qWarning(
"qUncompress: could not allocate enough memory to uncompress data");
622 qWarning(
"qUncompress: Z_MEM_ERROR: Not enough memory");
630 qWarning(
"qUncompress: Z_DATA_ERROR: Input data is corrupted");
639 return c >=
'A' && c <=
'Z';
644 if (c >=
'A' && c <=
'Z')
645 return c -
'A' +
'a';
651 0, 0, shared_null.array, {0} };
653 0, 0, shared_empty.array, {0} };
963 if (
d->
ref != 1 || len >
d->
alloc || (len < d->
size && len < d->alloc >> 1))
966 memcpy(x->
data, str, len + 1);
1414 memcpy(
d->
array, str, len+1);
1434 }
else if (size <= 0) {
1442 memcpy(
d->
array, data, size);
1466 memset(
d->
array, ch, size);
1534 if (
d->
ref != 1 || size >
d->
alloc || (size < d->size && size < d->alloc >> 1))
1558 resize(size < 0 ? d->size : size);
1678 memcpy(
d->
data, str, len);
1835 int pos,
const char *arr,
int len)
1839 if (pos < 0 || len <= 0 || arr == 0)
1842 int oldsize = ba->
size();
1844 char *dst = ba->
data();
1846 ::memset(dst + oldsize, 0x20, pos - oldsize);
1848 ::memmove(dst + pos + len, dst + pos, oldsize - pos);
1849 memcpy(dst + pos, arr, len);
1957 if (len <= 0 || pos >=
d->
size || pos < 0)
1960 if (pos + len >=
d->
size) {
1981 if (len == after.
d->
size && (pos + len <= d->
size)) {
1983 memmove(
d->
data + pos, after.
d->
data, len*
sizeof(
char));
1989 return insert(pos, copy);
2018 if (len == alen && (pos + len <= d->
size)) {
2020 memcpy(
d->
data + pos, after, len*
sizeof(
char));
2046 if (
isNull() || before.
d == after.
d)
2084 if (
isNull() || (before == after && bsize == asize))
2088 const char *
a = after;
2089 const char *b = before;
2091 char *copy = (
char *)malloc(asize);
2093 memcpy(copy, after, asize);
2097 char *copy = (
char *)malloc(bsize);
2099 memcpy(copy, before, bsize);
2108 if (bsize == asize) {
2110 while ((index = matcher.
indexIn(*
this, index)) != -1) {
2111 memcpy(d + index, after, asize);
2115 }
else if (asize < bsize) {
2119 while ((index = matcher.
indexIn(*
this, index)) != -1) {
2121 int msize = index - movestart;
2123 memmove(d + to, d + movestart, msize);
2130 memcpy(d + to, after, asize);
2138 int msize = len - movestart;
2140 memmove(d + to, d + movestart, msize);
2141 resize(len - num*(bsize-asize));
2146 while (index != -1) {
2150 index = matcher.
indexIn(*
this, index);
2153 indices[pos++] =
index;
2163 int adjust = pos*(asize-bsize);
2167 int newlen = len + adjust;
2177 int movestart = indices[pos] + bsize;
2178 int insertstart = indices[pos] + pos*(asize-bsize);
2179 int moveto = insertstart + asize;
2180 memmove(d + moveto, d + movestart, (moveend - movestart));
2182 memcpy(d + insertstart, after, asize);
2183 moveend = movestart - bsize;
2249 char b[2] = { before,
'\0' };
2292 char *e = i +
d->
size;
2312 while ((end =
indexOf(sep, start)) != -1) {
2348 const int resultSize = times *
d->
size;
2352 if (result.
d->
alloc != resultSize)
2357 int sizeSoFar =
d->
size;
2358 char *
end = result.
d->
data + sizeSoFar;
2360 const int halfResultSize = resultSize >> 1;
2361 while (sizeSoFar <= halfResultSize) {
2362 memcpy(end, result.
d->
data, sizeSoFar);
2366 memcpy(end, result.
d->
data, resultSize - sizeSoFar);
2367 result.
d->
data[resultSize] =
'\0';
2368 result.
d->
size = resultSize;
2373 if (ol_minus_1 < sizeof(uint) * CHAR_BIT) \ 2374 hashHaystack -= (a) << ol_minus_1; \ 2390 const int ol = ba.
d->
size;
2397 if (from >
d->
size || ol + from > l)
2437 if (from >
d->
size || ol + from > l)
2465 if (from < d->
size) {
2466 const char *n =
d->
data + from - 1;
2481 if (from < 0 || from > l)
2486 const char *
end = haystack;
2488 const uint ol_minus_1 = ol - 1;
2489 const char *n = needle + ol_minus_1;
2490 const char *h = haystack + ol_minus_1;
2491 uint hashNeedle = 0, hashHaystack = 0;
2493 for (idx = 0; idx < ol; ++idx) {
2494 hashNeedle = ((hashNeedle<<1) + *(n-idx));
2495 hashHaystack = ((hashHaystack<<1) + *(h-idx));
2497 hashHaystack -= *haystack;
2498 while (haystack >= end) {
2499 hashHaystack += *haystack;
2500 if (hashHaystack == hashNeedle && memcmp(needle, haystack, ol) == 0)
2501 return haystack - end;
2503 REHASH(*(haystack + ol));
2528 const int ol = ba.
d->
size;
2593 else if (from >
d->
size)
2596 const char *b =
d->
data;
2597 const char *n =
d->
data + from + 1;
2618 while ((i = matcher.
indexIn(*
this, i + 1)) != -1)
2621 while ((i =
indexOf(ba, i + 1)) != -1)
2658 const char *b =
d->
data;
2686 if (
d == ba.
d || ba.
d->
size == 0)
2723 return d->
data[0] == ch;
2737 if (
d == ba.
d || ba.
d->
size == 0)
2840 len =
d->
size - pos;
2845 if (len + pos >
d->
size)
2846 len =
d->
size - pos;
2847 if (pos == 0 && len ==
d->
size)
2915 #if !defined(QT_NO_DATASTREAM) || (defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE)) 2953 if (len == 0xffffffff)
2956 const quint32 Step = 1024 * 1024;
2961 ba.
resize(allocated + blockSize);
2968 }
while (allocated < len);
2972 #endif // QT_NO_DATASTREAM 3353 const char *from =
d->
data;
3354 const char *fromend = from +
d->
size;
3356 char *to = result.
d->
data;
3358 while (from!=fromend && isspace(
uchar(*from)))
3360 while (from!=fromend && !isspace(
uchar(*from)))
3361 to[outc++] = *from++;
3367 if (outc > 0 && to[outc-1] ==
' ')
3392 const char *s =
d->
data;
3397 while (start<=end && isspace(
uchar(s[start])))
3400 while (end && isspace(
uchar(s[end])))
3403 int l = end - start + 1;
3433 int padlen = width - len;
3435 result.
resize(len+padlen);
3438 memset(result.
d->
data+len, fill, padlen);
3441 result =
left(width);
3470 int padlen = width - len;
3472 result.
resize(len+padlen);
3474 memcpy(result.
d->
data+padlen,
data(), len);
3475 memset(result.
d->
data, fill, padlen);
3478 result =
left(width);
3510 #if defined(QT_CHECK_RANGE) 3511 if (base != 0 && (base < 2 || base > 36)) {
3512 qWarning(
"QByteArray::toLongLong: Invalid base %d", base);
3543 #if defined(QT_CHECK_RANGE) 3544 if (base != 0 && (base < 2 || base > 36)) {
3545 qWarning(
"QByteArray::toULongLong: Invalid base %d", base);
3579 if (v < INT_MIN || v >
INT_MAX) {
3644 if (v < LONG_MIN || v > LONG_MAX) {
3676 if (v > ULONG_MAX) {
3707 if (v < SHRT_MIN || v > SHRT_MAX) {
3738 if (v > USHRT_MAX) {
3798 const char alphabet[] =
"ABCDEFGH" "IJKLMNOP" "QRSTUVWX" "YZabcdef" 3799 "ghijklmn" "opqrstuv" "wxyz0123" "456789+/";
3800 const char padchar =
'=';
3806 char *out = tmp.
data();
3807 while (i < d->
size) {
3814 if (i ==
d->
size) padlen = 1;
3818 int j = (chunk & 0x00fc0000) >> 18;
3819 int k = (chunk & 0x0003f000) >> 12;
3820 int l = (chunk & 0x00000fc0) >> 6;
3821 int m = (chunk & 0x0000003f);
3822 *out++ = alphabet[j];
3823 *out++ = alphabet[k];
3824 if (padlen > 1) *out++ = padchar;
3825 else *out++ = alphabet[
l];
3826 if (padlen > 0) *out++ = padchar;
3827 else *out++ = alphabet[m];
3882 #if defined(QT_CHECK_RANGE) 3883 if (base < 2 || base > 36) {
3884 qWarning(
"QByteArray::setNum: Invalid base %d", base);
3901 #if defined(QT_CHECK_RANGE) 3902 if (base < 2 || base > 36) {
3903 qWarning(
"QByteArray::setNum: Invalid base %d", base);
3963 #if defined(QT_CHECK_RANGE) 3964 qWarning(
"QByteArray::setNum: Invalid format char '%c'", f);
4126 x->
data =
const_cast<char *
>(
data);
4186 unsigned int buf = 0;
4191 for (
int i = 0; i < base64.
size(); ++i) {
4192 int ch = base64.
at(i);
4195 if (ch >=
'A' && ch <=
'Z')
4197 else if (ch >=
'a' && ch <=
'z')
4199 else if (ch >=
'0' && ch <=
'9')
4209 buf = (buf << 6) | d;
4213 tmp[offset++] = buf >> nbits;
4214 buf &= (1 << nbits) - 1;
4239 bool odd_digit =
true;
4240 for (
int i = hexEncoded.
size() - 1; i >= 0; --i) {
4241 int ch = hexEncoded.
at(i);
4243 if (ch >=
'0' && ch <=
'9')
4245 else if (ch >=
'a' && ch <=
'f')
4246 tmp = ch -
'a' + 10;
4247 else if (ch >=
'A' && ch <=
'F')
4248 tmp = ch -
'A' + 10;
4256 *result |= tmp << 4;
4274 char *hexData = hex.
data();
4276 for (
int i = 0; i <
d->
size; ++i) {
4277 int j = (data[i] >> 4) & 0xf;
4279 hexData[i*2] = (j +
'0');
4281 hexData[i*2] = (j +
'a' - 10);
4284 hexData[i*2+1] = (j +
'0');
4286 hexData[i*2+1] = (j +
'a' - 10);
4297 const char *inputPtr =
data;
4300 int len = ba->
count();
4306 if (c == percent && i + 2 < len) {
4310 if (a >=
'0' && a <=
'9') a -=
'0';
4311 else if (a >=
'a' && a <=
'f') a = a -
'a' + 10;
4312 else if (a >=
'A' && a <=
'F') a = a -
'A' + 10;
4314 if (b >=
'0' && b <=
'9') b -=
'0';
4315 else if (b >=
'a' && b <=
'f') b = b -
'a' + 10;
4316 else if (b >=
'A' && b <=
'F') b = b -
'A' + 10;
4318 *data++ = (char)((a << 4) | b);
4366 static inline bool q_strchr(
const char str[],
char chr)
4368 if (!str)
return false;
4370 const char *
ptr = str;
4372 while ((c = *ptr++))
4380 static const char hexnumbers[] =
"0123456789ABCDEF";
4381 return hexnumbers[c & 0xf];
4390 int len = input.
count();
4391 const char *inputData = input.
constData();
4395 for (
int i = 0; i < len; ++i) {
4396 unsigned char c = *inputData++;
4397 if (((c >= 0x61 && c <= 0x7A)
4398 || (c >= 0x41 && c <= 0x5A)
4399 || (c >= 0x30 && c <= 0x39)
4413 output = ba->
data();
4415 output[length++] = percent;
4477 if ((percent >= 0x61 && percent <= 0x7A)
4478 || (percent >= 0x41 && percent <= 0x5A)
4479 || (percent >= 0x30 && percent <= 0x39)
4484 include2 += percent;
static QByteArray fromHex(const QByteArray &hexEncoded)
Returns a decoded copy of the hex encoded array hexEncoded.
void chop(int n)
Removes n bytes from the end of the byte array.
int qFindByteArray(const char *haystack0, int haystackLen, int from, const char *needle0, int needleLen)
static int lastIndexOfHelper(const char *haystack, int l, const char *needle, int ol, int from)
int qstrncmp(const char *str1, const char *str2, uint len)
static QByteArray & qbytearray_insert(QByteArray *ba, int pos, const char *arr, int len)
Inserts len bytes from the array arr at position pos and returns a reference the modified byte array...
void truncate(int pos)
Truncates the byte array at index position pos.
QByteArray & fill(char c, int size=-1)
Sets every byte in the byte array to character ch.
static qint64 bytearrayToLongLong(const char *num, int base, bool *ok, bool *overflow=0)
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
short toShort(bool *ok=0, int base=10) const
Returns the byte array converted to a short using base base, which is 10 by default and must be betwe...
#define QT_END_NAMESPACE
This macro expands to.
char * data()
Returns a pointer to the data stored in the byte array.
QByteArray toUpper() const
Returns an uppercase copy of the byte array.
T * data() const
Returns the value of the pointer referenced by this object.
static void q_fromPercentEncoding(QByteArray *ba, char percent)
QByteArray & append(char c)
Appends the character ch to this byte array.
static QByteArray fromPercentEncoding(const QByteArray &pctEncoded, char percent='%')
Returns a decoded copy of the URI/URL-style percent-encoded input.
qlonglong toLongLong(bool *ok=0, int base=10) const
Returns the byte array converted to a {long long} using base base, which is 10 by default and must be...
Q_CORE_EXPORT void qFree(void *ptr)
QByteArray rightJustified(int width, char fill=' ', bool truncate=false) const
Returns a byte array of size width that contains the fill character followed by this byte array...
The QByteArray class provides an array of bytes.
T * take()
Returns the value of the pointer referenced by this object.
QByteArray()
Constructs an empty byte array.
QByteArray toLower() const
Returns a lowercase copy of the byte array.
ulong toULong(bool *ok=0, int base=10) const
long toLong(bool *ok=0, int base=10) const
long ASN1_INTEGER_get ASN1_INTEGER * a
void setStatus(Status status)
Sets the status of the data stream to the status given.
Q_CORE_EXPORT void * qMalloc(size_t size)
int count() const
Same as size().
Q_CORE_EXPORT void * qRealloc(void *ptr, size_t size)
QByteArray & prepend(char c)
Prepends the character ch to this byte array.
static double bytearrayToDouble(const char *num, bool *ok, bool *overflow=0)
int qstrcmp(const char *str1, const char *str2)
A safe strcmp() function.
static bool q_strchr(const char str[], char chr)
QByteArray toHex() const
Returns a hex encoded copy of the byte array.
bool startsWith(const QByteArray &a) const
Returns true if this byte array starts with byte array ba; otherwise returns false.
#define Q_BASIC_ATOMIC_INITIALIZER(a)
QByteArray & setRawData(const char *a, uint n)
Resets the QByteArray to use the first size bytes of the data array.
Q_CORE_EXPORT QTextStream & hex(QTextStream &s)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
static QString doubleToString(const QChar zero, const QChar plus, const QChar minus, const QChar exponent, const QChar group, const QChar decimal, double d, int precision, DoubleForm form, int width, unsigned flags)
static const quint16 crc_tbl[16]
QByteArray simplified() const
Returns a byte array that has whitespace removed from the start and the end, and which has each seque...
char * qstrcpy(char *dst, const char *src)
Copies all the characters up to and including the '\0' from src into dst and returns a pointer to dst...
QByteArray right(int len) const
Returns a byte array that contains the rightmost len bytes of this byte array.
static QString unsLongLongToString(const QChar zero, const QChar group, const QChar plus, quint64 l, int precision, int base, int width, unsigned flags)
void append(const T &t)
Inserts value at the end of the list.
quint16 qChecksum(const char *data, uint len)
Returns the CRC-16 checksum of the first len bytes of data.
QByteArray qUncompress(const QByteArray &data)
Uncompresses the data byte array and returns a new byte array with the uncompressed data...
static QString longLongToString(const QChar zero, const QChar group, const QChar plus, const QChar minus, qint64 l, int precision, int base, int width, unsigned flags)
#define QT_BEGIN_NAMESPACE
This macro expands to.
int qAllocMore(int alloc, int extra)
int lastIndexOf(char c, int from=-1) const
Returns the index position of the last occurrence of character ch in the byte array, searching backward from index position from.
QByteArray & operator=(const QByteArray &)
Assigns other to this byte array and returns a reference to this byte array.
int readRawData(char *, int len)
Reads at most len bytes from the stream into s and returns the number of bytes read.
QDataStream & writeBytes(const char *, uint len)
Writes the length specifier len and the buffer s to the stream and returns a reference to the stream...
QByteArray trimmed() const
Returns a byte array that has whitespace removed from the start and the end.
static QByteArray fromRawData(const char *, int size)
Constructs a QByteArray that uses the first size bytes of the data array.
QByteArray leftJustified(int width, char fill=' ', bool truncate=false) const
Returns a byte array of size width that contains this byte array padded by the fill character...
qulonglong toULongLong(bool *ok=0, int base=10) const
Returns the byte array converted to an {unsigned long long} using base base, which is 10 by default a...
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
static quint64 bytearrayToUnsLongLong(const char *num, int base, bool *ok)
QChar toUpper() const
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
void q_normalizePercentEncoding(QByteArray *ba, const char *exclude)
const T * ptr(const T &t)
float toFloat(bool *ok=0) const
Returns the byte array converted to a float value.
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
QByteArray left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
int qstrnicmp(const char *str1, const char *str2, uint len)
A safe strnicmp() function.
The QByteArrayMatcher class holds a sequence of bytes that can be quickly matched in a byte array...
bool isNull() const
Returns true if this byte array is null; otherwise returns false.
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
int qstricmp(const char *str1, const char *str2)
A safe stricmp() function.
QDataStream & operator<<(QDataStream &out, const QByteArray &ba)
Writes byte array ba to the stream out and returns a reference to the stream.
QByteArray nulTerminated() const
Return a QByteArray that is sure to be NUL-terminated.
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
int version() const
Returns the version number of the data serialization format.
int length() const
Same as size().
const char * constData() const
Returns a pointer to the data stored in the byte array.
static QByteArray fromBase64(const QByteArray &base64)
Returns a decoded copy of the Base64 array base64.
QList< QByteArray > split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays...
#define Q_ASSERT_X(cond, where, what)
const QLocalePrivate * d() const
static void q_toPercentEncoding(QByteArray *ba, const char *dontEncode, const char *alsoEncode, char percent)
int count(char c) const
Returns the number of occurrences of character ch in the byte array.
static bool qIsUpper(char c)
QByteArray repeated(int times) const
Returns a copy of this byte array repeated the specified number of times.
int toInt(bool *ok=0, int base=10) const
Returns the byte array converted to an int using base base, which is 10 by default and must be betwee...
uint qstrlen(const char *str)
void resize(int size)
Sets the size of the byte array to size bytes.
QByteArray & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QByteArray toBase64() const
Returns a copy of the byte array, encoded as Base64.
int size() const
Returns the number of bytes in this byte array.
static char toHexHelper(char c)
QByteArray toPercentEncoding(const QByteArray &exclude=QByteArray(), const QByteArray &include=QByteArray(), char percent='%') const
Returns a URI/URL-style percent-encoded copy of this byte array.
char * qstrdup(const char *src)
Returns a duplicate string.
QDataStream & operator>>(QDataStream &in, QByteArray &ba)
Reads a byte array into ba from the stream in and returns a reference to the stream.
QByteArray & replace(int index, int len, const char *s)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
The QDataStream class provides serialization of binary data to a QIODevice.
QByteArray qCompress(const uchar *data, int nbytes, int compressionLevel)
Compresses the first nbytes of data and returns the compressed data in a new byte array...
double toDouble(bool *ok=0) const
Returns the byte array converted to a double value.
char at(int i) const
Returns the character at index position i in the byte array.
void reserve(int size)
Attempts to allocate memory for at least size bytes.
char * qstrncpy(char *dst, const char *src, uint len)
A safe strncpy() function.
uint toUInt(bool *ok=0, int base=10) const
Returns the byte array converted to an {unsigned int} using base base, which is 10 by default and mus...
QChar toLower() const
Returns the lowercase equivalent if the character is uppercase or titlecase; otherwise returns the ch...
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...
QByteArray & remove(int index, int len)
Removes len bytes from the array, starting at index position pos, and returns a reference to the arra...
int indexIn(const QByteArray &ba, int from=0) const
Searches the byte array ba, from byte position from (default 0, i.e.
void clear()
Clears the contents of the byte array and makes it empty.
ushort toUShort(bool *ok=0, int base=10) const
Returns the byte array converted to an {unsigned short} using base base, which is 10 by default and m...
bool endsWith(const QByteArray &a) const
Returns true if this byte array ends with byte array ba; otherwise returns false. ...
static char qToLower(char c)
QByteArray & insert(int i, char c)
Inserts character ch at index position i in the byte array.
#define forever
This macro is provided for convenience for writing infinite loops.