Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
QDecompressHelper Class Reference

#include <qdecompresshelper_p.h>

+ Collaboration diagram for QDecompressHelper:

Public Types

enum  ContentEncoding {
  None , Deflate , GZip , Brotli ,
  Zstandard
}
 

Public Member Functions

 QDecompressHelper ()=default
 
 ~QDecompressHelper ()
 
bool setEncoding (const QByteArray &contentEncoding)
 
bool isCountingBytes () const
 
void setCountingBytesEnabled (bool shouldCount)
 
qint64 uncompressedSize () const
 
bool hasData () const
 
void feed (const QByteArray &data)
 
void feed (QByteArray &&data)
 
void feed (const QByteDataBuffer &buffer)
 
void feed (QByteDataBuffer &&buffer)
 
qsizetype read (char *data, qsizetype maxSize)
 
bool isValid () const
 
void clear ()
 
void setDecompressedSafetyCheckThreshold (qint64 threshold)
 
QString errorString () const
 

Static Public Member Functions

static bool isSupportedEncoding (const QByteArray &encoding)
 
static QByteArrayList acceptedEncoding ()
 

Detailed Description

Definition at line 26 of file qdecompresshelper_p.h.

Member Enumeration Documentation

◆ ContentEncoding

Enumerator
None 
Deflate 
GZip 
Brotli 
Zstandard 

Definition at line 29 of file qdecompresshelper_p.h.

Constructor & Destructor Documentation

◆ QDecompressHelper()

QDecompressHelper::QDecompressHelper ( )
default

◆ ~QDecompressHelper()

QDecompressHelper::~QDecompressHelper ( )

Definition at line 89 of file qdecompresshelper.cpp.

References clear().

+ Here is the call graph for this function:

Member Function Documentation

◆ acceptedEncoding()

QByteArrayList QDecompressHelper::acceptedEncoding ( )
static

Definition at line 76 of file qdecompresshelper.cpp.

References list, and QList< T >::reserve().

Referenced by QHttpNetworkConnectionPrivate::prepareRequest().

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

◆ clear()

void QDecompressHelper::clear ( )

Definition at line 517 of file qdecompresshelper.cpp.

References Brotli, QByteDataBuffer::clear(), QString::clear(), Deflate, GZip, None, and Zstandard.

Referenced by ~QDecompressHelper(), feed(), feed(), feed(), QNetworkReplyHttpImplPrivate::followRedirect(), and QNetworkReplyHttpImplPrivate::replyDownloadData().

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

◆ errorString()

QString QDecompressHelper::errorString ( ) const

Returns a string describing the error that occurred or an empty string if no error occurred.

See also
isValid()

Definition at line 512 of file qdecompresshelper.cpp.

Referenced by QNetworkReplyHttpImplPrivate::replyDownloadData(), and QNetworkReplyHttpImplPrivate::replyDownloadMetaData().

+ Here is the caller graph for this function:

◆ feed() [1/4]

void QDecompressHelper::feed ( const QByteArray data)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 222 of file qdecompresshelper.cpp.

References feed().

Referenced by feed(), and QNetworkReplyHttpImplPrivate::replyDownloadData().

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

◆ feed() [2/4]

void QDecompressHelper::feed ( const QByteDataBuffer buffer)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 249 of file qdecompresshelper.cpp.

References QByteDataBuffer::append(), clear(), None, and Q_ASSERT.

+ Here is the call graph for this function:

◆ feed() [3/4]

void QDecompressHelper::feed ( QByteArray &&  data)

Give data to the QDecompressHelper which will be stored until a read is attempted.

If isCountingBytes() is true then it will decompress immediately before discarding the data, but will count the uncompressed byte size.

Definition at line 236 of file qdecompresshelper.cpp.

References QByteDataBuffer::append(), QByteDataBuffer::bufferCount(), clear(), None, and Q_ASSERT.

+ Here is the call graph for this function:

◆ feed() [4/4]

void QDecompressHelper::feed ( QByteDataBuffer &&  buffer)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 262 of file qdecompresshelper.cpp.

References QByteDataBuffer::append(), clear(), copy(), None, and Q_ASSERT.

+ Here is the call graph for this function:

◆ hasData()

bool QDecompressHelper::hasData ( ) const

Returns true if there are encoded bytes left or there is some indication that the decoder still has data left internally.

Note
Even if this returns true the next call to read() might read 0 bytes. This most likely means the decompression is done.

Definition at line 474 of file qdecompresshelper.cpp.

References QByteDataBuffer::isEmpty().

Referenced by read(), and QNetworkReplyHttpImplPrivate::replyDownloadData().

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

◆ isCountingBytes()

bool QDecompressHelper::isCountingBytes ( ) const

Returns true if the QDecompressHelper is measuring the size of the decompressed data.

See also
setCountingBytesEnabled, uncompressedSize

Definition at line 166 of file qdecompresshelper.cpp.

Referenced by QNetworkReplyHttpImplPrivate::replyDownloadData().

+ Here is the caller graph for this function:

◆ isSupportedEncoding()

bool QDecompressHelper::isSupportedEncoding ( const QByteArray encoding)
static

Definition at line 71 of file qdecompresshelper.cpp.

References None.

Referenced by QHttpNetworkReplyPrivate::isCompressed().

+ Here is the caller graph for this function:

◆ isValid()

bool QDecompressHelper::isValid ( ) const

Returns whether or not the object is valid. If it becomes invalid after an operation has been performed then an error has occurred.

See also
errorString()

Definition at line 501 of file qdecompresshelper.cpp.

References None.

Referenced by QNetworkReplyHttpImplPrivate::finished(), read(), QNetworkReplyHttpImplPrivate::replyDownloadData(), and QNetworkReplyHttpImplPrivate::replyDownloadMetaData().

+ Here is the caller graph for this function:

◆ read()

qsizetype QDecompressHelper::read ( char *  data,
qsizetype  maxSize 
)

Definition at line 347 of file qdecompresshelper.cpp.

References hasData(), QByteDataBuffer::isEmpty(), isValid(), and QByteDataBuffer::read().

Referenced by QNetworkReplyHttpImplPrivate::replyDownloadData().

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

◆ setCountingBytesEnabled()

void QDecompressHelper::setCountingBytesEnabled ( bool  shouldCount)

Enable or disable counting the decompressed size of the data based on shouldCount. Enabling this means the data will be decompressed twice (once for counting and once when data is being read).

Note
Can only be called before contentEncoding is set and data is fed to the object.
See also
isCountingBytes, uncompressedSize

Definition at line 184 of file qdecompresshelper.cpp.

References QByteDataBuffer::byteAmount(), None, and Q_ASSERT.

Referenced by QNetworkReplyHttpImplPrivate::replyDownloadMetaData().

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

◆ setDecompressedSafetyCheckThreshold()

void QDecompressHelper::setDecompressedSafetyCheckThreshold ( qint64  threshold)

Set the threshold required before the archive bomb detection kicks in. By default this is 10MB. Setting it to -1 is treated as disabling the feature.

Definition at line 424 of file qdecompresshelper.cpp.

Referenced by QNetworkReplyHttpImplPrivate::replyDownloadMetaData().

+ Here is the caller graph for this function:

◆ setEncoding()

bool QDecompressHelper::setEncoding ( const QByteArray contentEncoding)

Definition at line 94 of file qdecompresshelper.cpp.

References QString::arg(), None, Q_ASSERT, qWarning, setEncoding(), and QCoreApplication::translate().

Referenced by QNetworkReplyHttpImplPrivate::replyDownloadMetaData(), and setEncoding().

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

◆ uncompressedSize()

qint64 QDecompressHelper::uncompressedSize ( ) const

Returns the amount of uncompressed bytes left.

Note
Since this is only based on the data received so far the final size could be larger.
It is only valid to call this if isCountingBytes() returns true
See also
isCountingBytes, setCountBytes

Definition at line 206 of file qdecompresshelper.cpp.

References Q_ASSERT.

Referenced by QNetworkReplyHttpImplPrivate::replyDownloadData().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: