blob: 63da59a43cffade25507280ff5773a7dc7b27c9e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#pragma once
#include <zlib.h>
#include <Handle.h>
namespace Balau {
class ZStream : public Handle {
public:
typedef enum {
ZLIB,
GZIP,
RAW,
} header_t;
ZStream(const IO<Handle> & h, int level = Z_BEST_COMPRESSION, header_t header = ZLIB);
virtual void close() throw (GeneralException);
virtual bool isClosed();
virtual bool isEOF();
virtual bool canRead();
virtual bool canWrite();
virtual const char * getName();
virtual ssize_t read(void * buf, size_t count) throw (GeneralException);
virtual ssize_t write(const void * buf, size_t count) throw (GeneralException);
virtual off_t getSize();
void detach() { m_detached = true; }
void flush() { doFlush(false); }
private:
void finish() { doFlush(true); }
void doFlush(bool finish);
IO<Handle> m_h;
z_stream m_zin, m_zout;
bool m_detached, m_closed, m_eof;
String m_name;
uint8_t * m_in;
};
};
|