X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fzlibcompressed.cpp;h=fba71eb06d5e8b9ced1df0e2e1ce1e8ba743c889;hp=2220bcc46f063372698915a95e1ad1a45d1f74f0;hb=HEAD;hpb=20c897ece781e18ba54c41fd68e232ce566a938d diff --git a/source/io/zlibcompressed.cpp b/source/io/zlibcompressed.cpp index 2220bcc..8896f14 100644 --- a/source/io/zlibcompressed.cpp +++ b/source/io/zlibcompressed.cpp @@ -1,6 +1,7 @@ #ifdef WITH_ZLIB #include #endif +#include #include "zlibcompressed.h" using namespace std; @@ -14,7 +15,7 @@ zlib_error::zlib_error(const string &w, int c): #else runtime_error(w), #endif - code_(c) + m_code(c) { } @@ -30,23 +31,13 @@ struct ZlibCompressed::Private ZlibCompressed::Private::Private() { #ifdef WITH_ZLIB - stream.zalloc = 0; - stream.zfree = 0; - stream.opaque = 0; + stream.zalloc = nullptr; + stream.zfree = nullptr; + stream.opaque = nullptr; #endif } -ZlibCompressed::ZlibCompressed(Base &b, unsigned level): - below(b) -{ - mode = below.get_mode()&M_RDWR; - if(mode!=M_READ && mode!=M_WRITE) - throw invalid_access(mode); - - init(level); -} - ZlibCompressed::ZlibCompressed(Base &b, Mode m, unsigned level): below(b) { @@ -54,16 +45,7 @@ ZlibCompressed::ZlibCompressed(Base &b, Mode m, unsigned level): if(mode!=M_READ && mode!=M_WRITE) throw invalid_access(m); - init(level); -} - -void ZlibCompressed::init(unsigned level) -{ #ifdef WITH_ZLIB - buffer_size = 1024; - in_buffer = 0; - out_buffer = 0; - stream_end = false; priv = new Private; if(mode==M_WRITE) @@ -92,7 +74,7 @@ void ZlibCompressed::init(unsigned level) (void)buffer_size; (void)stream_end; (void)level; - throw zlib_error("unsupported", -1); + throw unsupported("ZlibCompressed"); #endif } @@ -115,12 +97,12 @@ ZlibCompressed::~ZlibCompressed() void ZlibCompressed::set_block(bool) { - throw logic_error("ZlibCompressed::set_block"); + throw unsupported("ZlibCompressed::set_block"); } void ZlibCompressed::set_inherit(bool) { - throw logic_error("ZlibCompressed::set_inherit"); + throw unsupported("ZlibCompressed::set_inherit"); } void ZlibCompressed::flush() @@ -280,7 +262,7 @@ size_t ZlibCompressed::do_read(char *data, size_t size) const Handle &ZlibCompressed::get_handle(Mode) { - throw logic_error("ZlibCompressed::get_handle"); + throw unsupported("ZlibCompressed::get_handle"); } } // namespace IO