NCBI C++ ToolKit
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
CChecksum Class Reference

Search Toolkit Book for CChecksum

CChecksum – Checksum calculator. More...

#include <util/checksum.hpp>

+ Inheritance diagram for CChecksum:
+ Collaboration diagram for CChecksum:

Public Types

enum  EMethod {
  eCRC32 = CChecksumBase::eCRC32 , eCRC32ZIP = CChecksumBase::eCRC32ZIP , eCRC32INSD = CChecksumBase::eCRC32INSD , eCRC32CKSUM = CChecksumBase::eCRC32CKSUM ,
  eCRC32C = CChecksumBase::eCRC32C , eAdler32 = CChecksumBase::eAdler32 , eMD5 = CChecksumBase::eMD5 , eDefault = eCRC32
}
 Method used to compute control sum. More...
 
enum  { kMinimumChecksumLength = 20 }
 

Public Member Functions

 CChecksum (EMethod method=eDefault)
 Default constructor. More...
 
 CChecksum (const CChecksum &other)
 Copy constructor. More...
 
CChecksumoperator= (const CChecksum &other)
 Assignment operator. More...
 
EMethod GetMethod (void) const
 Get current method used to compute checksum. More...
 
size_t GetChecksumSize (void) const
 Return size of checksum in bytes. More...
 
Uint4 GetChecksum (void) const
 Return calculated checksum. More...
 
void GetMD5Digest (unsigned char digest[16]) const
 Return calculated MD5 digest. More...
 
void GetMD5Digest (string &str) const
 
string GetHexSum (void) const
 Return string with checksum in hexadecimal form. More...
 
void AddChars (const char *str, size_t len)
 Update current control sum with data provided. More...
 
void AddLine (const char *line, size_t len)
 
void AddLine (const string &line)
 
void NextLine (void)
 
void AddFile (const string &file_path)
 Update checksum with the file data. More...
 
void AddStream (CNcbiIstream &is)
 Update checksum with the stream data. More...
 
void Reset (void)
 Reset the object to prepare it to the next checksum computation with the same method. More...
 
void Reset (EMethod method)
 Reset the object to prepare it to the next checksum computation with different method. More...
 
bool ValidChecksumLine (const char *line, size_t len) const
 Check for checksum line. More...
 
bool ValidChecksumLine (const string &line) const
 
CNcbiOstreamWriteChecksum (CNcbiOstream &out) const
 Write checksum calculation results into output stream. More...
 
CNcbiOstreamWriteChecksumData (CNcbiOstream &out) const
 
CNcbiOstreamWriteHexSum (CNcbiOstream &out) const
 
- Public Member Functions inherited from CChecksumBase
 CChecksumBase (EMethodDef method)
 Default constructor. More...
 
 ~CChecksumBase ()
 Destructor. More...
 
 CChecksumBase (const CChecksumBase &other)
 Copy constructor. More...
 
CChecksumBaseoperator= (const CChecksumBase &other)
 Assignment operator. More...
 
size_t GetSize (void) const
 Return size of checksum/hash in bytes, depending on used method. More...
 
size_t GetBits (void) const
 Return size of checksum/hash in bits (32, 64). More...
 
Uint4 GetResult32 (void) const
 Return calculated result. More...
 
Uint8 GetResult64 (void) const
 Return calculated result. More...
 
string GetResultHex (void) const
 Return string with checksum/hash in hexadecimal form. More...
 
EMethodDef x_GetMethod (void) const
 

Private Member Functions

bool ValidChecksumLineLong (const char *line, size_t len) const
 Check for checksum line. More...
 

Private Attributes

size_t m_LineCount
 Number of processed lines. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from CChecksumBase
static void InitTables (void)
 Initialize static tables used in CRC32 calculation. More...
 
static void PrintTables (CNcbiOstream &out)
 Print C++ code for CRC32 tables for direct inclusion into library. More...
 
- Protected Types inherited from CChecksumBase
enum  EMethodDef {
  eNone , eCRC32 , eCRC32ZIP , eCRC32INSD ,
  eCRC32CKSUM , eCRC32C , eAdler32 , eMD5 ,
  eCityHash32 , eCityHash64 , eFarmHash32 , eFarmHash64 ,
  eMurmurHash2_32 , eMurmurHash2_64 , eMurmurHash3_32
}
 All supported methods for CHash and CCheksum. More...
 
- Protected Member Functions inherited from CChecksumBase
void x_Update (const char *str, size_t len)
 Update current control sum with data provided. More...
 
void x_Reset (EMethodDef method)
 Reset the object to prepare it to the next computation using selected method. More...
 
void x_Free (void)
 Cleanup (used in destructor and assignment operator). More...
 
- Protected Attributes inherited from CChecksumBase
EMethodDef m_Method
 Current method. More...
 
size_t m_CharCount
 Number of processed chars. More...
 
union {
   Uint4   CChecksumBase::v32
 Used to store 32-bit results. More...
 
   Uint8   CChecksumBase::v64
 Used to store 64-bit results. More...
 
   CMD5 *   CChecksumBase::md5
 Used for MD5 calculation. More...
 
m_Value
 Checksum/Hash computation result. More...
 
- Static Protected Attributes inherited from CChecksumBase
static Uint8 m_Seed = 0
 Unique seed used by some hash methods. More...
 

Detailed Description

CChecksum – Checksum calculator.

This class is used to compute control sums.

Note
This class may use static tables (for CRC32 based methods only). This presents a potential race condition in MT programs. To avoid races call static InitTables() method before first concurrent use of CChecksum.

Definition at line 301 of file checksum.hpp.


The documentation for this class was generated from the following files:
Modified on Tue May 21 10:56:55 2024 by modify_doxy.py rev. 669887