66 lines
2.0 KiB
C++
66 lines
2.0 KiB
C++
/**
|
|
* @file include/ActivMiddleware/ActivBase/Compress/ZstdCompressor.h
|
|
*
|
|
* @brief Header file for zstd compression class.
|
|
*/
|
|
|
|
#if (!defined ACTIV_COMPRESS_ZSTD_COMPRESSOR_H)
|
|
#define ACTIV_COMPRESS_ZSTD_COMPRESSOR_H
|
|
|
|
#include "ActivMiddleware/ActivBase/External.h"
|
|
#include "ActivMiddleware/ActivBase/Compress/ICompressor.h"
|
|
#include "ActivMiddleware/CxxYZ/memory.h"
|
|
|
|
//! Necessary Zstd stream forward declarations.
|
|
struct ZSTD_CCtx_s;
|
|
typedef struct ZSTD_CCtx_s ZSTD_CCtx;
|
|
struct ZSTD_DCtx_s;
|
|
typedef struct ZSTD_DCtx_s ZSTD_DCtx;
|
|
|
|
//! Activ namespace.
|
|
namespace Activ
|
|
{
|
|
|
|
//! Zstd compression and decompression class
|
|
class ZstdCompressor : public ICompressor
|
|
{
|
|
public:
|
|
//! Default constructor.
|
|
ACTIV_BASE_API
|
|
ZstdCompressor();
|
|
|
|
//! Destructor.
|
|
ACTIV_BASE_API
|
|
virtual ~ZstdCompressor() ACTIV_OVERRIDE;
|
|
|
|
// ICompressor interface.
|
|
using ICompressor::Compress;
|
|
using ICompressor::Decompress;
|
|
ACTIV_BASE_API
|
|
virtual StatusCode Compress(void *pDestination, const size_t destinationLength, const void *pSource, const size_t sourceLength,
|
|
size_t &compressedLength, Stats &stats) ACTIV_OVERRIDE;
|
|
ACTIV_BASE_API
|
|
virtual StatusCode Decompress(void *pDestination, const size_t destinationLength, const void *pSource,
|
|
const size_t sourceLength, size_t &decompressedLength, Stats &stats) ACTIV_OVERRIDE;
|
|
|
|
private:
|
|
//! The zstd context custom deleter class.
|
|
class ZstdContextDeleter
|
|
{
|
|
public:
|
|
void operator()(ZSTD_CCtx * const pCompressionStream) const;
|
|
|
|
void operator()(ZSTD_DCtx * const pDecompressionStream) const;
|
|
};
|
|
|
|
typedef CxxYZ::unique_ptr<ZSTD_CCtx, ZstdContextDeleter> CCtxPtr; ///< The compression context pointer type definition.
|
|
typedef CxxYZ::unique_ptr<ZSTD_DCtx, ZstdContextDeleter> DCtxPtr; ///< The decompression context pointer type definition.
|
|
|
|
CCtxPtr m_pCompressionContext; ///< The compression context pointer.
|
|
DCtxPtr m_pDecompressionContext; ///< The decompression context pointer.
|
|
};
|
|
|
|
} // namespace Activ
|
|
|
|
#endif // (!defined ACTIV_COMPRESS_ZSTD_COMPRESSOR_H)
|