1 /* 2 * HT Editor 3 * cstream.cc 4 * 5 * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as 9 * published by the Free Software Foundation. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 */ 20 #ifndef __CSTREAM_H__ 21 #define __CSTREAM_H__ 22 23 #include "io/types.h" 24 #include "stream.h" 25 26 /* 27 * NEVER use ht_compressed_stream for both reading and writing! 28 */ 29 30 #define COMPRESSED_STREAM_DEFAULT_GRANULARITY 10240 31 32 class CompressedStream: public StreamLayer { 33 protected: 34 byte *buffer; 35 uint buffersize; 36 uint bufferpos; 37 public: 38 CompressedStream(Stream *stream, bool own_stream); 39 virtual ~CompressedStream(); 40 /* overwritten */ 41 virtual uint read(void *buf, uint size); 42 virtual uint write(const void *buf, uint size); 43 protected: 44 void flush_compressed(); 45 void flush_uncompressed(); 46 }; 47 48 #endif 49