OMNeT++ Simulation Library
6.0.3
|
#include <chasher.h>
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.
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 > | |
cHasher & | operator<< (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 |
|
inline |
Constructor.
|
inline |
Returns the hash value.
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.
bool equals | ( | const char * | hash | ) | const |
Parses the given hash string, and compares it to the stored hash.
std::string str | ( | ) | const |
Returns the textual representation (hex string) of the stored hash.