Zlib transformator.
More...
#include <zlib.hpp>
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:
run_on_this_thread_settings_t< Traits > on_this_thread()
A special marker for the case when http_server must be run on the context of the current thread.
Advanced usage:
{
{
}
if(
z.output_size() > 100 * 1024 )
{
}
}
- Since
- v.0.4.4
Definition at line 474 of file zlib.hpp.
◆ zlib_t() [1/3]
restinio::transforms::zlib::zlib_t::zlib_t |
( |
const params_t & |
transformation_params | ) |
|
|
inline |
◆ zlib_t() [2/3]
restinio::transforms::zlib::zlib_t::zlib_t |
( |
const zlib_t & |
| ) |
|
|
delete |
◆ zlib_t() [3/3]
restinio::transforms::zlib::zlib_t::zlib_t |
( |
zlib_t && |
| ) |
|
|
delete |
◆ ~zlib_t()
restinio::transforms::zlib::zlib_t::~zlib_t |
( |
| ) |
|
|
inline |
◆ complete()
void restinio::transforms::zlib::zlib_t::complete |
( |
| ) |
|
|
inline |
Complete the stream.
Definition at line 633 of file zlib.hpp.
◆ ensure_operation_in_not_completed()
void restinio::transforms::zlib::zlib_t::ensure_operation_in_not_completed |
( |
| ) |
const |
|
inlineprivate |
Checks completion flag and throws if operation is is already completed.
Definition at line 713 of file zlib.hpp.
◆ flush()
void restinio::transforms::zlib::zlib_t::flush |
( |
| ) |
|
|
inline |
Flush the zlib stream.
Flushes underlying zlib stream. All pending output is flushed to the output buffer.
Definition at line 611 of file zlib.hpp.
◆ get_error_msg()
const char * restinio::transforms::zlib::zlib_t::get_error_msg |
( |
| ) |
const |
|
inlineprivate |
Get zlib error message if it exists.
Definition at line 702 of file zlib.hpp.
◆ giveaway_output()
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() };
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 678 of file zlib.hpp.
◆ inc_buffer()
void restinio::transforms::zlib::zlib_t::inc_buffer |
( |
| ) |
|
|
inlineprivate |
Increment internal buffer for receiving output.
Definition at line 721 of file zlib.hpp.
◆ is_completed()
bool restinio::transforms::zlib::zlib_t::is_completed |
( |
| ) |
const |
|
inline |
Is operation complete?
Definition at line 692 of file zlib.hpp.
◆ is_identity()
bool restinio::transforms::zlib::zlib_t::is_identity |
( |
| ) |
const |
|
inlineprivate |
◆ operator=() [1/2]
◆ operator=() [2/2]
zlib_t & restinio::transforms::zlib::zlib_t::operator= |
( |
zlib_t && |
| ) |
|
|
delete |
◆ output_size()
auto restinio::transforms::zlib::zlib_t::output_size |
( |
| ) |
const |
|
inline |
Get current output size.
Definition at line 689 of file zlib.hpp.
◆ params()
const params_t & restinio::transforms::zlib::zlib_t::params |
( |
| ) |
const |
|
inline |
Get parameters of current transformation.
Definition at line 557 of file zlib.hpp.
◆ prepare_out_buffer()
auto restinio::transforms::zlib::zlib_t::prepare_out_buffer |
( |
| ) |
|
|
inlineprivate |
Prepare out buffer for receiving data.
Definition at line 729 of file zlib.hpp.
◆ write()
Append input data.
Pushes a given data to zlib transform. input is the data to be compressed or decompressed.
Definition at line 565 of file zlib.hpp.
◆ write_compress_impl()
void restinio::transforms::zlib::zlib_t::write_compress_impl |
( |
int |
flush | ) |
|
|
inlineprivate |
Handle incoming data for compression operation.
Definition at line 749 of file zlib.hpp.
◆ write_decompress_impl()
void restinio::transforms::zlib::zlib_t::write_decompress_impl |
( |
int |
flush | ) |
|
|
inlineprivate |
Handle incoming data for decompression operation.
Definition at line 798 of file zlib.hpp.
◆ m_operation_is_complete
bool restinio::transforms::zlib::zlib_t::m_operation_is_complete { false } |
|
private |
◆ m_out_buffer
std::string restinio::transforms::zlib::zlib_t::m_out_buffer |
|
private |
Output buffer.
Definition at line 850 of file zlib.hpp.
◆ m_params
Parameters for zlib.
Definition at line 837 of file zlib.hpp.
◆ m_write_pos
std::size_t restinio::transforms::zlib::zlib_t::m_write_pos { 0 } |
|
private |
Next write pos in out buffer.
Definition at line 852 of file zlib.hpp.
◆ m_zlib_stream
z_stream restinio::transforms::zlib::zlib_t::m_zlib_stream |
|
private |
◆ m_zlib_stream_initialized
bool restinio::transforms::zlib::zlib_t::m_zlib_stream_initialized { false } |
|
private |
Flag: was m_zlib_stream initialized properly.
If deflateInit2()/inflateInit2() was completed successfully it is needed to call deflateEnd()/inflateEnd().
Definition at line 844 of file zlib.hpp.
The documentation for this class was generated from the following file: