OMNeT++ API 6.1
Discrete Event Simulation Library
cHasher Class Reference

Description

Utility class to calculate the hash of some data.

We are trying to achieve that the same calls gives the same hash on a 32-bit machine and on a 64-bit machine. Longs can be either 32-bit or 64-bit, so we always convert them to 64 bits. We do not try to convert endianness, it would be too costly.

Inheritance diagram for cHasher:
[legend]

Public Member Functions

 cHasher ()
 
Updating the hash
void reset ()
 
void add (char d)
 
void add (short d)
 
void add (int d)
 
void add (long d)
 
void add (long long d)
 
void add (unsigned char d)
 
void add (unsigned short d)
 
void add (unsigned int d)
 
void add (unsigned long d)
 
void add (unsigned long long d)
 
void add (double d)
 
void add (simtime_t t)
 
void add (const char *s)
 
void add (const std::string &s)
 
void add (const void *p, size_t length)
 
template<typename T >
cHasheroperator<< (const T &x)
 
Obtaining the result
uint32_t getHash () const
 
uint32_t parse (const char *hash) const
 
bool equals (const char *hash) const
 
std::string str () const
 

Constructor & Destructor Documentation

◆ cHasher()

cHasher ( )
inline

Constructor.

Member Function Documentation

◆ getHash()

uint32_t getHash ( ) const
inline

Returns the hash value.

◆ parse()

uint32_t parse ( const char *  hash) const

Converts the given string to a numeric hash value. The object is not changed. Throws an error if the string does not contain a valid hash.

◆ equals()

bool equals ( const char *  hash) const

Parses the given hash string, and compares it to the stored hash.

◆ str()

std::string str ( ) const

Returns the textual representation (hex string) of the stored hash.


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