2
* IO layer : zlib streambuf
5
* Johan Ceuppens <jceuppen at easynet dot be>
7
* Copyright (C) 2004 Johan Ceuppens
9
* Released under GNU LGPL, read the file 'COPYING.LIB' for more information
12
#ifndef __STREAMS_ZLIB_H_
13
#define __STREAMS_ZLIB_H_
15
#include "streams-handles.h"
17
#include <glib/gtypes.h>
18
#include <glib/garray.h>
24
class ZlibBufferException : public std::exception {};
26
// This is the initial buffersize for the stream and
27
// zipbuffers (the streambuffers expand as needed).
28
const unsigned int BUFSIZE_STREAM = 4096;
35
class ZlibBuffer : public std::streambuf
39
ZlibBuffer(URIHandle& urih);
40
virtual ~ZlibBuffer() {}
44
virtual int allocate_buffers();
45
virtual int reallocate_buffers(int new_getsize, int new_putsize);
46
virtual int underflow();
47
virtual int overflow(int c = EOF);
48
virtual int flush_output();
50
virtual void init_inflation() throw(ZlibBufferException);
51
virtual void reset_inflation() throw(ZlibBufferException);
52
virtual int consume_and_inflate();
53
virtual int do_consume_and_inflate(int nbytes);
54
virtual int consume(guint8 *buf, int nbytes);
55
virtual int do_consume(guint8 *buf, int nbytes);
56
virtual GByteArray *inflate(guint8 *in_buffer, int nbytes);
57
virtual GByteArray *do_inflate(guint8 *in_buffer, int nbytes);
58
virtual int copy_to_get(guint8 *data, int nbytes);
59
virtual int do_copy_to_get(guint8 *data, int nbytes);
61
URIHandle *_urihandle;
65
ZlibBuffer& operator=(ZlibBuffer const& rhs);
66
ZlibBuffer(ZlibBuffer const& rhs);
69
int _putsize, _getsize;//sizes of in and out buffers
73
class izstream : public std::istream {
76
explicit izstream(std::streambuf& sb) : std::istream(&sb) {}
77
~izstream() { std::ios::init(0); }
79
std::streambuf *rdbuf() { return std::ios::rdbuf(); }
80
std::streambuf *operator ->() { return rdbuf(); }
91
c-file-style:"stroustrup"
92
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
97
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :