Code

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