Class BitArchiveHandler
Synopsis
#include <include/bitarchivehandler.hpp>
class BitArchiveHandler
Description
Abstract class representing a generic archive handler.
Inheritance
Decsendents: BitArchiveOpener, BitArchiveCreator
Methods
BitArchiveHandler | ||
~BitArchiveHandler | ||
clearPassword | Clear the current password used by the handler. | |
fileCallback | Returns: the current file callback. | |
format | Returns: the format used by the handler for extracting or compressing. | |
isPasswordDefined | Returns: true if a password is defined, false otherwise. | |
library | Returns: the Bit7zLibrary object used by the handler. | |
password | Returns: the password used to open, extract or encrypt the archive. | |
passwordCallback | Returns: the current password callback. | |
progressCallback | Returns: the current progress callback. | |
ratioCallback | Returns: the current ratio callback. | |
setFileCallback | Sets the callback to be called when the currently file being processed changes. | |
setPassword | Sets up a password to be used by the archive handler. | |
setPasswordCallback | Sets the callback to be called when a password is needed to complete the ongoing operation. | |
setProgressCallback | Sets the callback to be called when the processed size of the ongoing operation is updated. | |
setRatioCallback | Sets the callback to be called when the input processed size and current output size of the ongoing operation are known. | |
setTotalCallback | Sets the callback to be called when the total size of an operation is available. | |
totalCallback | Returns: the current total callback. |
Source
Lines 62-196 in include/bitarchivehandler.hpp.
class BitArchiveHandler {
public:
/**
* @return the Bit7zLibrary object used by the handler.
*/
const Bit7zLibrary& library() const;
/**
* @return the format used by the handler for extracting or compressing.
*/
virtual const BitInFormat& format() const = 0;
/**
* @return the password used to open, extract or encrypt the archive.
*/
const wstring password() const;
/**
* @return true if a password is defined, false otherwise.
*/
bool isPasswordDefined() const;
/**
* @return the current total callback.
*/
TotalCallback totalCallback() const;
/**
* @return the current progress callback.
*/
ProgressCallback progressCallback() const;
/**
* @return the current ratio callback.
*/
RatioCallback ratioCallback() const;
/**
* @return the current file callback.
*/
FileCallback fileCallback() const;
/**
* @return the current password callback.
*/
PasswordCallback passwordCallback() const;
/**
* @brief Sets up a password to be used by the archive handler.
*
* The password will be used to encrypt/decrypt archives by using the default
* cryptographic method of the archive format.
*
* @note Calling setPassword when the input archive is not encrypted does not have effect on
* the extraction process.
*
* @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).
*
* @note After a password has been set, it will be used for every subsequent operation.
* To disable the use of the password, you need to call the clearPassword method, which is equivalent
* to call setPassword(L"").
*
* @param password the password to be used.
*/
virtual void setPassword( const wstring& password );
/**
* @brief 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 clearPassword();
/**
* @brief Sets the callback to be called when the total size of an operation is available.
*
* @param callback the total callback to be used.
*/
void setTotalCallback( const TotalCallback& callback );
/**
* @brief 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<int>( ( 100.0 * processed_size ) / total_size ).
*
* @param callback the progress callback to be used.
*/
void setProgressCallback( const ProgressCallback& callback );
/**
* @brief 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<int>( ( 100.0 * output_size ) / input_size ).
*
* @param callback the ratio callback to be used.
*/
void setRatioCallback( const RatioCallback& callback );
/**
* @brief Sets the callback to be called when the currently file being processed changes.
*
* @param callback the file callback to be used.
*/
void setFileCallback( const FileCallback& callback );
/**
* @brief Sets the callback to be called when a password is needed to complete the ongoing operation.
*
* @param callback the password callback to be used.
*/
void setPasswordCallback( const PasswordCallback& callback );
protected:
const Bit7zLibrary& mLibrary;
wstring mPassword;
explicit BitArchiveHandler( const Bit7zLibrary& lib, const wstring& password = L"" );
virtual ~BitArchiveHandler() = 0;
private:
//CALLBACKS
TotalCallback mTotalCallback;
ProgressCallback mProgressCallback;
RatioCallback mRatioCallback;
FileCallback mFileCallback;
PasswordCallback mPasswordCallback;
};