1 #ifndef _library__zlibstream__hpp__included__
2 #define _library__zlibstream__hpp__included__
8 #define ZLIB_PAGE_STORAGE 65500
16 * Create new zlib stream.
18 * Parameter compression: The compression level.
20 zlibstream(unsigned compression
);
22 * Destroy zlib stream.
26 * Reset the stream, adding some initial data.
28 * Parameter data: The data to write (may be NULL if datalen=0).
29 * Parameter datalen: The length of data.
31 void reset(uint8_t* data
, size_t datalen
);
33 * Write data into stream.
35 * Parameter data: The data to write.
36 * Parameter datalen: The length of data.
38 void write(uint8_t* data
, size_t datalen
);
40 * Read the data as buffer.
42 * Parameter out: The buffer to write to.
44 void read(std::vector
<char>& out
);
46 * Read the data so far as buffer and empty compressed data.
48 * This performs a sync flush.
50 * Parameter out: The buffer to write to.
52 void readsync(std::vector
<char>& out
);
54 * Clear the output stream and add some uncompressed data.
56 * This is useful after doing readsync().
58 * Parameter data: The data to write (may be NULL if datalen=0).
59 * Parameter datalen: The length of data.
61 void adddata(uint8_t* data
, size_t datalen
);
65 * Parameter f: New flag value.
67 void set_flag(bool f
);
71 * Returns: Flag value.
77 uint8_t data
[ZLIB_PAGE_STORAGE
];
81 void _read(std::vector
<char>& out
, int mode
);
82 void _reset(uint8_t* data
, size_t datalen
, bool doactually
);
83 void flushpage(uint8_t* data
, size_t datalen
, int mode
);
84 zlibstream(zlibstream
&);
85 zlibstream
& operator=(zlibstream
&);
88 std::list
<page
> storage
;