aboutsummaryrefslogtreecommitdiff
path: root/src/stable/deflate.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/stable/deflate.h')
-rw-r--r--src/stable/deflate.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/stable/deflate.h b/src/stable/deflate.h
new file mode 100644
index 0000000..f835cfc
--- /dev/null
+++ b/src/stable/deflate.h
@@ -0,0 +1,66 @@
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
13#include "bu/filter.h"
14
15namespace Bu
16{
17 /**
18 * Provides Deflate (LZ77) support via zlib. This provides zlib, raw, and
19 * gzip stream types. By default it will autodetect the input type and
20 * encode into a raw deflate stream.
21 *
22 *@ingroup Streams
23 *@ingroup Compression
24 */
25 class Deflate : public Bu::Filter
26 {
27 public:
28 enum Format
29 {
30 Raw = 0x01,
31 Zlib = 0x02,
32 Gzip = 0x03,
33 AutoDetect = 0x04,
34
35 AutoRaw = 0x04|0x01,
36 AutoZlib = 0x04|0x02,
37 AutoGzip = 0x04|0x03
38 };
39
40 Deflate( Bu::Stream &rNext, int nCompression=-1, Format eFmt=AutoZlib );
41 virtual ~Deflate();
42
43 virtual void start();
44 virtual Bu::size stop();
45 virtual Bu::size read( void *pBuf, Bu::size nBytes );
46 virtual Bu::size write( const void *pBuf, Bu::size nBytes );
47
48 virtual bool isOpen();
49 virtual bool isEos();
50
51 Bu::size getCompressedSize();
52
53 private:
54 void zError( int code );
55 void *prState;
56 bool bReading;
57 int nCompression;
58 char *pBuf;
59 uint32_t nBufSize;
60 Bu::size sTotalOut;
61 Format eFmt;
62 bool bEos;
63 };
64}
65
66#endif