Zipios++
|
00001 #ifndef DEFLATEOUTPUTSTREAMBUF_H 00002 #define DEFLATEOUTPUTSTREAMBUF_H 00003 00004 #include "zipios++/zipios-config.h" 00005 00006 #include "zipios++/meta-iostreams.h" 00007 #include <vector> 00008 00009 #include <zlib.h> 00010 00011 #include "zipios++/filteroutputstreambuf.h" 00012 #include "zipios++/ziphead.h" 00013 #include "zipios++/zipios_defs.h" 00014 00015 namespace zipios { 00016 00017 using std::vector ; 00018 00025 class DeflateOutputStreambuf : public FilterOutputStreambuf { 00026 public: 00027 00034 explicit DeflateOutputStreambuf( streambuf *outbuf, bool user_init = false, 00035 bool del_outbuf = false ) ; 00036 00038 virtual ~DeflateOutputStreambuf() ; 00039 00040 bool init( int comp_level = 6 ) ; 00041 bool closeStream() ; 00042 00049 uint32 getCrc32() const { return _crc32 ; } 00050 00055 uint32 getCount() const { return _overflown_bytes ; } 00056 00057 protected: 00058 virtual int overflow( int c = EOF ) ; 00059 virtual int sync() ; 00060 00062 bool flushOutvec() ; 00063 00066 void endDeflation() ; 00067 00068 private: 00069 z_stream _zs ; 00070 bool _zs_initialized ; 00071 protected: // FIXME: reconsider design? 00072 const int _invecsize ; 00073 vector< char > _invec ; 00074 const int _outvecsize ; 00075 vector< char > _outvec ; 00076 00077 uint32 _crc32 ; 00078 uint32 _overflown_bytes ; 00079 }; 00080 00081 00082 } // namespace 00083 00084 00085 00086 #endif 00087 00092 /* 00093 Zipios++ - a small C++ library that provides easy access to .zip files. 00094 Copyright (C) 2000 Thomas Søndergaard 00095 00096 This library is free software; you can redistribute it and/or 00097 modify it under the terms of the GNU Lesser General Public 00098 License as published by the Free Software Foundation; either 00099 version 2 of the License, or (at your option) any later version. 00100 00101 This library is distributed in the hope that it will be useful, 00102 but WITHOUT ANY WARRANTY; without even the implied warranty of 00103 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00104 Lesser General Public License for more details. 00105 00106 You should have received a copy of the GNU Lesser General Public 00107 License along with this library; if not, write to the Free Software 00108 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00109 */