RPNX::Compress
Self-contained C++20 compression and ZIP library
 
Loading...
Searching...
No Matches
rpnx::compression::deflate_codec Namespace Reference

Internal implementation shared by raw DEFLATE, zlib, gzip, and ZIP. More...

Classes

class  huffman_decoder
 Canonical Huffman decoder for the bit-reversed codes used by DEFLATE. More...
 
class  iterator_bit_reader
 LSB-first bit reader that consumes a single-pass byte reader. More...
 
class  iterator_bit_writer
 LSB-first bit writer that emits bytes through an STL output iterator. More...
 

Functions

std::uint16_t reverse_bits (std::uint16_t value, std::uint8_t bit_count) noexcept
 Reverses the selected low bits for DEFLATE wire order.
 
template<typename writer_type>
void write_fixed_symbol (writer_type &writer, std::uint16_t symbol)
 Emits one fixed-Huffman literal or length symbol.
 
std::uint32_t crc32 (std::span< std::byte const > input) noexcept
 Computes the reflected IEEE CRC-32 used by gzip and ZIP.
 
template<typename writer_type>
void compress_fixed_block (writer_type &writer, std::span< std::byte const > input, bool final_block, std::int32_t level)
 Emits one fixed-Huffman DEFLATE block from a bounded search buffer.
 
template<std::input_iterator input_iterator, std::sentinel_for< input_iterator > sentinel, typename output_iterator>
output_iterator compress (format stream_format, input_iterator first, sentinel last, output_iterator output, compression_options const &options)
 Compresses an iterator range as raw DEFLATE, zlib, or gzip.
 
template<std::input_iterator input_iterator, std::sentinel_for< input_iterator > sentinel, typename output_iterator>
output_iterator decompress (format stream_format, input_iterator first, sentinel last, output_iterator output, decompression_options const &options)
 Decompresses raw DEFLATE, zlib, or gzip input.
 

Detailed Description

Internal implementation shared by raw DEFLATE, zlib, gzip, and ZIP.

Function Documentation

◆ compress()

template<std::input_iterator input_iterator, std::sentinel_for< input_iterator > sentinel, typename output_iterator>
output_iterator rpnx::compression::deflate_codec::compress ( format stream_format,
input_iterator first,
sentinel last,
output_iterator output,
compression_options const & options )

◆ compress_fixed_block()

template<typename writer_type>
void rpnx::compression::deflate_codec::compress_fixed_block ( writer_type & writer,
std::span< std::byte const > input,
bool final_block,
std::int32_t level )

Emits one fixed-Huffman DEFLATE block from a bounded search buffer.

Template Parameters
writer_typeLSB-first writer providing write_bits().
Parameters
writerDestination bit writer.
inputUncompressed block.
final_blockWhether to set the DEFLATE final-block bit.
levelCompression level controlling match-search depth.

Definition at line 317 of file deflate.hpp.

References reverse_bits(), and write_fixed_symbol().

Referenced by compress().

◆ crc32()

std::uint32_t rpnx::compression::deflate_codec::crc32 ( std::span< std::byte const > input)
inlinenodiscardnoexcept

Computes the reflected IEEE CRC-32 used by gzip and ZIP.

Parameters
inputBytes to checksum.
Returns
Finalized CRC-32.

Definition at line 183 of file deflate.hpp.

Referenced by rpnx::compression::create_zip(), and rpnx::compression::zip_detail::extract_archive().

◆ decompress()

template<std::input_iterator input_iterator, std::sentinel_for< input_iterator > sentinel, typename output_iterator>
output_iterator rpnx::compression::deflate_codec::decompress ( format stream_format,
input_iterator first,
sentinel last,
output_iterator output,
decompression_options const & options )

◆ reverse_bits()

std::uint16_t rpnx::compression::deflate_codec::reverse_bits ( std::uint16_t value,
std::uint8_t bit_count )
inlinenodiscardnoexcept

Reverses the selected low bits for DEFLATE wire order.

Parameters
valueValue containing the bits to reverse.
bit_countNumber of low bits to reverse.
Returns
Reversed bits in the low part of the result.

Definition at line 140 of file deflate.hpp.

Referenced by compress_fixed_block(), and write_fixed_symbol().

◆ write_fixed_symbol()

template<typename writer_type>
void rpnx::compression::deflate_codec::write_fixed_symbol ( writer_type & writer,
std::uint16_t symbol )

Emits one fixed-Huffman literal or length symbol.

Template Parameters
writer_typeLSB-first writer providing write_bits().
Parameters
writerDestination bit writer.
symbolDEFLATE literal, end-of-block, or length symbol.

Definition at line 158 of file deflate.hpp.

References reverse_bits().

Referenced by compress_fixed_block().