X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fio%2Fzlibcompressed.h;h=fb12d61a4eff0fdcb07386582b759c302fc361dd;hb=99b9121e2158603372c7313400283b622e6754d8;hp=fa7a15315ccb09a7a44a1671e85d26f3ea5b3bc6;hpb=e352b6c33142c531e12dfe87cc25e5f1510731de;p=libs%2Fcore.git diff --git a/source/io/zlibcompressed.h b/source/io/zlibcompressed.h index fa7a153..fb12d61 100644 --- a/source/io/zlibcompressed.h +++ b/source/io/zlibcompressed.h @@ -16,7 +16,7 @@ private: public: zlib_error(const std::string &, int); - ~zlib_error() throw() { } + virtual ~zlib_error() throw() = default; int code() const throw() { return code_; } }; @@ -34,24 +34,31 @@ private: struct Private; Base &below; - unsigned buffer_size; - unsigned char *in_buffer; - unsigned char *out_buffer; - bool stream_end; - Private *priv; + std::size_t buffer_size = 1024; + unsigned char *in_buffer = 0; + unsigned char *out_buffer = 0; + bool stream_end = false; + Private *priv = 0; public: /** Creates a zlib de/compression object. The underlying object must be open for reading or writing, not both. The level parameter determines compression quality, ranging from 1 (fastest) to 9 (best compression). */ - ZlibCompressed(Base &, unsigned level = 9); + ZlibCompressed(Base &b, unsigned level = 9): ZlibCompressed(b, b.get_mode()&M_RDWR, level) { } + + /** 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); 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 @@ -61,7 +68,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