deflateoutputstreambuf.h
Go to the documentation of this file.
#ifndef DEFLATEOUTPUTSTREAMBUF_H
#define DEFLATEOUTPUTSTREAMBUF_H
#include "zipios++/zipios-config.h"
#include "zipios++/meta-iostreams.h"
#include <vector>
#include <zlib.h>
#include "zipios++/filteroutputstreambuf.h"
#include "zipios++/ziphead.h"
#include "zipios++/zipios_defs.h"
namespace zipios {
using std::vector ;
class DeflateOutputStreambuf : public FilterOutputStreambuf {
public:
explicit DeflateOutputStreambuf( streambuf *outbuf, bool user_init = false,
bool del_outbuf = false ) ;
virtual ~DeflateOutputStreambuf() ;
bool init( int comp_level = 6 ) ;
bool closeStream() ;
uint32 getCrc32() const { return _crc32 ; }
uint32 getCount() const { return _overflown_bytes ; }
protected:
virtual int overflow( int c = EOF ) ;
virtual int sync() ;
bool flushOutvec() ;
void endDeflation() ;
private:
z_stream _zs ;
bool _zs_initialized ;
protected: // FIXME: reconsider design?
const int _invecsize ;
vector< char > _invec ;
const int _outvecsize ;
vector< char > _outvec ;
uint32 _crc32 ;
uint32 _overflown_bytes ;
};
} // namespace
#endif
/*
Zipios++ - a small C++ library that provides easy access to .zip files.
Copyright (C) 2000 Thomas Søndergaard
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
zipios::DeflateOutputStreambuf::~DeflateOutputStreambuf
virtual ~DeflateOutputStreambuf()
Destructor.
Definition deflateoutputstreambuf.cpp:43
zipios::DeflateOutputStreambuf::getCrc32
uint32 getCrc32() const
Returns the CRC32 for the current stream.
Definition deflateoutputstreambuf.h:49
zipios::DeflateOutputStreambuf::endDeflation
void endDeflation()
Flushes the remaining data in the zlib buffers, after which the only possible operations are deflateE...
Definition deflateoutputstreambuf.cpp:173
zipios::DeflateOutputStreambuf::flushOutvec
bool flushOutvec()
Flushes _outvec and updates _zs.next_out and _zs.avail_out.
Definition deflateoutputstreambuf.cpp:162
zipios::DeflateOutputStreambuf::DeflateOutputStreambuf
DeflateOutputStreambuf(streambuf *outbuf, bool user_init=false, bool del_outbuf=false)
DeflateOutputStreambuf constructor.
Definition deflateoutputstreambuf.cpp:18
zipios::DeflateOutputStreambuf::getCount
uint32 getCount() const
Returns the number of bytes written to the streambuf, that has been processed from the input buffer b...
Definition deflateoutputstreambuf.h:55
zipios::FilterOutputStreambuf::FilterOutputStreambuf
FilterOutputStreambuf(streambuf *outbuf, bool del_outbuf=false)
Constructor.
Definition filteroutputstreambuf.cpp:8
filteroutputstreambuf.h
Header file that defines FilterOutputStreambuf.
ziphead.h
Header file containing classes and functions for reading the central directory and local header field...
zipios_defs.h
Header file that defines some simple data types.