RESTinio
|
Zlib transformator. More...
#include <zlib.hpp>
Public Member Functions | |
zlib_t (const params_t &transformation_params) | |
zlib_t (const zlib_t &)=delete | |
zlib_t (zlib_t &&)=delete | |
zlib_t & | operator= (const zlib_t &)=delete |
zlib_t & | operator= (zlib_t &&)=delete |
~zlib_t () | |
const params_t & | params () const |
Get parameters of current transformation. More... | |
void | write (string_view_t input) |
Append input data. More... | |
void | flush () |
Flush the zlib stream. More... | |
void | complete () |
Complete the stream. More... | |
std::string | giveaway_output () |
Get current accumulated output data. More... | |
auto | output_size () const |
Get current output size. More... | |
bool | is_completed () const |
Is operation complete? More... | |
Private Member Functions | |
bool | is_identity () const |
const char * | get_error_msg () const |
Get zlib error message if it exists. More... | |
void | ensure_operation_in_not_completed () const |
Checks completion flag and throws if operation is is already completed. More... | |
void | inc_buffer () |
Increment internal buffer for receiving output. More... | |
auto | prepare_out_buffer () |
Prepare out buffer for receiving data. More... | |
void | write_compress_impl (int flush) |
Handle incoming data for compression operation. More... | |
void | write_decompress_impl (int flush) |
Handle incoming data for decompression operation. More... | |
Private Attributes | |
const params_t | m_params |
Parameters for zlib. More... | |
bool | m_zlib_stream_initialized { false } |
Flag: was m_zlib_stream initialized properly. More... | |
z_stream | m_zlib_stream |
zlib stream. More... | |
std::string | m_out_buffer |
Output buffer. More... | |
std::size_t | m_write_pos { 0 } |
Next write pos in out buffer. More... | |
bool | m_operation_is_complete { false } |
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:
Advanced usage:
|
delete |
|
inline |
|
inlineprivate |
|
inline |
|
inlineprivate |
|
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:
At the point (2) consume_out()
function receives a string that is not an appended version of a string received in point (1).
|
inlineprivate |
|
inline |
|
inlineprivate |
|
inline |
|
inlineprivate |
|
inline |
|
inlineprivate |
|
inlineprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
Flag: was m_zlib_stream initialized properly.
If deflateInit2()/inflateInit2() was completed successfully it is needed to call deflateEnd()/inflateEnd().