Tkrzw
Public Types | Public Member Functions | List of all members
tkrzw::LZMACompressor Class Referencefinal

Compressor implemeted with LZMA. More...

#include <tkrzw_compress.h>

Public Types

enum  MetadataMode : int32_t { METADATA_NONE = 0 , METADATA_CRC32 = 2 , METADATA_SHA256 = 1 }
 Enumeration for metadata modes. More...
 

Public Member Functions

 LZMACompressor (int32_t level=6, MetadataMode metadata_mode=METADATA_NONE)
 Constructor. More...
 
virtual ~LZMACompressor ()
 Destructor. More...
 
bool IsSupported () const override
 Checks whether the implementation is actually supported. More...
 
char * Compress (const void *buf, size_t size, size_t *sp) const override
 Compresses a serial data. More...
 
char * Decompress (const void *buf, size_t size, size_t *sp) const override
 Decompresses a serial data. More...
 
std::unique_ptr< CompressorMakeCompressor () const override
 Makes a new Compressor object of the same concrete class. More...
 
- Public Member Functions inherited from tkrzw::Compressor
virtual ~Compressor ()=default
 Destructor. More...
 
const std::type_info & GetType () const
 Gets the type information of the actual class. More...
 

Detailed Description

Compressor implemeted with LZMA.

Member Enumeration Documentation

◆ MetadataMode

Enumeration for metadata modes.

Enumerator
METADATA_NONE 

Without any checksum.

METADATA_CRC32 

With CRC-32 checksum.

METADATA_SHA256 

With SHA-256 checksum.

Constructor & Destructor Documentation

◆ LZMACompressor()

tkrzw::LZMACompressor::LZMACompressor ( int32_t  level = 6,
MetadataMode  metadata_mode = METADATA_NONE 
)
explicit

Constructor.

Parameters
levelThe compression level between 0 and 9. Higher means slower but better compression. 0 means no compression.
metadata_modeThe mode for the metadata added to the result.

◆ ~LZMACompressor()

virtual tkrzw::LZMACompressor::~LZMACompressor ( )
virtual

Destructor.

Member Function Documentation

◆ IsSupported()

bool tkrzw::LZMACompressor::IsSupported ( ) const
overridevirtual

Checks whether the implementation is actually supported.

Returns
True if the implementation is actually supported.

Implements tkrzw::Compressor.

◆ Compress()

char* tkrzw::LZMACompressor::Compress ( const void *  buf,
size_t  size,
size_t *  sp 
) const
overridevirtual

Compresses a serial data.

Parameters
bufthe input buffer.
sizethe size of the input buffer.
spthe pointer to the variable into which the size of the region of the return value is assigned.
Returns
The pointer to the result data, or nullptr on failure.

Because the region of the return value is allocated with the xmalloc function, it should be released with the xfree function.

Implements tkrzw::Compressor.

◆ Decompress()

char* tkrzw::LZMACompressor::Decompress ( const void *  buf,
size_t  size,
size_t *  sp 
) const
overridevirtual

Decompresses a serial data.

Parameters
bufthe input buffer.
sizethe size of the input buffer.
spthe pointer to the variable into which the size of the region of the return value is assigned.
Returns
The pointer to the result data, or nullptr on failure.

Because the region of the return value is allocated with the xmalloc function, it should be released with the xfree function.

Implements tkrzw::Compressor.

◆ MakeCompressor()

std::unique_ptr<Compressor> tkrzw::LZMACompressor::MakeCompressor ( ) const
overridevirtual

Makes a new Compressor object of the same concrete class.

Returns
The new Compressor object.

Implements tkrzw::Compressor.