blob: 2d82a13bc5ec718cb710ef1ac1425d1e2aa194a3 [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
DRCff5ca2d2011-08-09 20:19:59 +00002 * Copyright (C) 2011 D. R. Commander. All Rights Reserved.
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00003 *
4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this software; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
18 */
19
20//
21// ZlibOutStream streams to a compressed data stream (underlying), compressing
22// with zlib on the fly.
23//
24
25#ifndef __RDR_ZLIBOUTSTREAM_H__
26#define __RDR_ZLIBOUTSTREAM_H__
27
28#include <rdr/OutStream.h>
29
30struct z_stream_s;
31
32namespace rdr {
33
34 class ZlibOutStream : public OutStream {
35
36 public:
37
38 ZlibOutStream(OutStream* os=0, int bufSize=0, int compressionLevel=-1);
39 virtual ~ZlibOutStream();
40
41 void setUnderlying(OutStream* os);
42 void setCompressionLevel(int level=-1);
43 void flush();
44 int length();
45
46 private:
47
48 int overrun(int itemSize, int nItems);
Pierre Ossmanb5822f32011-10-18 14:27:07 +000049 void deflate(int flush);
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000050 void checkCompressionLevel();
51
52 OutStream* underlying;
53 int compressionLevel;
54 int newLevel;
55 int bufSize;
56 int offset;
57 z_stream_s* zs;
58 U8* start;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000059 };
60
61} // end of namespace rdr
62
63#endif