~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/dom/io/gzipstream.h

  • Committer: ishmal
  • Date: 2006-04-12 13:25:21 UTC
  • Revision ID: ishmal@users.sourceforge.net-20060412132521-5ynoezpwbzq4d1c3
Add new rearranged /dom directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 */
 
29
 
 
30
 
 
31
 
 
32
 
 
33
#include "domstream.h"
 
34
 
 
35
namespace org
 
36
{
 
37
namespace w3c
 
38
{
 
39
namespace dom
 
40
{
 
41
namespace io
 
42
{
 
43
 
 
44
//#########################################################################
 
45
//# G Z I P    I N P U T    S T R E A M
 
46
//#########################################################################
 
47
 
 
48
/**
 
49
 * This class is for deflating a gzip-compressed InputStream source
 
50
 *
 
51
 */
 
52
class GzipInputStream : public BasicInputStream
 
53
{
 
54
 
 
55
public:
 
56
 
 
57
    GzipInputStream(InputStream &sourceStream);
 
58
 
 
59
    virtual ~GzipInputStream();
 
60
 
 
61
    virtual int available();
 
62
 
 
63
    virtual void close();
 
64
 
 
65
    virtual int get();
 
66
 
 
67
private:
 
68
 
 
69
    bool load();
 
70
 
 
71
    bool loaded;
 
72
 
 
73
    std::vector<unsigned char> buffer;
 
74
    unsigned int bufPos;
 
75
 
 
76
 
 
77
}; // class GzipInputStream
 
78
 
 
79
 
 
80
 
 
81
 
 
82
//#########################################################################
 
83
//# G Z I P    O U T P U T    S T R E A M
 
84
//#########################################################################
 
85
 
 
86
/**
 
87
 * This class is for gzip-compressing data going to the
 
88
 * destination OutputStream
 
89
 *
 
90
 */
 
91
class GzipOutputStream : public BasicOutputStream
 
92
{
 
93
 
 
94
public:
 
95
 
 
96
    GzipOutputStream(OutputStream &destinationStream);
 
97
 
 
98
    virtual ~GzipOutputStream();
 
99
 
 
100
    virtual void close();
 
101
 
 
102
    virtual void flush();
 
103
 
 
104
    virtual void put(int ch);
 
105
 
 
106
private:
 
107
 
 
108
    std::vector<unsigned char> buffer;
 
109
 
 
110
 
 
111
}; // class GzipOutputStream
 
112
 
 
113
 
 
114
 
 
115
 
 
116
 
 
117
 
 
118
 
 
119
} // namespace io
 
120
} // namespace dom
 
121
} // namespace w3c
 
122
} // namespace org
 
123
 
 
124
 
 
125
#endif /* __GZIPSTREAM_H__ */