Code

Translations. French translation minor update.
[inkscape.git] / src / io / gzipstream.h
1 #ifndef __INKSCAPE_IO_GZIPSTREAM_H__
2 #define __INKSCAPE_IO_GZIPSTREAM_H__
3 /**
4  * Zlib-enabled input and output streams
5  *
6  * This is a thin wrapper of libz calls, in order
7  * to provide a simple interface to our developers
8  * for gzip input and output.
9  *
10  * Authors:
11  *   Bob Jamison <rjamison@titan.com>
12  *
13  * Copyright (C) 2004 Inkscape.org
14  *
15  * Released under GNU GPL, read the file 'COPYING' for more information
16  */
19 #include "inkscapestream.h"
20 #include <zlib.h>
22 namespace Inkscape
23 {
24 namespace IO
25 {
27 //#########################################################################
28 //# G Z I P    I N P U T    S T R E A M
29 //#########################################################################
31 /**
32  * This class is for deflating a gzip-compressed InputStream source
33  *
34  */
35 class GzipInputStream : public BasicInputStream
36 {
38 public:
40     GzipInputStream(InputStream &sourceStream);
41     
42     virtual ~GzipInputStream();
43     
44     virtual int available();
45     
46     virtual void close();
47     
48     virtual int get();
49     
50 private:
52     bool load();
53     int fetchMore();
55     bool loaded;
56     
57     long totalIn;
58     long totalOut;
60     unsigned char *outputBuf;
61     unsigned char *srcBuf;
63     unsigned long crc;
64     unsigned long srcCrc;
65     unsigned long srcSiz;
66     unsigned long srcConsumed;
67     unsigned long srcLen;
68     long outputBufPos;
69     long outputBufLen;
71     z_stream d_stream;
72 }; // class GzipInputStream
77 //#########################################################################
78 //# G Z I P    O U T P U T    S T R E A M
79 //#########################################################################
81 /**
82  * This class is for gzip-compressing data going to the
83  * destination OutputStream
84  *
85  */
86 class GzipOutputStream : public BasicOutputStream
87 {
89 public:
91     GzipOutputStream(OutputStream &destinationStream);
92     
93     virtual ~GzipOutputStream();
94     
95     virtual void close();
96     
97     virtual void flush();
98     
99     virtual void put(int ch);
101 private:
103     std::vector<unsigned char> inputBuf;
105     long totalIn;
106     long totalOut;
107     unsigned long crc;
109 }; // class GzipOutputStream
117 } // namespace IO
118 } // namespace Inkscape
121 #endif /* __INKSCAPE_IO_GZIPSTREAM_H__ */