]> git.donarmstrong.com Git - flightcrew.git/blob - src/zipios/zipios++/inflateinputstreambuf.h
Imported Upstream version 0.7.2+dfsg
[flightcrew.git] / src / zipios / zipios++ / inflateinputstreambuf.h
1 #ifndef INFLATEINPUTSTREAMBUF_H
2 #define INFLATEINPUTSTREAMBUF_H
3
4 #include "zipios++/zipios-config.h"
5
6 #include "zipios++/meta-iostreams.h"
7 #include <vector>
8
9 #include <zlib.h>
10
11 #include "zipios++/filterinputstreambuf.h"
12
13 namespace zipios {
14
15 using std::vector ;
16
17 /** InflateInputStreambuf is an input stream filter, that inflates the input
18     from the attached input stream. Deflation/Inflation is a
19     compression/decompression method used in gzip and zip. The zlib
20     library is used to perform the actual inflation, this class only
21     wraps the functionality in an input stream filter. */
22 class InflateInputStreambuf : public FilterInputStreambuf {
23 public:
24   /** InflateInputStreambuf constructor.
25       @param inbuf the streambuf to use for input.
26       @param s_pos a position to reset the inbuf to before reading. Specify
27       -1 to read from the current position.
28       @param del_inbuf if true is specified inbuf will be deleted, when 
29       the InflateInputStreambuf is destructed.
30   */
31   explicit InflateInputStreambuf( streambuf *inbuf, int s_pos = -1, bool del_inbuf = false ) ;
32   virtual ~InflateInputStreambuf() ;
33
34   /** Resets the zlib stream and purges input and output buffers.
35       repositions the input streambuf at stream_position.
36       @param stream_position a position to reset the inbuf to before reading. Specify
37       -1 to read from the current position.
38   */
39   bool reset( int stream_position = -1 ) ;
40 protected:
41   virtual int underflow() ;
42 private:
43   z_stream _zs ;
44   bool _zs_initialized ;
45   const int _invecsize ;
46   vector< char > _invec ;
47 protected: // FIXME: reconsider design?
48   const int _outvecsize ;
49   vector< char > _outvec ;
50
51 private:
52
53   /** Copy-constructor is private to prevent copying. */
54   InflateInputStreambuf( const InflateInputStreambuf &src ) ;
55
56   /** Copy-assignment operator is private to prevent copying.  */
57   const InflateInputStreambuf &operator= ( const InflateInputStreambuf &src ) ;
58
59 };
60
61
62 } // namespace
63
64
65
66 #endif
67
68 /** \file
69     Header file that defines InflateInputStreambuf.
70 */
71
72 /*
73   Zipios++ - a small C++ library that provides easy access to .zip files.
74   Copyright (C) 2000  Thomas Søndergaard
75   
76   This library is free software; you can redistribute it and/or
77   modify it under the terms of the GNU Lesser General Public
78   License as published by the Free Software Foundation; either
79   version 2 of the License, or (at your option) any later version.
80   
81   This library is distributed in the hope that it will be useful,
82   but WITHOUT ANY WARRANTY; without even the implied warranty of
83   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
84   Lesser General Public License for more details.
85   
86   You should have received a copy of the GNU Lesser General Public
87   License along with this library; if not, write to the Free Software
88   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
89 */