deflateoutputstreambuf.h
Go to the documentation of this file.00001 #ifndef DEFLATEOUTPUTSTREAMBUF_H
00002 #define DEFLATEOUTPUTSTREAMBUF_H
00003 
00004 #include "zipios-config.h"
00005 
00006 #include "meta-iostreams.h"
00007 #include <vector>
00008 
00009 #include <zlib.h>
00010 
00011 #include "filteroutputstreambuf.h"
00012 #include "ziphead.h"
00013 #include "zipios_defs.h"
00014 
00015 namespace zipios {
00016 
00017 using std::vector ;
00018 
00025 class BaseExport 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: 
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 } 
00083 
00084 
00085 
00086 #endif
00087 
00092 
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107 
00108 
00109