QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCArchiveDeviceBase Class Referenceabstract

#include <QGCArchiveDeviceBase.h>

+ Inheritance diagram for QGCArchiveDeviceBase:
+ Collaboration diagram for QGCArchiveDeviceBase:

Public Member Functions

 ~QGCArchiveDeviceBase () override
 
void close () override
 
bool isSequential () const override
 
qint64 bytesAvailable () const override
 
QString errorString () const
 
QString formatName () const
 
QString filterName () const
 

Protected Member Functions

 QGCArchiveDeviceBase (const QString &filePath, QObject *parent=nullptr)
 
 QGCArchiveDeviceBase (QIODevice *source, QObject *parent=nullptr)
 
qint64 readData (char *data, qint64 maxSize) override
 
qint64 writeData (const char *data, qint64 maxSize) override
 
bool initSourceFromPath ()
 
virtual bool initArchive ()=0
 
virtual bool prepareForReading ()=0
 
virtual bool isReadyToRead () const =0
 
void configureArchiveFormats (bool allFormats)
 
bool openArchive ()
 
bool fillBuffer ()
 
void captureFormatInfo ()
 Capture format info from the archive after first header read.
 
virtual void resetState ()
 Reset all state (called by close())
 

Protected Attributes

QString _filePath
 
QIODevice * _sourceDevice = nullptr
 
bool _ownsSource = false
 
std::unique_ptr< QIODevice > _ownedSource
 
struct archive * _archive = nullptr
 
QByteArray _resourceData
 
bool _eof = false
 
QByteArray _buffer
 
QString _errorString
 
QString _formatName
 
QString _filterName
 

Detailed Description

Base class for QIODevice wrappers that use libarchive for decompression Provides common source management, buffer handling, and archive lifecycle Read-only, sequential access only

Definition at line 17 of file QGCArchiveDeviceBase.h.

Constructor & Destructor Documentation

◆ ~QGCArchiveDeviceBase()

QGCArchiveDeviceBase::~QGCArchiveDeviceBase ( )
override

Definition at line 31 of file QGCArchiveDeviceBase.cc.

References close().

◆ QGCArchiveDeviceBase() [1/2]

QGCArchiveDeviceBase::QGCArchiveDeviceBase ( const QString &  filePath,
QObject *  parent = nullptr 
)
explicitprotected

Construct with file path

Parameters
filePathPath to file (or Qt resource path :/)
parentQObject parent

Definition at line 17 of file QGCArchiveDeviceBase.cc.

◆ QGCArchiveDeviceBase() [2/2]

QGCArchiveDeviceBase::QGCArchiveDeviceBase ( QIODevice *  source,
QObject *  parent = nullptr 
)
explicitprotected

Construct with QIODevice source

Parameters
sourceData source (must be open and readable)
parentQObject parent
Note
The source device must remain valid until this device is closed

Definition at line 24 of file QGCArchiveDeviceBase.cc.

Member Function Documentation

◆ bytesAvailable()

qint64 QGCArchiveDeviceBase::bytesAvailable ( ) const
override

Definition at line 57 of file QGCArchiveDeviceBase.cc.

References _buffer.

◆ captureFormatInfo()

void QGCArchiveDeviceBase::captureFormatInfo ( )
protected

Capture format info from the archive after first header read.

Definition at line 221 of file QGCArchiveDeviceBase.cc.

References _archive, _filterName, and _formatName.

Referenced by QGCDecompressDevice::prepareForReading().

◆ close()

void QGCArchiveDeviceBase::close ( )
override

◆ configureArchiveFormats()

void QGCArchiveDeviceBase::configureArchiveFormats ( bool  allFormats)
protected

Configure libarchive format support (called during initArchive)

Parameters
allFormatstrue for all archive formats, false for raw (single-file) format

Definition at line 154 of file QGCArchiveDeviceBase.cc.

References _archive.

Referenced by QGCArchiveFile::initArchive(), and QGCDecompressDevice::initArchive().

◆ errorString()

QString QGCArchiveDeviceBase::errorString ( ) const

Get error description

Returns
Error string if error occurred, empty otherwise

Definition at line 62 of file QGCArchiveDeviceBase.cc.

References _errorString.

◆ fillBuffer()

bool QGCArchiveDeviceBase::fillBuffer ( )
protected

Read data from archive into internal buffer

Returns
true if data was read, false on EOF or error

Definition at line 197 of file QGCArchiveDeviceBase.cc.

References _archive, _buffer, _eof, _errorString, and QGCFileHelper::kBufferSizeMax.

Referenced by readData().

◆ filterName()

QString QGCArchiveDeviceBase::filterName ( ) const
inline

Get detected compression filter name (available after open)

Returns
Filter name like "gzip", "xz", "zstd", "none", or empty if not detected

Definition at line 39 of file QGCArchiveDeviceBase.h.

References _filterName.

◆ formatName()

QString QGCArchiveDeviceBase::formatName ( ) const
inline

Get detected archive format name (available after open)

Returns
Format name like "RAW", "ZIP 2.0", "POSIX ustar", or empty if not detected

Definition at line 35 of file QGCArchiveDeviceBase.h.

References _formatName.

◆ initArchive()

virtual bool QGCArchiveDeviceBase::initArchive ( )
protectedpure virtual

Initialize libarchive reader with configured format support Subclasses must override to configure format support before calling base

Returns
true on success, sets _errorString on failure

Implemented in QGCArchiveFile, and QGCDecompressDevice.

◆ initSourceFromPath()

bool QGCArchiveDeviceBase::initSourceFromPath ( )
protected

Initialize source device from file path Opens file or Qt resource and sets up _sourceDevice

Returns
true on success, sets _errorString on failure

Definition at line 113 of file QGCArchiveDeviceBase.cc.

References _errorString, _filePath, _ownedSource, _resourceData, _sourceDevice, and QGCFileHelper::isQtResource().

Referenced by QGCArchiveFile::open(), and QGCDecompressDevice::open().

◆ isReadyToRead()

virtual bool QGCArchiveDeviceBase::isReadyToRead ( ) const
protectedpure virtual

Check if ready to read data

Returns
true if archive is initialized and ready

Implemented in QGCArchiveFile, and QGCDecompressDevice.

Referenced by readData().

◆ isSequential()

bool QGCArchiveDeviceBase::isSequential ( ) const
inlineoverride

Definition at line 26 of file QGCArchiveDeviceBase.h.

◆ openArchive()

bool QGCArchiveDeviceBase::openArchive ( )
protected

◆ prepareForReading()

virtual bool QGCArchiveDeviceBase::prepareForReading ( )
protectedpure virtual

Called after archive is initialized, before reading begins Subclasses override to seek to entry, read headers, etc.

Returns
true on success, sets _errorString on failure

Implemented in QGCArchiveFile, and QGCDecompressDevice.

◆ readData()

qint64 QGCArchiveDeviceBase::readData ( char *  data,
qint64  maxSize 
)
overrideprotected

Definition at line 74 of file QGCArchiveDeviceBase.cc.

References _buffer, _eof, fillBuffer(), and isReadyToRead().

◆ resetState()

void QGCArchiveDeviceBase::resetState ( )
protectedvirtual

Reset all state (called by close())

Reimplemented in QGCArchiveFile, and QGCDecompressDevice.

Definition at line 234 of file QGCArchiveDeviceBase.cc.

References _buffer, _eof, _filterName, and _formatName.

Referenced by close(), QGCArchiveFile::resetState(), and QGCDecompressDevice::resetState().

◆ writeData()

qint64 QGCArchiveDeviceBase::writeData ( const char *  data,
qint64  maxSize 
)
overrideprotected

Definition at line 104 of file QGCArchiveDeviceBase.cc.

Member Data Documentation

◆ _archive

◆ _buffer

QByteArray QGCArchiveDeviceBase::_buffer
protected

Definition at line 106 of file QGCArchiveDeviceBase.h.

Referenced by bytesAvailable(), fillBuffer(), readData(), and resetState().

◆ _eof

bool QGCArchiveDeviceBase::_eof = false
protected

Definition at line 103 of file QGCArchiveDeviceBase.h.

Referenced by fillBuffer(), readData(), and resetState().

◆ _errorString

◆ _filePath

QString QGCArchiveDeviceBase::_filePath
protected

◆ _filterName

QString QGCArchiveDeviceBase::_filterName
protected

◆ _formatName

QString QGCArchiveDeviceBase::_formatName
protected

◆ _ownedSource

std::unique_ptr<QIODevice> QGCArchiveDeviceBase::_ownedSource
protected

Definition at line 98 of file QGCArchiveDeviceBase.h.

Referenced by close(), and initSourceFromPath().

◆ _ownsSource

bool QGCArchiveDeviceBase::_ownsSource = false
protected

Definition at line 97 of file QGCArchiveDeviceBase.h.

Referenced by close().

◆ _resourceData

QByteArray QGCArchiveDeviceBase::_resourceData
protected

Definition at line 102 of file QGCArchiveDeviceBase.h.

Referenced by initSourceFromPath().

◆ _sourceDevice

QIODevice* QGCArchiveDeviceBase::_sourceDevice = nullptr
protected

Definition at line 96 of file QGCArchiveDeviceBase.h.

Referenced by close(), initSourceFromPath(), and openArchive().


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