finish io
All checks were successful
Linux arm64 / Build (push) Successful in 19s

This commit is contained in:
2025-06-27 18:53:03 +02:00
parent 0d26879152
commit ed0b06f78d
11 changed files with 443 additions and 54 deletions

View File

@@ -6,20 +6,7 @@
*/
#include <cstdint>
#include <sp/common/DataBuffer.h>
namespace sp {
namespace option {
struct ZlibCompress {
bool m_Enabled = true;
std::size_t m_CompressionThreshold = 64;
};
} // namespace option
} // namespace sp
#include <sp/io/IOInterface.h>
#include <sp/io/MessageEncapsulator.h>
namespace sp {
namespace zlib {
@@ -41,14 +28,20 @@ DataBuffer Decompress(DataBuffer& buffer, std::uint64_t packetLength);
} // namespace zlib
namespace io {
template <>
class MessageEncapsulator<option::ZlibCompress> {
class ZlibCompress : public MessageEncapsulator {
private:
std::size_t m_CompressionThreshold;
public:
static DataBuffer Encapsulate(const DataBuffer& a_Data, const option::ZlibCompress& a_Option);
static DataBuffer Decapsulate(DataBuffer& a_Data, const option::ZlibCompress& a_Option);
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 io
} // namespace sp
} // namespace sp