aboutsummaryrefslogtreecommitdiff
path: root/src/deflate.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-10-23 07:43:50 +0000
committerMike Buland <eichlan@xagasoft.com>2011-10-23 07:43:50 +0000
commitda1e0ef0772b078bd295301bd675afdee00d40e9 (patch)
tree7d1703bbb5c2d76e6e6300e51f0ed1e09704af4f /src/deflate.h
parent208b983734d7431699f4bd3534e08321e42ada86 (diff)
downloadlibbu++-da1e0ef0772b078bd295301bd675afdee00d40e9.tar.gz
libbu++-da1e0ef0772b078bd295301bd675afdee00d40e9.tar.bz2
libbu++-da1e0ef0772b078bd295301bd675afdee00d40e9.tar.xz
libbu++-da1e0ef0772b078bd295301bd675afdee00d40e9.zip
Switched ito* to synchro*, except the server, I'm thinking of takeing the core
in a different direction anyway. Added the Deflate class, it uses zlib, and can do raw (headerless) deflate streams, zlib format, or gzip format. It's easy to use and quite versitile.
Diffstat (limited to '')
-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