File indexing completed on 2024-06-23 04:03:44

0001 #ifndef ZLIBCOMPRESSOR_H
0002 #define ZLIBCOMPRESSOR_H
0003 
0004 #include <QObject>
0005 
0006 #include "zlib.h"
0007 
0008 class QIODevice;
0009 
0010 class ZLibCompressor : public QObject
0011 {
0012     Q_OBJECT
0013 
0014 public:
0015     ZLibCompressor(QIODevice* device, int compression = Z_DEFAULT_COMPRESSION);
0016     ~ZLibCompressor() override;
0017 
0018     int write(const QByteArray&);
0019 
0020 protected slots:
0021     void flush();
0022 
0023 protected:
0024     int write(const QByteArray&, bool flush);
0025 
0026 private:
0027     QIODevice* device_;
0028     z_stream* zlib_stream_;
0029     bool flushed_;
0030 };
0031 
0032 #endif