Data & serialization

compress.h

Compress and decompress complete byte strings using gzip.

C++23 mc/compress.h
#include <mc/compress.h>

The returned cstr may contain embedded NUL bytes. Preserve its length when storing or transmitting it.

Jump to a declaration · 2

Free functions & types

Functions

cCompress

inline cstr cCompress(const cstr& str);

Returns gzip-compressed bytes using the best-compression setting. The result is binary data held in a cstr and can contain NUL bytes.

cDecompress

inline cstr cDecompress(const cstr& str);

Expands gzip data into its original bytes. Invalid or incomplete compressed data can raise an exception from the compression library.