Zlib transformator.
Uses zlib (https://zlib.net) for gzip/deflate compresion/decompression. All higher level functionality that minimizes boilerplate code and makes compression and decompression logic less verbose is based on using zlib_t.
Simple usage:
rtz::zlib_t z{ rtz::make_gzip_compress_params( compression_level ).level( 9 ) };
z.write( input_data );
z.complete();
auto gziped_data = z.giveaway_output();
Advanced usage:
rtz::zlib_t z{ rtz::make_gzip_compress_params( compression_level ).level( 9 ) };
std::size_t processed_data = 0;
for( const auto d : data_pieces )
{
z.write( d );
processed_data += d.size();
if( processed_data > 1024 * 1024 )
{
z.flush();
}
if( z.output_size() > 100 * 1024 )
{
append_output( z.giveaway_output() );
}
}
z.complete();
append_output( z.giveaway_output() );
- Since
- v.0.4.4
Definition at line 478 of file zlib.hpp.
std::string restinio::transforms::zlib::zlib_t::giveaway_output |
( |
| ) |
|
|
inline |
Get current accumulated output data.
On this request a current accumulated output data is reterned. Move semantics is applied. Once current output is fetched zlib_t object resets its internal out buffer.
In the following code:
restinio::transformator::zlib_t z{ restinio::transformator::gzip_compress() };
z.write( A );
consume_out( z.giveaway_output() );
z.write( B );
z.write( C );
consume_out( z.giveaway_output() );
At the point (2) consume_out()
function receives a string that is not an appended version of a string received in point (1).
Definition at line 684 of file zlib.hpp.