boost::capy::zlib::deflate_service
Provides the ZLib compression API.
Synopsis
Declared in <boost/capy/zlib/deflate.hpp>
struct deflate_service;
Description
This service interface exposes the ZLib deflate (compression) functionality through a set of virtual functions. The deflate algorithm compresses data by finding repeated byte sequences and encoding them efficiently using a combination of LZ77 and Huffman coding.
The windowBits parameter in init2() controls the format: ‐ 8..15: zlib format with specified window size ‐ ‐8..‐15: raw deflate format (no header/trailer) ‐ 16+windowBits: gzip format
// Example: Basic compression
boost::capy::datastore ctx;
auto& deflate_svc = boost::capy::zlib::install_deflate_service(ctx);
boost::capy::zlib::stream st = {};
std::vector<unsigned char> input_data = get_data();
std::vector<unsigned char> output(input_data.size() * 2);
st.zalloc = nullptr;
st.zfree = nullptr;
st.opaque = nullptr;
deflate_svc.init(st, boost::capy::zlib::default_compression);
st.avail_in = input_data.size();
st.next_in = input_data.data();
st.avail_out = output.size();
st.next_out = output.data();
deflate_svc.deflate(st, boost::capy::zlib::finish);
output.resize(st.total_out);
deflate_svc.deflate_end(st);
// Example: Gzip compression with custom window size
boost::capy::zlib::stream st = {};
st.zalloc = nullptr;
st.zfree = nullptr;
// Use gzip format (16 + 15 for max window)
deflate_svc.init2(st,
6, // level
boost::capy::zlib::deflated, // method
16 + 15, // gzip format
8, // memLevel
boost::capy::zlib::default_strategy); // strategy
// Compress data...
deflate_svc.deflate_end(st);
Member Functions
Name |
Description |
|
Return an upper bound on compressed size. |
|
Compress data in the stream. |
|
Release all resources held by the deflate stream. |
|
Duplicate a deflate stream. |
|
Return the current compression dictionary. |
|
Initialize deflate compression. |
|
Initialize deflate compression with extended parameters. |
|
Dynamically update compression parameters. |
|
Return the number of pending output bytes. |
|
Insert bits into the compressed stream. |
|
Reset the deflate stream state. |
|
Set the compression dictionary. |
|
Set the gzip header information. |
|
Return the ZLib version string. |
Non-Member Functions
Name |
Description |
Install the deflate service into a polystore. |
Created with MrDocs