summaryrefslogtreecommitdiff
path: root/includes/ZHandle.h
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2014-08-10 02:58:35 -0700
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2014-08-10 02:58:35 -0700
commitec0f82bb6ea911baee6b9654f799f037282bf5b9 (patch)
treef18dd08e58c9231de3353544191c1fa2dfdbcb2b /includes/ZHandle.h
parentbd06a6ec9ec3d0e10fe6e09bab4a156ceef6e0c8 (diff)
Introducing notion of filters.
Diffstat (limited to 'includes/ZHandle.h')
-rw-r--r--includes/ZHandle.h24
1 files changed, 10 insertions, 14 deletions
diff --git a/includes/ZHandle.h b/includes/ZHandle.h
index dfb73fb..30db407 100644
--- a/includes/ZHandle.h
+++ b/includes/ZHandle.h
@@ -6,30 +6,26 @@
namespace Balau {
-class ZStream : public Handle {
+class ZStream : public Filter {
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);
- void detach() { m_detached = true; }
+ ZStream(IO<Handle> h, int level = Z_BEST_COMPRESSION, header_t header = ZLIB);
+ virtual void close() throw (GeneralException) override;
+ virtual ssize_t read(void * buf, size_t count) throw (GeneralException) override;
+ virtual ssize_t write(const void * buf, size_t count) throw (GeneralException) override;
+ virtual bool isEOF() override { return m_phase == CLOSING || m_eof || Filter::isEOF(); }
+ virtual bool isClosed() override { return m_phase == CLOSING || Filter::isClosed(); }
+ virtual const char * getName() override { return m_name.to_charp(); }
void flush() { doFlush(false); }
void setUseAsyncOp(bool useAsyncOp) { m_useAsyncOp = useAsyncOp; }
- virtual bool isPendingComplete();
+ virtual bool isPendingComplete() override;
void finish() { doFlush(true); }
void doFlush(bool finish);
private:
- IO<Handle> m_h;
z_stream m_zin, m_zout;
String m_name;
uint8_t * m_buf = NULL;
@@ -50,7 +46,7 @@ class ZStream : public Handle {
size_t m_total, m_count, m_compressed;
AsyncOperation * m_op = NULL;
ssize_t m_status = IDLE;
- bool m_detached = false, m_closed = false, m_eof = false, m_useAsyncOp = true;
+ bool m_useAsyncOp = true, m_eof = false;
};
};