libxcks
0.1.0.1
|
Computes a checksum from a file. More...
#include <ckcalculator.hpp>
Public Member Functions | |
ChecksumFileCalculator (ChecksumCalculatorProgress &progressHandler=defaultChecksumCalculatorProgress, const unsigned int newNbThreads=automatic_thread_number, const size_t newBufferSize=default_file_buffer_size) | |
Constructor. More... | |
ChecksumFileCalculator (const ChecksumFileCalculator &)=delete | |
Deleted copy constructor. More... | |
ChecksumFileCalculator & | operator= (const ChecksumFileCalculator &)=delete |
Deleted assignment operator. More... | |
virtual | ~ChecksumFileCalculator ()=default |
Destructor. More... | |
State | calculate (ChecksumValue &sumValue, const ChecksumAlgoId id, const std::filesystem::path &filepath) |
Calculates the checksum from the given file. More... | |
State | calculate (ArrayChecksumValue &sumValues, const ArrayChecksumAlgoId &ids, const std::filesystem::path &filepath) |
Calculates the checksums from the given file. More... | |
Public Member Functions inherited from libxcks::ChecksumCalculator | |
ChecksumCalculator (ChecksumCalculatorProgress &progressHandler=defaultChecksumCalculatorProgress, const unsigned int newNbThreads=automatic_thread_number, const size_t newBufferSize=default_buffer_size) | |
Constructor. More... | |
ChecksumCalculator (const ChecksumCalculator &)=delete | |
Deleted copy constructor. More... | |
ChecksumCalculator & | operator= (const ChecksumCalculator &)=delete |
Deleted assignment operator. More... | |
virtual | ~ChecksumCalculator ()=default |
Destructor. More... | |
size_t | getBufferSize () const |
Gets the size of the buffer to use for reading in the input stream. More... | |
size_t | setBufferSize (const size_t newBufSize) |
Sets the size of the buffer to use for reading in the input stream. More... | |
unsigned int | getNbThreads () const |
Returns the number of threads to use to compute checksums. More... | |
unsigned int | setNbThreads (const unsigned int newNbThreads) |
Sets the number of threads to use to compute checksums. More... | |
ChecksumCalculatorProgress & | getChecksumProgress () const |
Gets the progress handler used to show the progression. More... | |
State | calculate (ChecksumValue &sumValue, const ChecksumAlgoId id, std::istream &is) |
Calculates the checksum from the given stream. More... | |
State | calculate (ArrayChecksumValue &sumValues, const ArrayChecksumAlgoId &ids, std::istream &is) |
Calculates the checksums from the given stream. More... | |
Static Protected Attributes | |
static constexpr size_t | default_file_buffer_size = 0xFFFFu |
Default buffer size for reading files. More... | |
Static Protected Attributes inherited from libxcks::ChecksumCalculator | |
static DefaultChecksumCalculatorProgress | defaultChecksumCalculatorProgress |
Default progress checksum calculator instance. More... | |
static constexpr size_t | default_buffer_size = 4096u |
Default buffer size for reading streams. More... | |
static constexpr size_t | min_buffer_size = 1u |
Minimal buffer size for reading streams. More... | |
static constexpr size_t | max_buffer_size = 1048576u |
Maximal buffer size for reading streams. More... | |
static constexpr unsigned int | default_thread_number = 2u |
Default number of threads for computing checksums if the number of cores of the system cannot be automatically found. More... | |
static constexpr unsigned int | max_thread_number = 32u |
Maximal value for number of threads for computing checksums. More... | |
Additional Inherited Members | |
Public Types inherited from libxcks::ChecksumCalculator | |
enum class | State { Ok = 0 , NoValidAlgoId , OutOfMemory , ReadError , FileNotFound , CantOpenFile , CancelledByUser } |
States that can be returned by the calculate or the check method. More... | |
Static Public Attributes inherited from libxcks::ChecksumCalculator | |
static constexpr unsigned int | automatic_thread_number = 0u |
System dependent value for number of threads for computing checksums. More... | |
Protected Attributes inherited from libxcks::ChecksumCalculator | |
ChecksumCalculatorProgress & | progress |
The progress handler used to show the progression. More... | |
size_t | bufferSize |
The size of the buffer to use for reading the input stream. More... | |
unsigned int | nbThreads |
Number of threads to compute checksums. More... | |
Computes a checksum from a file.
Please note that all the pointers passed to this class are not freed, it is the responsibility to the users of this class to free them.
Definition at line 268 of file ckcalculator.hpp.
libxcks::ChecksumFileCalculator::ChecksumFileCalculator | ( | ChecksumCalculatorProgress & | progressHandler = defaultChecksumCalculatorProgress , |
const unsigned int | newNbThreads = automatic_thread_number , |
||
const size_t | newBufferSize = default_file_buffer_size |
||
) |
Constructor.
progressHandler | ChecksumCalculatorProgress instance class to show the progress. |
newNbThreads | The number of threads to use to compute checksums. |
newBufferSize | The size of the buffer to use for reading in the input stream. |
Definition at line 375 of file ckcalculator.cpp.
|
delete |
Deleted copy constructor.
|
virtualdefault |
Destructor.
ChecksumFileCalculator::State libxcks::ChecksumFileCalculator::calculate | ( | ArrayChecksumValue & | sumValues, |
const ArrayChecksumAlgoId & | ids, | ||
const std::filesystem::path & | filepath | ||
) |
Calculates the checksums from the given file.
sumValues
is cleared before adding computed values.[out] | sumValues | The calculated values of the checksums from the input file. |
[in] | ids | The ids of the wanted algorithm of checksums. |
[in] | filepath | Path of the file from which the data will be extracted to compute the checksum. The data are extracted until the end of the file is reached. |
Ok
if the checksum has been successfully calculated. NoValidAlgoId
if no valid id of algorithm of checksum has been provided. ReadError
if a read error has occurred. FileNotFound
if the file doesn't exist. CantOpenFile
if the file can't be opened. Cancelled
if the user has cancelled the calculation. Definition at line 409 of file ckcalculator.cpp.
ChecksumFileCalculator::State libxcks::ChecksumFileCalculator::calculate | ( | ChecksumValue & | sumValue, |
const ChecksumAlgoId | id, | ||
const std::filesystem::path & | filepath | ||
) |
Calculates the checksum from the given file.
[out] | sumValue | The calculated value of the checksum from the input stream. |
[in] | id | The id of the wanted algorithm of checksums. |
[in,out] | filepath | Path of the file from which the data will be extracted to compute the checksum. The data are extracted until the end of the file is reached. |
Ok
if the checksum has been successfully calculated. NoValidAlgoId
if no valid id of algorithm of checksum has been provided. ReadError
if a read error has occurred. FileNotFound
if the file doesn't exist. CantOpenFile
if the file can't be opened. Cancelled
if the user has cancelled the calculation. Definition at line 389 of file ckcalculator.cpp.
|
delete |
Deleted assignment operator.
|
staticconstexprprotected |
Default buffer size for reading files.
Definition at line 271 of file ckcalculator.hpp.