Supported callbacks are:

  • Total callback (signature: void( uint64_t )), whose argument is the total size of the archive to be extracted or of the files to be compressed (it is called at the beginning of any operation).
  • Progress callback (signature: void( uint64_t )), whose argument is the current processed size; calculating the ratio between the processed size and the total size (given by the total callback) gives the current operation progress (e.g. static_cast<int>( ( 100.0 * completed ) / total ))
  • Ratio callback (signature: void( uint64_t, uint64_t )), in which the two arguments are, respectively, the input size and output size (e.g. compression ratio can be calculated as static_cast<int>( ( 100.0 * out_size ) / in_size )).
  • File callback (signature: void( wstring )), whose argument is the name of the file currently being processed.
  • Password callback (signature: wstring()), which is called when a password was not specified in code (e.g. through setPassword method) but it is needed in order to open and/or extract the archive; the callback must return a wstring containing the password entered by the user.

Callbacks are stored as std::functions, hence callbacks can be lambdas, free functions, member functions, etc...

In order to set a callback you should call the appropriate setter function (inherited by the base class BitArchiveHandler) of the compressor or extractor class being used.


// ...
compressor.setRatioCallback( []( uint64_t in_size, uint64_t out_size ) {
    std::cout << "Current compression ratio: " << static_cast<int>( ( 100.0 * out_size ) / in_size ) << "%" << std::endl;
} );
// ...

Compression Methods

Each format supports only a limited number of compression methods (BitCompressionMethod), as summarized in the following table:

Copy :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :x: :x: :x:
Ppmd :heavy_check_mark: :heavy_check_mark: :x: :x: :x: :x: :x:
Lzma :heavy_check_mark: :heavy_check_mark: :x: :x: :x: :x: :x:
Lzma2 :heavy_check_mark: :x: :x: :x: :heavy_check_mark: :x: :x:
BZip2 :heavy_check_mark: :heavy_check_mark: :x: :x: :x: :heavy_check_mark: :x:
Deflate :x: :heavy_check_mark: :x: :x: :x: :x: :heavy_check_mark:
Deflate64 :x: :heavy_check_mark: :x: :x: :x: :x: :x:

Add Discussion as Guest

Log in