BEEP-8 Helper Lib 1.0.0
Loading...
Searching...
No Matches
zpack.h File Reference

Header file for ZPack compression and decompression classes. More...

#include <memory>
#include <b8/type.h>
#include <pipe.h>

Go to the source code of this file.

Classes

class  ZPack::CZPackEncoder
 Class for encoding data streams using various compression methods. More...
 
class  ZPack::CZPackDecoder
 Class for decoding data streams encoded with ZPack compression methods. More...
 

Enumerations

enum  ZPack::CompressionMethod { ZPack::HuffmanToRle , ZPack::Huffman , ZPack::Flat , ZPack::FlatWithSize }
 Enum representing the available compression methods. More...
 

Variables

constexpr u8 ZPack::Signature = 0x99
 

Detailed Description

Header file for ZPack compression and decompression classes.

This module provides functionality for compressing and decompressing data using various methods including Huffman encoding, Run-Length Encoding (RLE), and their combinations. The primary classes are CZPackEncoder and CZPackDecoder, which handle the encoding and decoding of data streams respectively.

The ZPack format supports the following compression methods:

  • Huffman followed by RLE (HuffmanToRle)
  • Huffman only (Huffman)
  • No compression (Flat)
  • No compression with original size (FlatWithSize)

Example usage:

// Create pipes for input and output
auto pipe_in = std::make_shared<Pipe::CMemBufferPipe>();
auto pipe_out = std::make_shared<Pipe::CMemBufferPipe>();
// Fill the input pipe with data
pipe_in->Push('a');
pipe_in->Push('b');
pipe_in->Push('c');
// Create and configure the encoder
encoder.SetIn(pipe_in);
encoder.SetOut(pipe_out);
encoder.Encode();
// Create and configure the decoder
auto decoded_pipe = std::make_shared<Pipe::CMemBufferPipe>();
decoder.SetIn(pipe_out);
decoder.SetOut(decoded_pipe);
auto result = decoder.Decode();
// Process the decoded data
}
Class for decoding data streams encoded with ZPack compression methods.
Definition zpack.h:119
CZPackDecoder::DecodeResult Decode()
Decodes the data from the input pipe and writes it to the output pipe.
Definition zpack.cpp:106
void SetIn(std::shared_ptr< Pipe::CPipe > pipe_in_)
Sets the input pipe for the decoder.
Definition zpack.cpp:98
void SetOut(std::shared_ptr< Pipe::CPipe > pipe_out_)
Sets the output pipe for the decoder.
Definition zpack.cpp:102
@ DECODE_OK
Decoding was successful.
Definition zpack.h:128
Class for encoding data streams using various compression methods.
Definition zpack.h:89
void SetIn(std::shared_ptr< Pipe::CPipe > pipe_in_)
Sets the input pipe for the encoder.
Definition zpack.cpp:19
void Encode()
Encodes the data from the input pipe and writes it to the output pipe.
Definition zpack.cpp:27
void SetOut(std::shared_ptr< Pipe::CPipe > pipe_out_)
Sets the output pipe for the encoder.
Definition zpack.cpp:23

Note: This module is designed for compression and decompression of data streams and is not thread-safe.

Enumeration Type Documentation

◆ CompressionMethod

Enum representing the available compression methods.

Enumerator
HuffmanToRle 

Huffman encoding followed by Run-Length Encoding (RLE)

Huffman 

Huffman encoding only.

Flat 

No compression.

FlatWithSize 

No compression, includes original size.