Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
DRC | ff5ca2d | 2011-08-09 20:19:59 +0000 | [diff] [blame^] | 2 | * Copyright (C) 2011 D. R. Commander. All Rights Reserved. |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 3 | * |
| 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 | |
| 30 | struct z_stream_s; |
| 31 | |
| 32 | namespace 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); |
| 49 | void checkCompressionLevel(); |
| 50 | |
| 51 | OutStream* underlying; |
| 52 | int compressionLevel; |
| 53 | int newLevel; |
| 54 | int bufSize; |
| 55 | int offset; |
| 56 | z_stream_s* zs; |
| 57 | U8* start; |
DRC | ff5ca2d | 2011-08-09 20:19:59 +0000 | [diff] [blame^] | 58 | bool newBehavior; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | } // end of namespace rdr |
| 62 | |
| 63 | #endif |