summaryrefslogtreecommitdiff
path: root/src/deflate.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/deflate.h')
-rw-r--r--src/deflate.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/deflate.h b/src/deflate.h
new file mode 100644
index 0000000..cab9b51
--- /dev/null
+++ b/src/deflate.h
@@ -0,0 +1,63 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#ifndef BU_DEFLATE_H
9#define BU_DEFLATE_H
10
11#include <stdint.h>
12#include <zlib.h>
13
14#include "bu/filter.h"
15
16namespace Bu
17{
18 /**
19 *
20 *@ingroup Streams
21 */
22 class Deflate : public Bu::Filter
23 {
24 public:
25 enum Format
26 {
27 Raw = 0x01,
28 Zlib = 0x02,
29 Gzip = 0x03,
30 AutoDetect = 0x04,
31
32 AutoRaw = 0x04|0x01,
33 AutoZlib = 0x04|0x02,
34 AutoGzip = 0x04|0x03
35 };
36
37 Deflate( Bu::Stream &rNext, int nCompression=9, Format eFmt=AutoRaw );
38 virtual ~Deflate();
39
40 virtual void start();
41 virtual Bu::size stop();
42 virtual Bu::size read( void *pBuf, Bu::size nBytes );
43 virtual Bu::size write( const void *pBuf, Bu::size nBytes );
44
45 virtual bool isOpen();
46 virtual bool isEos();
47
48 Bu::size getCompressedSize();
49
50 private:
51 void zError( int code );
52 z_stream zState;
53 bool bReading;
54 int nCompression;
55 char *pBuf;
56 uint32_t nBufSize;
57 Bu::size sTotalOut;
58 Format eFmt;
59 bool bEos;
60 };
61}
62
63#endif