X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fio%2Fzlibcompressed.h;h=e4ae6e08f852f9b6228f7ff0f4b415d80a08de81;hb=c8bf2d6c15893ccc9dbc4e04611b7229029f4808;hp=1ee427413ddc1cc448338278fab543f19bbd2ca9;hpb=8ed14b63ab6249e9fc2a3a691cf8ffbf49166deb;p=libs%2Fcore.git diff --git a/source/io/zlibcompressed.h b/source/io/zlibcompressed.h index 1ee4274..e4ae6e0 100644 --- a/source/io/zlibcompressed.h +++ b/source/io/zlibcompressed.h @@ -3,6 +3,7 @@ #include #include +#include #include "base.h" namespace Msp { @@ -27,15 +28,16 @@ operates on top of another I/O object. To ensure proper termination of the compressed data stream, the ZlibCompressed object must be destroyed before the underlying object is closed. */ -class ZlibCompressed: public Base +class ZlibCompressed: public Base, public sigc::trackable { private: struct Private; Base &below; - unsigned buffer_size; + std::size_t buffer_size; unsigned char *in_buffer; unsigned char *out_buffer; + bool stream_end; Private *priv; public: @@ -44,12 +46,23 @@ public: compression quality, ranging from 1 (fastest) to 9 (best compression). */ ZlibCompressed(Base &, unsigned level = 9); + /** Creates a zlib de/compression object. Mode must be either read or + write, and compatible with the underlying object. */ + ZlibCompressed(Base &, Mode, unsigned level = 9); + +private: + void init(unsigned); + +public: virtual ~ZlibCompressed(); + virtual void set_block(bool); + virtual void set_inherit(bool); + void flush(); protected: - virtual unsigned do_write(const char *, unsigned); + virtual std::size_t do_write(const char *, std::size_t); private: /** Compresses data and writes it to the underlying object. Returns true if @@ -59,7 +72,9 @@ private: bool compress_data(int flush_mode); public: - virtual unsigned do_read(char *, unsigned); + virtual std::size_t do_read(char *, std::size_t); + + virtual const Handle &get_handle(Mode); }; } // namespace IO