Gorgon Game Engine
LZMA Class Reference

This class allows encoding and decoding data using LZMA compression algorithm. More...

Public Types

typedef std::function< void(float)> ProgressNotification
 Callback to notify progress. The value is reported between 0 and 1. More...
 

Public Member Functions

 LZMA (bool useuncompressedsize=true)
 Default constructor. More...
 
template<class I_ , class O_ >
void Decode (I_ &input, O_ &output, Byte *compressionproperties=nullptr, unsigned long long fsize=(unsigned long long)(long long) -1)
 Decodes LZMA compressed data. More...
 
template<class I_ , class O_ >
void Decode (I_ &input, O_ &output, LZMA::ProgressNotification notifier, Byte *compressionproperties=nullptr, unsigned long long fsize=(unsigned long long)(long long) -1)
 Decodes LZMA compressed data. More...
 
template<class I_ , class O_ >
void Encode (I_ &input, O_ &output)
 Encodes the given data to LZMA compressed data. More...
 
template<class I_ , class O_ >
void Encode (I_ &input, O_ &output, ProgressNotification notifier)
 Encodes the given data to LZMA compressed data. More...
 
int PropertySize ()
 The size of the compression property data appended in front of the compressed data. More...
 

Public Attributes

bool UseUncompressedSize
 Whether to encode uncompressed size with the compression properties. Default value for this variable is true. More...
 

Protected Member Functions

void decode (lzma::Reader *reader, lzma::Writer *writer, unsigned long long size, std::function< void(lzma::Reader *, long long)> seekfn, Byte *cprops, unsigned long long fsize, ProgressNotification *notifier)
 Performs actual decompression, notifier and cprops can be nullptr. More...
 
void encode (lzma::Reader *reader, lzma::Writer *writer, unsigned long long size, ProgressNotification *notifier)
 Performs actual compression, notifier can be nullptr. More...
 

Detailed Description

This class allows encoding and decoding data using LZMA compression algorithm.

Member Typedef Documentation

◆ ProgressNotification

typedef std::function<void(float)> ProgressNotification

Callback to notify progress. The value is reported between 0 and 1.

Constructor & Destructor Documentation

◆ LZMA()

LZMA ( bool  useuncompressedsize = true)

Default constructor.

Member Function Documentation

◆ Decode() [1/2]

void Decode ( I_ &  input,
O_ &  output,
Byte compressionproperties = nullptr,
unsigned long long  fsize = (unsigned long long)(long long)-1 
)

Decodes LZMA compressed data.

Supports vectors, arrays, strings and streams as data source and targets.

Parameters
inputInput data
outputOutput data
compressionpropertiesis the compression property data. Leaving this parameter with default nullptr, causes this function to read the actual compression properties from the main data source.
fsizesize of the extracted data. This value is only used if UseUncompressedSize is false. Default value of -1 relies on LZMA to terminate extraction.
Warning
Using this system with arrays is extremely dangerous make sure your arrays are big enough
Exceptions
runtime_error

References LZMA::decode().

◆ Decode() [2/2]

void Decode ( I_ &  input,
O_ &  output,
LZMA::ProgressNotification  notifier,
Byte compressionproperties = nullptr,
unsigned long long  fsize = (unsigned long long)(long long)-1 
)

Decodes LZMA compressed data.

Supports vectors, arrays, strings and streams as data source and targets. This variant allows a notification function which is called during decompression.

Parameters
inputInput data
outputOutput data
notifieris the callback to send notifications to
compressionpropertiesis the compression property data. Leaving this parameter with default nullptr, causes this function to read the actual compression properties from the main data source.
fsizesize of the extracted data. This value is only used if UseUncompressedSize is false. Default value of -1 relies on LZMA to terminate extraction. Additionally, -1 will cause progress notification to report 0.
Warning
Using this system with arrays is extremely dangerous make sure your arrays are big enough
Exceptions
runtime_error

References LZMA::decode().

◆ decode()

void decode ( lzma::Reader *  reader,
lzma::Writer *  writer,
unsigned long long  size,
std::function< void(lzma::Reader *, long long)>  seekfn,
Byte cprops,
unsigned long long  fsize,
LZMA::ProgressNotification notifier 
)
protected

Performs actual decompression, notifier and cprops can be nullptr.

References LZMA::UseUncompressedSize.

◆ Encode() [1/2]

void Encode ( I_ &  input,
O_ &  output 
)

Encodes the given data to LZMA compressed data.

Supports vectors, arrays, strings and streams as data source and targets.

Warning
Using this system with arrays is extremely dangerous make sure your arrays are big enough
Exceptions
runtime_error

References LZMA::encode().

◆ Encode() [2/2]

void Encode ( I_ &  input,
O_ &  output,
ProgressNotification  notifier 
)

Encodes the given data to LZMA compressed data.

Supports vectors, arrays, strings and streams as data source and targets. This variant allows a notification function which is called during compression.

Warning
Using this system with arrays is extremely dangerous make sure your arrays are big enough
Exceptions
runtime_error

References LZMA::encode().

◆ encode()

void encode ( lzma::Reader *  reader,
lzma::Writer *  writer,
unsigned long long  size,
LZMA::ProgressNotification notifier 
)
protected

Performs actual compression, notifier can be nullptr.

References LZMA::UseUncompressedSize.

◆ PropertySize()

int PropertySize ( )

The size of the compression property data appended in front of the compressed data.

References LZMA::UseUncompressedSize.

Member Data Documentation

◆ UseUncompressedSize

bool UseUncompressedSize

Whether to encode uncompressed size with the compression properties. Default value for this variable is true.


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