Wrapper for CheckSum class. More...
#include <CheckSum.h>
Public Member Functions | |
virtual void | start (void) |
virtual void | add (void *buf, unsigned long long int len) |
virtual void | end (void) |
virtual void | result (unsigned char *&res, unsigned int &len) const |
virtual int | print (char *buf, int len) const |
virtual void | scan (const char *buf) |
virtual | operator bool (void) const |
virtual bool | operator! (void) const |
Static Public Member Functions | |
static std::string | FileChecksum (const std::string &filepath, type tp=md5, bool decimalbase=false) |
Wrapper for CheckSum class.
To be used for manipulation of any supported checksum type in a transparent way.
virtual void Arc::CheckSumAny::add | ( | void * | buf, | |
unsigned long long int | len | |||
) | [inline, virtual] |
Add data to be checksummed.
This method calculates the checksum of the passed data chuck, taking into account the previous state of this object.
buf | pointer to data chuck to be checksummed. | |
len | size of the data chuck. |
Implements Arc::CheckSum.
References Arc::CheckSum::add().
virtual void Arc::CheckSumAny::end | ( | void | ) | [inline, virtual] |
Finalize the checksumming.
This method finalizes the checksum algorithm, that is calculating the final checksum result.
Implements Arc::CheckSum.
References Arc::CheckSum::end().
static std::string Arc::CheckSumAny::FileChecksum | ( | const std::string & | filepath, | |
type | tp = md5 , |
|||
bool | decimalbase = false | |||
) | [static] |
Get checksum of a file.
This method provide an easy way to get the checksum of a file, by only specifying the path to the file. Optionally the checksum type can be specified, if not the MD5 algorithm will be used.
filepath | path to file of which checksum should be calculated | |
tp | type of checksum algorithm to use, default is md5. | |
decimalbase | specifies whether output should be in base 10 or 16 |
virtual int Arc::CheckSumAny::print | ( | char * | buf, | |
int | len | |||
) | const [inline, virtual] |
Retrieve result of checksum into a string.
The passed string buf is filled with result of checksum algorithm in base 16. At most len chacters is filled into buffer buf. The hexadecimal value is prepended with "<algorithm>:", where <algorithm> is one of "cksum", "md5" or "adler32" respectively corresponding to the result from the CRC32Sum, MD5Sum and Adler32 classes.
buf | pointer to buffer which should be filled with checksum result. | |
len | max number of character filled into buffer. |
Reimplemented from Arc::CheckSum.
References Arc::CheckSum::print().
virtual void Arc::CheckSumAny::scan | ( | const char * | buf | ) | [inline, virtual] |
Set internal checksum state.
This method sets the internal state to that of the passed textural representation. The format passed to this method must be the same as retrieved from the CheckSum::print method.
buf | string containing textural representation of checksum |
Implements Arc::CheckSum.
References Arc::CheckSum::scan().
virtual void Arc::CheckSumAny::start | ( | void | ) | [inline, virtual] |
Initiate the checksum algorithm.
This method must be called before starting a new checksum calculation.
Implements Arc::CheckSum.
References Arc::CheckSum::start().