Mineserver
A rewrite of Minecraft 1.8.9 in C++ !
|
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) | |
ZLib compressor.
Compressor class that wraps around zlib for compression or decompression.
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.
level | the compression level |
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.
data | the data to compress |
len | the length of data |
out | the output buffer, should be of length len if you want no risks |
outLen | the output buffer length |
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.
data | the data to uncompress |
len | the length of data |
out | the output buffer |
outLen | the output buffer length |