Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::Compressor Class Reference

Compressor class. More...

#include <Compressor.h>

Public Types

using OutputStream = sese::io::OutputStream
 

Public Member Functions

 Compressor (CompressionType type, size_t level, size_t buffer_size=ZLIB_CHUNK_SIZE)
 
virtual ~Compressor ()
 
void input (const void *input, unsigned int input_size)
 
int deflate (OutputStream *out)
 
int reset ()
 
size_t getTotalIn () const
 
size_t getTotalOut () const
 

Private Attributes

void * stream
 
size_t cap = 0
 Represents allocated buffer size.
 
size_t length = 0
 Represents filled buffer size.
 
size_t read = 0
 Represents read portion of the buffer.
 
unsigned char * buffer
 Internal buffer.
 

Detailed Description

Compressor class.

Member Typedef Documentation

◆ OutputStream

Constructor & Destructor Documentation

◆ Compressor()

sese::Compressor::Compressor ( sese::CompressionType type,
size_t level,
size_t buffer_size = ZLIB_CHUNK_SIZE )
explicit

Create a compressor

Parameters
typeCompression format - GZIP option is not recommended here
levelCompression level
buffer_sizeSet internal buffer size

References buffer, cap, and stream.

◆ ~Compressor()

sese::Compressor::~Compressor ( )
virtual

Member Function Documentation

◆ deflate()

int sese::Compressor::deflate ( OutputStream * out)

Perform compression

Parameters
outOutput stream for compressed data
Return values
Z_OK(0) Current buffer block compressed successfully
Z_STREAM_ERROR(-2) Other errors
Z_BUF_ERROR(-5) Output stream capacity insufficient

References read(), and sese::io::OutputStream::write().

◆ getTotalIn()

size_t sese::Compressor::getTotalIn ( ) const
nodiscard

Size of the currently processed input buffer

Returns
Buffer size

◆ getTotalOut()

size_t sese::Compressor::getTotalOut ( ) const
nodiscard

Size of the currently processed output buffer

Returns
Buffer size

References read().

◆ input()

void sese::Compressor::input ( const void * input,
unsigned int input_size )

Set the buffer to be compressed

Parameters
inputBuffer to be compressed
input_sizeSize of this buffer

◆ reset()

int sese::Compressor::reset ( )

Reset z_stream object

Returns
Result

References read().

Member Data Documentation

◆ buffer

unsigned char* sese::Compressor::buffer
private

Internal buffer.

Referenced by Compressor().

◆ cap

size_t sese::Compressor::cap = 0
private

Represents allocated buffer size.

Referenced by Compressor().

◆ length

size_t sese::Compressor::length = 0
private

Represents filled buffer size.

◆ read

size_t sese::Compressor::read = 0
private

Represents read portion of the buffer.

◆ stream

void* sese::Compressor::stream
private

Referenced by Compressor().


The documentation for this class was generated from the following files: