Zipios++
deflateoutputstreambuf.h
Go to the documentation of this file.
1 #ifndef DEFLATEOUTPUTSTREAMBUF_H
2 #define DEFLATEOUTPUTSTREAMBUF_H
3 
4 #include "zipios++/zipios-config.h"
5 
6 #include "zipios++/meta-iostreams.h"
7 #include <vector>
8 
9 #include <zlib.h>
10 
12 #include "zipios++/ziphead.h"
13 #include "zipios++/zipios_defs.h"
14 
15 namespace zipios {
16 
17 using std::vector ;
18 
26 public:
27 
34  explicit DeflateOutputStreambuf( streambuf *outbuf, bool user_init = false,
35  bool del_outbuf = false ) ;
36 
38  virtual ~DeflateOutputStreambuf() ;
39 
40  bool init( int comp_level = 6 ) ;
41  bool closeStream() ;
42 
49  uint32 getCrc32() const { return _crc32 ; }
50 
55  uint32 getCount() const { return _overflown_bytes ; }
56 
57 protected:
58  virtual int overflow( int c = EOF ) ;
59  virtual int sync() ;
60 
62  bool flushOutvec() ;
63 
66  void endDeflation() ;
67 
68 private:
69  z_stream _zs ;
70  bool _zs_initialized ;
71 protected: // FIXME: reconsider design?
72  const int _invecsize ;
73  vector< char > _invec ;
74  const int _outvecsize ;
75  vector< char > _outvec ;
76 
77  uint32 _crc32 ;
78  uint32 _overflown_bytes ;
79 };
80 
81 
82 } // namespace
83 
84 
85 
86 #endif
87 
92 /*
93  Zipios++ - a small C++ library that provides easy access to .zip files.
94  Copyright (C) 2000 Thomas Søndergaard
95 
96  This library is free software; you can redistribute it and/or
97  modify it under the terms of the GNU Lesser General Public
98  License as published by the Free Software Foundation; either
99  version 2 of the License, or (at your option) any later version.
100 
101  This library is distributed in the hope that it will be useful,
102  but WITHOUT ANY WARRANTY; without even the implied warranty of
103  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
104  Lesser General Public License for more details.
105 
106  You should have received a copy of the GNU Lesser General Public
107  License along with this library; if not, write to the Free Software
108  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
109 */
zipios::DeflateOutputStreambuf::flushOutvec
bool flushOutvec()
Flushes _outvec and updates _zs.next_out and _zs.avail_out.
Definition: deflateoutputstreambuf.cpp:162
zipios_defs.h
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
ziphead.h
filteroutputstreambuf.h
zipios::FilterOutputStreambuf
A FilterOutputStreambuf is a streambuf that filters the data that is written to it before it passes i...
Definition: filteroutputstreambuf.h:14
zipios::DeflateOutputStreambuf
DeflateOutputStreambuf is an output stream filter, that deflates the data that is written to it befor...
Definition: deflateoutputstreambuf.h:25
zipios::DeflateOutputStreambuf::getCrc32
uint32 getCrc32() const
Returns the CRC32 for the current stream.
Definition: deflateoutputstreambuf.h:49
zipios::DeflateOutputStreambuf::~DeflateOutputStreambuf
virtual ~DeflateOutputStreambuf()
Destructor.
Definition: deflateoutputstreambuf.cpp:43
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::DeflateOutputStreambuf
DeflateOutputStreambuf(streambuf *outbuf, bool user_init=false, bool del_outbuf=false)
DeflateOutputStreambuf constructor.
Definition: deflateoutputstreambuf.cpp:18