Code

4af5ada2b49f05284554ada30ab448320fb653d2
[inkscape.git] / src / dom / io / gzipstream.h
1 #ifndef __GZIPSTREAM_H__
2 #define __GZIPSTREAM_H__
3 /**
4  * Zlib-enabled input and output streams
5  *
6  * This provides a simple mechanism for reading and
7  * writing Gzip files.   We use our own 'ZipTool' class
8  * to accomplish this, avoiding a zlib dependency.
9  *
10  * Authors:
11  *   Bob Jamison
12  *
13  * Copyright (C) 2006 Bob Jamison
14  *
15  *  This library is free software; you can redistribute it and/or
16  *  modify it under the terms of the GNU Lesser General Public
17  *  License as published by the Free Software Foundation; either
18  *  version 2.1 of the License, or (at your option) any later version.
19  *
20  *  This library is distributed in the hope that it will be useful,
21  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23  *  Lesser General Public License for more details.
24  *
25  *  You should have received a copy of the GNU Lesser General Public
26  *  License along with this library; if not, write to the Free Software
27  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28  */
33 #include "domstream.h"
35 namespace org
36 {
37 namespace w3c
38 {
39 namespace dom
40 {
41 namespace io
42 {
44 //#########################################################################
45 //# G Z I P    I N P U T    S T R E A M
46 //#########################################################################
48 /**
49  * This class is for deflating a gzip-compressed InputStream source
50  *
51  */
52 class GzipInputStream : public BasicInputStream
53 {
55 public:
57     GzipInputStream(InputStream &sourceStream);
59     virtual ~GzipInputStream();
61     virtual int available();
63     virtual void close();
65     virtual int get();
67 private:
69     bool load();
71     bool loaded;
73     std::vector<unsigned char> buffer;
74     unsigned int bufPos;
77 }; // class GzipInputStream
82 //#########################################################################
83 //# G Z I P    O U T P U T    S T R E A M
84 //#########################################################################
86 /**
87  * This class is for gzip-compressing data going to the
88  * destination OutputStream
89  *
90  */
91 class GzipOutputStream : public BasicOutputStream
92 {
94 public:
96     GzipOutputStream(OutputStream &destinationStream);
98     virtual ~GzipOutputStream();
100     virtual void close();
102     virtual void flush();
104     virtual int put(XMLCh ch);
106 private:
108     std::vector<unsigned char> buffer;
111 }; // class GzipOutputStream
119 } // namespace io
120 } // namespace dom
121 } // namespace w3c
122 } // namespace org
125 #endif /* __GZIPSTREAM_H__ */