Mineserver
A rewrite of Minecraft 1.8.9 in C++ !
Loading...
Searching...
No Matches
crypto::ZLibCompressor Class Reference

ZLib compressor. More...

#include <crypto.h>

Public Member Functions

 ZLibCompressor (int level)
 Construct a new Zlib Compressor object.
 
 ~ZLibCompressor ()=default
 Destroy the Zlib Compressor object.
 
int compress (const std::byte *data, size_t len, std::byte *out, size_t outLen)
 Compresses data (deflate)
 
int uncompress (const std::byte *data, size_t len, std::byte *out, size_t outLen)
 Uncompresses data (inflate)
 

Detailed Description

ZLib compressor.

Compressor class that wraps around zlib for compression or decompression.

Constructor & Destructor Documentation

◆ ZLibCompressor()

crypto::ZLibCompressor::ZLibCompressor ( int level)

Construct a new Zlib Compressor object.

Creates a compressor with a paramed zlib level going from 0 to 9 (0 means no compression and 9 means full compression). Set it to -1 to use the default compression.

Parameters
levelthe compression level

Member Function Documentation

◆ compress()

int crypto::ZLibCompressor::compress ( const std::byte * data,
size_t len,
std::byte * out,
size_t outLen )

Compresses data (deflate)

Compresses data buffer of length len and outputs it in the out buffer. It then returns the length of the written data.

Parameters
datathe data to compress
lenthe length of data
outthe output buffer, should be of length len if you want no risks
outLenthe output buffer length
Returns
int the written length

◆ uncompress()

int crypto::ZLibCompressor::uncompress ( const std::byte * data,
size_t len,
std::byte * out,
size_t outLen )

Uncompresses data (inflate)

Uncompresses data buffer of length len and outputs it in the out buffer. It then returns the length of the written data. The out buffer needs to be of the length of the uncompressed data.

Warning
Uncompress length need to be known
Parameters
datathe data to uncompress
lenthe length of data
outthe output buffer
outLenthe output buffer length
Returns
int the written length

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