Skip to content

BitStreamCompressor

Oz edited this page Sep 3, 2019 · 9 revisions
#include "bitstreamcompressor.hpp"

inherits from BitArchiveCreator.

List of all members

Public Members

Return type Name
BitStreamCompressor( const Bit7zLibrary &lib, const BitInOutFormat &format )
void compress( istream &in_stream, ostream &out_stream, const wstring &in_stream_name=L"" ) const
void compress( istream &in_stream, vector< byte_t > &out_buffer, const wstring &in_stream_name=L"" ) const
void compress( istream &in_stream, const wstring &out_file, const wstring &in_stream_name=L"" ) const
const BitInFormat & format() const override
const BitInOutFormat & compressionFormat() const
bool cryptHeaders() const
BitCompressionLevel compressionLevel() const
BitCompressionMethod compressionMethod() const
uint32_t dictionarySize() const
bool solidMode() const
bool updateMode() const
uint64_t volumeSize() const
void setPassword( const wstring &password ) override
void setPassword( const wstring &password, bool crypt_headers )
void setCompressionLevel( BitCompressionLevel compression_level )
void setCompressionMethod( BitCompressionMethod compression_method )
void setDictionarySize( uint32_t dictionary_size )
void setSolidMode( bool solid_mode )
void setUpdateMode( bool update_mode )
void setVolumeSize( uint64_t size )
const Bit7zLibrary & library() const
const wstring password() const
bool isPasswordDefined() const
TotalCallback totalCallback() const
ProgressCallback progressCallback() const
RatioCallback ratioCallback() const
FileCallback fileCallback() const
PasswordCallback passwordCallback() const
void clearPassword()
void setTotalCallback( const TotalCallback &callback )
void setProgressCallback( const ProgressCallback &callback )
void setRatioCallback( const RatioCallback &callback )
void setFileCallback( const FileCallback &callback )
void setPasswordCallback( const PasswordCallback &callback )

Member Function Documentation

BitStreamCompressor( const Bit7zLibrary &lib, const BitInOutFormat &format )

Constructs a BitStreamCompressor object.

The Bit7zLibrary parameter is needed in order to have access to the functionalities of the 7z DLLs. On the other hand, the BitInOutFormat is required in order to know the format of the input archive.


void compress( istream &in_stream, ostream &out_stream, const wstring &in_stream_name=L"" ) const

Compresses the given standard istream to the standard ostream.


void compress( istream &in_stream, vector< byte_t > &out_buffer, const wstring &in_stream_name=L"" ) const

Compresses the given standard istream to the output buffer.


void compress( istream &in_stream, const wstring &out_file, const wstring &in_stream_name=L"" ) const

Compresses the given standard istream to an archive on the filesystem.


[virtual] const BitInFormat & format() const override

Returns the format used by the archive creator.


const BitInOutFormat & compressionFormat() const

Returns the format used by the archive creator.


bool cryptHeaders() const

Returns whether the creator crypts also the headers of archives or not


BitCompressionLevel compressionLevel() const

Returns the compression level used by the archive creator.


BitCompressionMethod compressionMethod() const

Returns the compression method used by the archive creator.


uint32_t dictionarySize() const

Returns the dictionary size used by the archive creator.


bool solidMode() const

Returns whether the archive creator uses solid compression or not.


bool updateMode() const

Returns whether the archive creator is allowed to update existing archives or not.


uint64_t volumeSize() const

Returns the size (in bytes) of the archive volume used by the creator (a 0 value means that all files are going in a single archive).


[virtual] void setPassword( const wstring &password ) override

Sets up a password for the output archive.

When setting a password, the produced archive will be encrypted using the default cryptographic method of the output format. The option "crypt headers" remains unchanged, in contrast with what happens when calling the setPassword(wstring, bool) method.

Note: Calling setPassword when the output format doesn't support archive encryption (e.g. GZip, BZip2, etc...) does not have any effects (in other words, it doesn't throw exceptions and it has no effects on compression operations).


void setPassword( const wstring &password, bool crypt_headers )

Sets up a password for the output archive.

When setting a password, the produced archive will be encrypted using the default cryptographic method of the output format. If the format is 7z and the option "crypt_headers" is set to true, also the headers of the archive will be encrypted, resulting in a password request everytime the output file will be opened.

Note: Calling setPassword when the output format doesn't support archive encryption (e.g. GZip, BZip2, etc...) does not have any effects (in other words, it doesn't throw exceptions and it has no effects on compression operations).


void setCompressionLevel( BitCompressionLevel compression_level )

Sets the compression level to be used when creating an archive.


void setCompressionMethod( BitCompressionMethod compression_method )

Sets the compression method to be used when creating an archive.


void setDictionarySize( uint32_t dictionary_size )

Sets the dictionary size to be used when creating an archive.


void setSolidMode( bool solid_mode )

Sets whether to use solid compression or not.

Note: Setting the solid compression mode to true has effect only when using the 7z format with multiple input files.


void setUpdateMode( bool update_mode )

Sets whether the creator can update existing archives or not.

Note: If false, an exception will be thrown in case a compression operation targets an existing archive.


void setVolumeSize( uint64_t size )

Sets the size (in bytes) of the archive volumes.

Note: This setting has effects only when the destination archive is on filesystem.


const Bit7zLibrary & library() const

Returns the Bit7zLibrary object used by the handler.


const wstring password() const

Returns the password used to open, extract or encrypt the archive.


bool isPasswordDefined() const

Returns true if a password is defined, false otherwise.


TotalCallback totalCallback() const

Returns the current total callback.


ProgressCallback progressCallback() const

Returns the current progress callback.


RatioCallback ratioCallback() const

Returns the current ratio callback.


FileCallback fileCallback() const

Returns the current file callback.


PasswordCallback passwordCallback() const

Returns the current password callback.


void clearPassword()

Clear the current password used by the handler.

Calling clearPassword() will disable the encryption/decryption of archives.

Note: This is equivalent to calling setPassword(L"").


void setTotalCallback( const TotalCallback &callback )

Sets the callback to be called when the total size of an operation is available.


void setProgressCallback( const ProgressCallback &callback )

Sets the callback to be called when the processed size of the ongoing operation is updated.

Note: The percentage of completition of the current operation can be obtained by calculating static_cast( ( 100.0 * processed_size ) / total_size ).


void setRatioCallback( const RatioCallback &callback )

Sets the callback to be called when the input processed size and current output size of the ongoing operation are known.

Note: The ratio percentage of a compression operation can be obtained by calculating static_cast( ( 100.0 * output_size ) / input_size ).


void setFileCallback( const FileCallback &callback )

Sets the callback to be called when the currently file being processed changes.


void setPasswordCallback( const PasswordCallback &callback )

Sets the callback to be called when a password is needed to complete the ongoing operation.


Clone this wiki locally