19 _hv[0] = _hv[1] = _hv[2] = _hv[3] = 0;
37 operator = (
const HashVal ©) {
48 operator == (
const HashVal &other)
const {
49 return (_hv[0] == other._hv[0] &&
50 _hv[1] == other._hv[1] &&
51 _hv[2] == other._hv[2] &&
52 _hv[3] == other._hv[3]);
59 operator != (
const HashVal &other)
const {
60 return !operator == (other);
67 operator < (
const HashVal &other)
const {
75 compare_to(
const HashVal &other)
const {
76 if (_hv[0] != other._hv[0]) {
77 return (
int)_hv[0] - (int)other._hv[0];
79 if (_hv[1] != other._hv[1]) {
80 return (
int)_hv[1] - (int)other._hv[1];
82 if (_hv[2] != other._hv[2]) {
83 return (
int)_hv[2] - (int)other._hv[2];
85 return (
int)_hv[3] - (int)other._hv[3];
93 _hv[0] ^= other._hv[0];
94 _hv[1] ^= other._hv[1];
95 _hv[2] ^= other._hv[2];
96 _hv[3] ^= other._hv[3];
104 out << _hv[0] <<
" " << _hv[1] <<
" " << _hv[2] <<
" " << _hv[3];
112 in >> _hv[0] >> _hv[1] >> _hv[2] >> _hv[3];
118 INLINE
void HashVal::
119 output(std::ostream &out)
const {
126 INLINE
void HashVal::
127 write_datagram(
Datagram &destination)
const {
137 INLINE
void HashVal::
148 INLINE
void HashVal::
159 INLINE
void HashVal::
173 INLINE
void HashVal::
174 hash_ramfile(
const Ramfile &ramfile) {
175 hash_buffer(ramfile._data.data(), ramfile._data.length());
183 INLINE
void HashVal::
184 hash_string(
const std::string &data) {
185 hash_buffer(data.data(), data.length());
193 INLINE
void HashVal::
194 hash_bytes(
const vector_uchar &data) {
195 hash_buffer((
const char *)&data[0], data.size());
197 #endif // HAVE_OPENSSL 202 INLINE
char HashVal::
203 tohex(
unsigned int nibble) {
208 return nibble - 10 +
'a';
214 INLINE
unsigned int HashVal::
215 fromhex(
char digit) {
216 if (isdigit(digit)) {
219 return tolower(digit) -
'a' + 10;
224 INLINE std::ostream &operator << (std::ostream &out,
const HashVal &hv) {
A StreamWriter object is used to write sequential binary data directly to an ostream.
void output_dec(std::ostream &out) const
Outputs the HashVal as four unsigned decimal integers.
Stores a 128-bit value that represents the hashed contents (typically MD5) of a file or buffer.
void output_hex(std::ostream &out) const
Outputs the HashVal as a 32-digit hexadecimal number.
void add_uint32(uint32_t value)
Adds an unsigned 32-bit integer to the datagram.
uint32_t get_uint32()
Extracts an unsigned 32-bit integer.
void merge_with(const HashVal &other)
Generates a new HashVal representing the xor of this one and the other one.
An in-memory buffer specifically designed for downloading files to memory.
uint32_t get_uint32()
Extracts an unsigned 32-bit integer.
An STL function object class, this is intended to be used on any ordered collection of class objects ...
A class to retrieve the individual data elements previously stored in a Datagram.
void add_uint32(uint32_t value)
Adds an unsigned 32-bit integer to the stream.
A class to read sequential binary data directly from an istream.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void input_dec(std::istream &in)
Inputs the HashVal as four unsigned decimal integers.