Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qbytearray.cpp File Reference
#include "qbytearray.h"
#include "qbytearraymatcher.h"
#include "private/qtools_p.h"
#include "qhashfunctions.h"
#include "qlist.h"
#include "qlocale_p.h"
#include "qlocale_tools_p.h"
#include "private/qnumeric_p.h"
#include "private/qsimd_p.h"
#include "qstringalgorithms_p.h"
#include "qscopedpointer.h"
#include "qbytearray_p.h"
#include "qstringconverter_p.h"
#include <qdatastream.h>
#include <qmath.h>
#include <zconf.h>
#include <zlib.h>
#include <qxpfunctional.h>
#include <ctype.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
+ Include dependency graph for qbytearray.cpp:

Go to the source code of this file.

Macros

#define REHASH(a)
 

Typedefs

using CompressSizeHint_t = quint32
 

Enumerations

enum class  ZLibOp : bool { Compression , Decompression }
 

Functions

static constexpr uchar asciiUpper (uchar c)
 
static constexpr uchar asciiLower (uchar c)
 
qsizetype qFindByteArray (const char *haystack0, qsizetype haystackLen, qsizetype from, const char *needle0, qsizetype needleLen)
 
int qstrnicmp (const char *str1, qsizetype len1, const char *str2, qsizetype len2)
 
static Q_DECL_COLD_FUNCTION const char * zlibOpAsString (ZLibOp op)
 
static Q_DECL_COLD_FUNCTION QByteArray zlibError (ZLibOp op, const char *what)
 
static Q_DECL_COLD_FUNCTION QByteArray dataIsNull (ZLibOp op)
 
static Q_DECL_COLD_FUNCTION QByteArray lengthIsNegative (ZLibOp op)
 
static Q_DECL_COLD_FUNCTION QByteArray tooMuchData (ZLibOp op)
 
static Q_DECL_COLD_FUNCTION QByteArray invalidCompressedData ()
 
static Q_DECL_COLD_FUNCTION QByteArray unexpectedZlibError (ZLibOp op, int err, const char *msg)
 
static QByteArray xxflate (ZLibOp op, QArrayDataPointer< char > out, QByteArrayView input, qxp::function_ref< int(z_stream *) const > init, qxp::function_ref< int(z_stream *, size_t) const > processChunk, qxp::function_ref< void(z_stream *) const > deinit)
 
QByteArray qCompress (const uchar *data, qsizetype nbytes, int compressionLevel)
 
static qsizetype findCharHelper (QByteArrayView haystack, qsizetype from, char needle) noexcept
 
static qsizetype lastIndexOfHelper (const char *haystack, qsizetype l, const char *needle, qsizetype ol, qsizetype from)
 
static qsizetype lastIndexOfCharHelper (QByteArrayView haystack, qsizetype from, char needle) noexcept
 
static qsizetype countCharHelper (QByteArrayView haystack, char needle) noexcept
 
static constexpr bool isUpperCaseAscii (char c)
 
static constexpr bool isLowerCaseAscii (char c)
 
template<typename T >
static QByteArray toCase_template (T &input, uchar(*lookup)(uchar))
 
static char * qulltoa2 (char *p, qulonglong n, int base)
 
static void q_fromPercentEncoding (QByteArray *ba, char percent)
 

Variables

static const quint16 crc_tbl [16]
 

Macro Definition Documentation

◆ REHASH

#define REHASH (   a)
Value:
if (ol_minus_1 < sizeof(std::size_t) * CHAR_BIT) \
hashHaystack -= std::size_t(a) << ol_minus_1; \
hashHaystack <<= 1
GLboolean GLboolean GLboolean GLboolean a
[7]

Definition at line 2640 of file qbytearray.cpp.

Typedef Documentation

◆ CompressSizeHint_t

Definition at line 523 of file qbytearray.cpp.

Enumeration Type Documentation

◆ ZLibOp

enum class ZLibOp : bool
strong
Enumerator
Compression 
Decompression 

Definition at line 525 of file qbytearray.cpp.

Function Documentation

◆ asciiLower()

static constexpr uchar asciiLower ( uchar  c)
inlinestaticconstexpr

Definition at line 47 of file qbytearray.cpp.

◆ asciiUpper()

static constexpr uchar asciiUpper ( uchar  c)
inlinestaticconstexpr

Definition at line 42 of file qbytearray.cpp.

◆ countCharHelper()

static qsizetype countCharHelper ( QByteArrayView  haystack,
char  needle 
)
inlinestaticnoexcept

Definition at line 2834 of file qbytearray.cpp.

References ch.

Referenced by QByteArray::count(), and QtPrivate::count().

+ Here is the caller graph for this function:

◆ dataIsNull()

static Q_DECL_COLD_FUNCTION QByteArray dataIsNull ( ZLibOp  op)
static

Definition at line 545 of file qbytearray.cpp.

References zlibError().

Referenced by QByteArray::qCompress().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findCharHelper()

static qsizetype findCharHelper ( QByteArrayView  haystack,
qsizetype  from,
char  needle 
)
inlinestaticnoexcept

Definition at line 2645 of file qbytearray.cpp.

References qMax().

Referenced by QtPrivate::findByteArray().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ invalidCompressedData()

static Q_DECL_COLD_FUNCTION QByteArray invalidCompressedData ( )
static

Definition at line 563 of file qbytearray.cpp.

References Decompression, and zlibError().

Referenced by xxflate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isLowerCaseAscii()

static constexpr bool isLowerCaseAscii ( char  c)
inlinestaticconstexpr

Definition at line 2978 of file qbytearray.cpp.

Referenced by QByteArray::isUpper().

+ Here is the caller graph for this function:

◆ isUpperCaseAscii()

static constexpr bool isUpperCaseAscii ( char  c)
inlinestaticconstexpr

Definition at line 2970 of file qbytearray.cpp.

Referenced by QByteArray::isLower(), and QByteArray::number().

+ Here is the caller graph for this function:

◆ lastIndexOfCharHelper()

static qsizetype lastIndexOfCharHelper ( QByteArrayView  haystack,
qsizetype  from,
char  needle 
)
inlinestaticnoexcept

Definition at line 2744 of file qbytearray.cpp.

Referenced by QtPrivate::lastIndexOf().

+ Here is the caller graph for this function:

◆ lastIndexOfHelper()

static qsizetype lastIndexOfHelper ( const char *  haystack,
qsizetype  l,
const char *  needle,
qsizetype  ol,
qsizetype  from 
)
static

Definition at line 2710 of file qbytearray.cpp.

References REHASH.

Referenced by QtPrivate::lastIndexOf().

+ Here is the caller graph for this function:

◆ lengthIsNegative()

static Q_DECL_COLD_FUNCTION QByteArray lengthIsNegative ( ZLibOp  op)
static

Definition at line 551 of file qbytearray.cpp.

References zlibError().

Referenced by QByteArray::qCompress().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ q_fromPercentEncoding()

static void q_fromPercentEncoding ( QByteArray ba,
char  percent 
)
static

Definition at line 4722 of file qbytearray.cpp.

References ba, QByteArray::data(), i, QByteArray::isEmpty(), QByteArray::size(), and QByteArray::truncate().

Referenced by QByteArray::percentDecoded().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qCompress()

QByteArray qCompress ( const uchar data,
qsizetype  nbytes,
int  compressionLevel 
)
related

Definition at line 664 of file qbytearray.cpp.

Referenced by QByteArray::qCompress(), QSvgIconEngine::read(), QShader::serialized(), QSvgIconEngine::write(), QCacheItem::writeCompressedData(), and RCCFileInfo::writeDataBlob().

+ Here is the caller graph for this function:

◆ qFindByteArray()

qsizetype qFindByteArray ( const char *  haystack0,
qsizetype  haystackLen,
qsizetype  from,
const char *  needle,
qsizetype  needleLen 
)

Definition at line 255 of file qbytearraymatcher.cpp.

References findChar(), qFindByteArrayBoyerMoore(), and REHASH.

Referenced by QtPrivate::findByteArray().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qstrnicmp()

int qstrnicmp ( const char *  str1,
qsizetype  len1,
const char *  str2,
qsizetype  len2 
)
Since
5.12

A helper for QByteArray::compare. Compares len1 bytes from str1 to len2 bytes from str2. If len2 is -1, then str2 is expected to be '\0'-terminated.

Definition at line 339 of file qbytearray.cpp.

References QtMiscUtils::caseCompareAscii(), i, Q_ASSERT, qMin(), and s2.

Referenced by QByteArray::compare(), QByteArrayView::compare(), parseHeaderName(), and parseHeaderName().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qulltoa2()

static char * qulltoa2 ( char *  p,
qulonglong  n,
int  base 
)
static

Definition at line 4224 of file qbytearray.cpp.

References base, and qWarning.

Referenced by QByteArray::setNum(), and QByteArray::setNum().

+ Here is the caller graph for this function:

◆ toCase_template()

template<typename T >
static QByteArray toCase_template ( T &  input,
uchar(*)(uchar lookup 
)
static

Definition at line 3186 of file qbytearray.cpp.

References ch, QByteArray::constBegin(), and e.

+ Here is the call graph for this function:

◆ tooMuchData()

static Q_DECL_COLD_FUNCTION QByteArray tooMuchData ( ZLibOp  op)
static

Definition at line 557 of file qbytearray.cpp.

References zlibError().

Referenced by QByteArray::qCompress(), and xxflate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unexpectedZlibError()

static Q_DECL_COLD_FUNCTION QByteArray unexpectedZlibError ( ZLibOp  op,
int  err,
const char *  msg 
)
static

Definition at line 569 of file qbytearray.cpp.

References qWarning, and zlibOpAsString().

Referenced by xxflate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xxflate()

static QByteArray xxflate ( ZLibOp  op,
QArrayDataPointer< char >  out,
QByteArrayView  input,
qxp::function_ref< int(z_stream *) const >  init,
qxp::function_ref< int(z_stream *, size_t) const >  processChunk,
qxp::function_ref< void(z_stream *) const >  deinit 
)
static

Definition at line 578 of file qbytearray.cpp.

References capacity, Decompression, QArrayData::GrowsAtEnd, init(), invalidCompressedData(), out, Q_ASSERT, qScopeGuard(), tooMuchData(), and unexpectedZlibError().

Referenced by QByteArray::qCompress().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ zlibError()

static Q_DECL_COLD_FUNCTION QByteArray zlibError ( ZLibOp  op,
const char *  what 
)
static

Definition at line 538 of file qbytearray.cpp.

References qWarning, and zlibOpAsString().

Referenced by dataIsNull(), invalidCompressedData(), lengthIsNegative(), and tooMuchData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ zlibOpAsString()

static Q_DECL_COLD_FUNCTION const char * zlibOpAsString ( ZLibOp  op)
static

Definition at line 528 of file qbytearray.cpp.

References Compression, and Decompression.

Referenced by unexpectedZlibError(), and zlibError().

+ Here is the caller graph for this function:

Variable Documentation

◆ crc_tbl

const quint16 crc_tbl[16]
static
Initial value:
= {
0x0000, 0x1081, 0x2102, 0x3183,
0x4204, 0x5285, 0x6306, 0x7387,
0x8408, 0x9489, 0xa50a, 0xb58b,
0xc60c, 0xd68d, 0xe70e, 0xf78f
}

Definition at line 442 of file qbytearray.cpp.

Referenced by QByteArray::qChecksum().