QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCArchiveDeviceBase.h
Go to the documentation of this file.
1#pragma once
2
5
6#include <QtCore/QBuffer>
7#include <QtCore/QFile>
8#include <QtCore/QIODevice>
9
10#include <memory>
11
12struct archive;
13
19class QGCArchiveDeviceBase : public QIODevice
20{
21 Q_OBJECT
22
23public:
24 ~QGCArchiveDeviceBase() override;
25
26 // QIODevice interface
27 void close() override;
28 bool isSequential() const override { return true; }
29 qint64 bytesAvailable() const override;
30
33 QString errorString() const;
34
37 QString formatName() const { return _formatName; }
38
41 QString filterName() const { return _filterName; }
42
43protected:
47 explicit QGCArchiveDeviceBase(const QString &filePath, QObject *parent = nullptr);
48
53 explicit QGCArchiveDeviceBase(QIODevice *source, QObject *parent = nullptr);
54
55 // QIODevice interface
56 qint64 readData(char *data, qint64 maxSize) override;
57 qint64 writeData(const char *data, qint64 maxSize) override;
58
62 bool initSourceFromPath();
63
67 virtual bool initArchive() = 0;
68
72 virtual bool prepareForReading() = 0;
73
76 virtual bool isReadyToRead() const = 0;
77
80 void configureArchiveFormats(bool allFormats);
81
84 bool openArchive();
85
88 bool fillBuffer();
89
91 void captureFormatInfo();
92
94 virtual void resetState();
95
96 // Source management
97 QString _filePath;
98 QIODevice *_sourceDevice = nullptr;
99 bool _ownsSource = false;
100 std::unique_ptr<QIODevice> _ownedSource;
101
102 // libarchive state
103 struct archive *_archive = nullptr;
104 QByteArray _resourceData; // For Qt resources (must outlive archive)
105 bool _eof = false;
106
107 // Decompressed data buffer
108 QByteArray _buffer;
109
110 // Error state
112
113 // Format info (populated after first header read)
114 QString _formatName;
115 QString _filterName;
116};
Base class for QIODevice wrappers that use libarchive for decompression.
bool isSequential() const override
void captureFormatInfo()
Capture format info from the archive after first header read.
virtual bool isReadyToRead() const =0
virtual bool initArchive()=0
qint64 readData(char *data, qint64 maxSize) override
std::unique_ptr< QIODevice > _ownedSource
virtual bool prepareForReading()=0
void configureArchiveFormats(bool allFormats)
virtual void resetState()
Reset all state (called by close())
qint64 writeData(const char *data, qint64 maxSize) override
qint64 bytesAvailable() const override