Files
Persson-dev ed0b06f78d
All checks were successful
Linux arm64 / Build (push) Successful in 19s
finish io
2025-06-27 18:53:03 +02:00

47 lines
1.0 KiB
C++

#pragma once
/**
* \file Compression.h
* \brief File containing compress utilities
*/
#include <cstdint>
#include <sp/io/MessageEncapsulator.h>
namespace sp {
namespace zlib {
/**
* \brief Compress some data
* \param buffer the data to compress
* \return the compressed data
*/
DataBuffer Compress(const DataBuffer& buffer, std::size_t a_CompressionThreshold = 64);
/**
* \brief Uncompress some data
* \param buffer the data to uncompress
* \param packetLength lenght of data
* \return the uncompressed data
*/
DataBuffer Decompress(DataBuffer& buffer, std::uint64_t packetLength);
} // namespace zlib
class ZlibCompress : public MessageEncapsulator {
private:
std::size_t m_CompressionThreshold;
public:
ZlibCompress() : m_CompressionThreshold(64) {}
ZlibCompress(const ZlibCompress&) = default;
virtual ~ZlibCompress() {}
protected:
virtual DataBuffer EncapsulateImpl(const DataBuffer& a_Data) override;
virtual DataBuffer DecapsulateImpl(DataBuffer& a_Data) override;
};
} // namespace sp