ARC SDK
Public Member Functions
Arc::CheckSum Class Referenceabstract

Interface for checksum manipulations. More...

#include <arc/CheckSum.h>

Inheritance diagram for Arc::CheckSum:
Arc::Adler32Sum Arc::CheckSumAny Arc::CRC32Sum Arc::MD5Sum

Public Member Functions

 CheckSum (void)
 Default constructor. More...
 
virtual void start (void)=0
 Initiate the checksum algorithm. More...
 
virtual void add (void *buf, unsigned long long int len)=0
 Add data to be checksummed. More...
 
virtual void end (void)=0
 Finalize the checksumming. More...
 
virtual void result (unsigned char *&res, unsigned int &len) const =0
 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)=0
 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...
 

Detailed Description

Interface for checksum manipulations.

This class is an interface and is extended in the specialized classes CRC32Sum, MD5Sum and Adler32Sum. The interface is among others used during data transfers through DataBuffer class. The helper class CheckSumAny can be used as an easier way of handling automatically the different checksum types.

See also
CheckSumAny
CRC32Sum
MD5Sum
Adler32Sum

Constructor & Destructor Documentation

◆ CheckSum()

Arc::CheckSum::CheckSum ( void  )
inline

Default constructor.

Member Function Documentation

◆ add()

virtual void Arc::CheckSum::add ( void *  buf,
unsigned long long int  len 
)
pure virtual

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.

Implemented in Arc::CheckSumAny, Arc::Adler32Sum, Arc::MD5Sum, and Arc::CRC32Sum.

◆ end()

virtual void Arc::CheckSum::end ( void  )
pure virtual

Finalize the checksumming.

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

Implemented in Arc::CheckSumAny, Arc::Adler32Sum, Arc::MD5Sum, and Arc::CRC32Sum.

◆ operator bool()

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

Indicates whether the checksum has been calculated.

Reimplemented in Arc::CheckSumAny, Arc::Adler32Sum, Arc::MD5Sum, and Arc::CRC32Sum.

◆ operator!()

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

Indicates whether the checksum has not been calculated.

Reimplemented in Arc::CheckSumAny, Arc::Adler32Sum, Arc::MD5Sum, and Arc::CRC32Sum.

◆ print()

virtual int Arc::CheckSum::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 in Arc::CheckSumAny, Arc::Adler32Sum, Arc::MD5Sum, and Arc::CRC32Sum.

◆ result()

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

Retrieve result of checksum as binary blob.

Implemented in Arc::CheckSumAny, Arc::Adler32Sum, Arc::MD5Sum, and Arc::CRC32Sum.

◆ scan()

virtual void Arc::CheckSum::scan ( const char *  buf)
pure virtual

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

Implemented in Arc::CheckSumAny, Arc::Adler32Sum, Arc::MD5Sum, and Arc::CRC32Sum.

◆ start()

virtual void Arc::CheckSum::start ( void  )
pure virtual

Initiate the checksum algorithm.

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

Implemented in Arc::CheckSumAny, Arc::Adler32Sum, Arc::MD5Sum, and Arc::CRC32Sum.


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