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
17class QGCArchiveDeviceBase : public QIODevice
18{
19 Q_OBJECT
20
21public:
22 ~QGCArchiveDeviceBase() override;
23
24 // QIODevice interface
25 void close() override;
26 bool isSequential() const override { return true; }
27 qint64 bytesAvailable() const override;
28
31 QString errorString() const;
32
35 QString formatName() const { return _formatName; }
36
39 QString filterName() const { return _filterName; }
40
41protected:
45 explicit QGCArchiveDeviceBase(const QString &filePath, QObject *parent = nullptr);
46
51 explicit QGCArchiveDeviceBase(QIODevice *source, QObject *parent = nullptr);
52
53 // QIODevice interface
54 qint64 readData(char *data, qint64 maxSize) override;
55 qint64 writeData(const char *data, qint64 maxSize) override;
56
60 bool initSourceFromPath();
61
65 virtual bool initArchive() = 0;
66
70 virtual bool prepareForReading() = 0;
71
74 virtual bool isReadyToRead() const = 0;
75
78 void configureArchiveFormats(bool allFormats);
79
82 bool openArchive();
83
86 bool fillBuffer();
87
89 void captureFormatInfo();
90
92 virtual void resetState();
93
94 // Source management
95 QString _filePath;
96 QIODevice *_sourceDevice = nullptr;
97 bool _ownsSource = false;
98 std::unique_ptr<QIODevice> _ownedSource;
99
100 // libarchive state
101 struct archive *_archive = nullptr;
102 QByteArray _resourceData; // For Qt resources (must outlive archive)
103 bool _eof = false;
104
105 // Decompressed data buffer
106 QByteArray _buffer;
107
108 // Error state
110
111 // Format info (populated after first header read)
112 QString _formatName;
113 QString _filterName;
114};
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