ARC SDK
Public Types | Public Member Functions | Static Public Member Functions
Arc::CheckSumAny Class Reference

Wrapper for CheckSum class. More...

#include <arc/CheckSum.h>

Inheritance diagram for Arc::CheckSumAny:
Arc::CheckSum

Public Types

enum  type {
  none, unknown, undefined, cksum,
  md5, adler32
}
 Type of checksum. More...
 

Public Member Functions

 CheckSumAny (CheckSum *c=NULL)
 Construct a new CheckSumAny from the given CheckSum. More...
 
 CheckSumAny (type type)
 Construct a new CheckSumAny using the given checksum type. More...
 
 CheckSumAny (const char *type)
 Construct a new CheckSumAny using the given checksum type represented as a string. More...
 
virtual void start (void)
 Initiate the checksum algorithm. More...
 
virtual void add (void *buf, unsigned long long int len)
 Add data to be checksummed. More...
 
virtual void end (void)
 Finalize the checksumming. More...
 
virtual void result (unsigned char *&res, unsigned int &len) const
 Retrieve result of checksum as binary blob. More...
 
virtual int print (char *buf, int len) const
 Retrieve result of checksum into a string. More...
 
virtual void scan (const char *buf)
 Set internal checksum state. More...
 
virtual operator bool (void) const
 Indicates whether the checksum has been calculated. More...
 
virtual bool operator! (void) const
 Indicates whether the checksum has not been calculated. More...
 
bool active (void)
 
type Type (void) const
 
void operator= (const char *type)
 
bool operator== (const char *s)
 
bool operator== (const CheckSumAny &ck)
 
- Public Member Functions inherited from Arc::CheckSum
 CheckSum (void)
 Default constructor. More...
 

Static Public Member Functions

static type Type (const char *crc)
 
static std::string FileChecksum (const std::string &filepath, type tp=md5, bool decimalbase=false)
 Get checksum of a file. More...
 

Detailed Description

Wrapper for CheckSum class.

To be used for manipulation of any supported checksum type in a transparent way.

Member Enumeration Documentation

◆ type

Type of checksum.

Enumerator
none 

No checksum.

unknown 

Unknown checksum.

undefined 

Undefined checksum.

cksum 

CRC32 checksum.

md5 

MD5 checksum.

adler32 

ADLER32 checksum.

Constructor & Destructor Documentation

◆ CheckSumAny() [1/3]

Arc::CheckSumAny::CheckSumAny ( CheckSum c = NULL)
inline

Construct a new CheckSumAny from the given CheckSum.

◆ CheckSumAny() [2/3]

Arc::CheckSumAny::CheckSumAny ( type  type)

Construct a new CheckSumAny using the given checksum type.

◆ CheckSumAny() [3/3]

Arc::CheckSumAny::CheckSumAny ( const char *  type)

Construct a new CheckSumAny using the given checksum type represented as a string.

Member Function Documentation

◆ add()

virtual void Arc::CheckSumAny::add ( void *  buf,
unsigned long long int  len 
)
inlinevirtual

Add data to be checksummed.

This method calculates the checksum of the passed data chunk, taking into account the previous state of this object.

Parameters
bufpointer to data chuck to be checksummed.
lensize of the data chuck.

Implements Arc::CheckSum.

◆ end()

virtual void Arc::CheckSumAny::end ( void  )
inlinevirtual

Finalize the checksumming.

This method finalizes the checksum algorithm, that is calculating the final checksum result.

Implements Arc::CheckSum.

◆ FileChecksum()

static std::string Arc::CheckSumAny::FileChecksum ( const std::string &  filepath,
type  tp = md5,
bool  decimalbase = false 
)
static

Get checksum of a file.

This method provides 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.

Parameters
filepathpath to file of which checksum should be calculated
tptype of checksum algorithm to use, default is md5.
decimalbasespecifies whether output should be in base 10 or 16
Returns
a string containing the calculated checksum is returned.

◆ operator bool()

virtual Arc::CheckSumAny::operator bool ( void  ) const
inlinevirtual

Indicates whether the checksum has been calculated.

Reimplemented from Arc::CheckSum.

◆ operator!()

virtual bool Arc::CheckSumAny::operator! ( void  ) const
inlinevirtual

Indicates whether the checksum has not been calculated.

Reimplemented from Arc::CheckSum.

◆ print()

virtual int Arc::CheckSumAny::print ( char *  buf,
int  len 
) const
inlinevirtual

Retrieve result of checksum into a string.

The passed string buf is filled with result of checksum algorithm in base 16. At most len characters are 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.

Parameters
bufpointer to buffer which should be filled with checksum result.
lenmax number of character filled into buffer.
Returns
0 on success

Reimplemented from Arc::CheckSum.

◆ result()

virtual void Arc::CheckSumAny::result ( unsigned char *&  res,
unsigned int &  len 
) const
inlinevirtual

Retrieve result of checksum as binary blob.

Implements Arc::CheckSum.

◆ scan()

virtual void Arc::CheckSumAny::scan ( const char *  buf)
inlinevirtual

Set internal checksum state.

This method sets the internal state to that of the passed textual representation. The format passed to this method must be the same as retrieved from the CheckSum::print method.

Parameters
bufstring containing textual representation of checksum
See also
CheckSum::print

Implements Arc::CheckSum.

◆ start()

virtual void Arc::CheckSumAny::start ( void  )
inlinevirtual

Initiate the checksum algorithm.

This method must be called before starting a new checksum calculation.

Implements Arc::CheckSum.


The documentation for this class was generated from the following file: