add /coders/compression module

This commit is contained in:
MihailRis
2024-09-01 21:58:33 +03:00
parent 0f53d5b835
commit 7d193941a4
7 changed files with 170 additions and 86 deletions
+30
View File
@@ -0,0 +1,30 @@
#pragma once
#include <memory>
#include "typedefs.hpp"
namespace compression {
enum class Method {
NONE, EXTRLE8, GZIP
};
/// @brief Compress buffer
/// @param src source buffer
/// @param srclen length of the source buffer
/// @param len (out argument) length of result buffer
/// @param method compression method
/// @return compressed bytes array
/// @throws std::invalid_argument if compression method is NONE
std::unique_ptr<ubyte[]> compress(
const ubyte* src, size_t srclen, size_t& len, Method method
);
/// @brief Decompress buffer
/// @param src compressed buffer
/// @param srclen length of compressed buffer
/// @param dstlen max expected length of source buffer
/// @return decompressed bytes array
std::unique_ptr<ubyte[]> decompress(
const ubyte* src, size_t srclen, size_t dstlen, Method method);
}