This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user