Class StreamPeerGZIP
A stream peer that handles GZIP and deflate compression/decompression.
- Inheritance
-
StreamPeerGZIP
Remarks
This class allows to compress or decompress data using GZIP/deflate in a streaming fashion. This is particularly useful when compressing or decompressing files that have to be sent through the network without needing to allocate them all in memory.
After starting the stream via StreamPeerGZIP.start_compression (or StreamPeerGZIP.start_decompression), calling StreamPeer.put_partial_data on this stream will compress (or decompress) the data, writing it to the internal buffer. Calling get_available_bytes will return the pending bytes in the internal buffer, and StreamPeer.get_partial_data will retrieve the compressed (or decompressed) bytes from it. When the stream is over, you must call finish to ensure the internal buffer is properly flushed (make sure to call get_available_bytes on last time to check if more data needs to be read after that).
Methods
clear
Clears this stream, resetting the internal state.
void clear
finish
Finalizes the stream, compressing or decompressing any buffered chunk left.
int finish
start_compression(bool, int)
Start the stream in compression mode with the given buffer_size
, if use_deflate
is true
uses deflate instead of GZIP.
int start_compression(bool use_deflate, int buffer_size)
Parameters
start_decompression(bool, int)
Start the stream in decompression mode with the given buffer_size
, if use_deflate
is true
uses deflate instead of GZIP.
int start_decompression(bool use_deflate, int buffer_size)