libassetmap  1.0.0
Hash-table based archive format containing compressed data
Public Member Functions | List of all members
AssetMap::ICompress Class Referenceabstract
Inheritance diagram for AssetMap::ICompress:
Inheritance graph
[legend]

Public Member Functions

virtual size_t Compress (const uint8_t *src, size_t srcLen, uint8_t *dst, size_t dstLen)=0
 Compresses a range of data into an output buffer. More...
 
virtual size_t CalcCompressSize (size_t len) const noexcept=0
 Calculates the worst-case size (in bytes) required to compress data of length len. More...
 
virtual bool CreateDictionary (std::filesystem::directory_entry samplesDir)=0
 Creates a dictionary from a valid, readable directory, if it can. More...
 
virtual std::pair< const uint8_t *, size_t > Dictionary () const noexcept=0
 Obtains the dictionary pointer and size. More...
 
virtual void UseDictionary (const uint8_t *dict, size_t len) noexcept=0
 References a dictionary to use for compression. More...
 

Member Function Documentation

◆ CalcCompressSize()

virtual size_t AssetMap::ICompress::CalcCompressSize ( size_t  len) const
pure virtualnoexcept

Calculates the worst-case size (in bytes) required to compress data of length len.

Parameters
lenThe size (in bytes) to compress.
Returns
The worst-case amount of space needed as a dest buffer to Compress()

Implemented in AssetMap::ZSTD.

◆ Compress()

virtual size_t AssetMap::ICompress::Compress ( const uint8_t *  src,
size_t  srcLen,
uint8_t *  dst,
size_t  dstLen 
)
pure virtual

Compresses a range of data into an output buffer.

This function will compress a full sequence of data such that the output can be passed to an instance of IDecompress::Decompress and result in the same original input.

Precondition
It is implementation-defined whether src and dst may overlap. This is also true of passing any 0 lengths or a dstLen that is less than the result of CalcCompressSize. If dstLen is less than CalcCompressSize() there is no guarantee the compressed result contains the complete input data.
Parameters
srcA pointer to data at least srcLen in length.
srcLenThe length of data to compress.
dstA pointer to output
dstLen
Returns
The number of bytes written to the destination.

Implemented in AssetMap::ZSTD.

◆ CreateDictionary()

virtual bool AssetMap::ICompress::CreateDictionary ( std::filesystem::directory_entry  samplesDir)
pure virtual

Creates a dictionary from a valid, readable directory, if it can.

The directory is iterated recursively. How the dictionary is created is implementation defined. Typically a constructor will have been told a desired dictionary size. It is not an error for a dictionary to fail creation. This simply means the provided samples are not suitable for generating a dictionary.

Parameters
samplesDirA valid directory entry to use as samples.
Returns
a bool indicating whether dictionary creation succeeded.

Implemented in AssetMap::ZSTD.

◆ Dictionary()

virtual std::pair<const uint8_t*, size_t> AssetMap::ICompress::Dictionary ( ) const
pure virtualnoexcept

Obtains the dictionary pointer and size.

Precondition
CreateDictionary() must have been called and returned true.
Postcondition
The pointer is guaranteed to remain valid until another call to CreateDictionary() or destruction of the instance.
Returns
a pair consisting of a pointer to the data and its length.

Implemented in AssetMap::ZSTD.

◆ UseDictionary()

virtual void AssetMap::ICompress::UseDictionary ( const uint8_t *  dict,
size_t  len 
)
pure virtualnoexcept

References a dictionary to use for compression.

Precondition
dict must point to a valid dictionary of size len previously created by an instance of the same or compatible implementation.
Postcondition
dict must remain valid until all calls to Compress() have completed and no further calls are made.
Parameters
dictA pointer to the dictionary.
len

Implemented in AssetMap::ZSTD.


The documentation for this class was generated from the following file: