23 _hv[0] = _hv[1] = _hv[2] = _hv[3] = 0;
45 operator = (
const HashVal ©) {
58 operator == (
const HashVal &other)
const {
59 return (_hv[0] == other._hv[0] &&
60 _hv[1] == other._hv[1] &&
61 _hv[2] == other._hv[2] &&
62 _hv[3] == other._hv[3]);
71 operator != (
const HashVal &other)
const {
72 return !operator == (other);
81 operator < (
const HashVal &other)
const {
91 compare_to(
const HashVal &other)
const {
92 if (_hv[0] != other._hv[0]) {
93 return (
int)_hv[0] - (int)other._hv[0];
95 if (_hv[1] != other._hv[1]) {
96 return (
int)_hv[1] - (int)other._hv[1];
98 if (_hv[2] != other._hv[2]) {
99 return (
int)_hv[2] - (int)other._hv[2];
101 return (
int)_hv[3] - (int)other._hv[3];
112 _hv[0] ^= other._hv[0];
113 _hv[1] ^= other._hv[1];
114 _hv[2] ^= other._hv[2];
115 _hv[3] ^= other._hv[3];
126 out << _hv[0] <<
" " << _hv[1] <<
" " << _hv[2] <<
" " << _hv[3];
136 in >> _hv[0] >> _hv[1] >> _hv[2] >> _hv[3];
144 INLINE
void HashVal::
145 output(ostream &out)
const {
154 INLINE
void HashVal::
155 write_datagram(
Datagram &destination)
const {
167 INLINE
void HashVal::
180 INLINE
void HashVal::
193 INLINE
void HashVal::
210 INLINE
void HashVal::
211 hash_ramfile(
const Ramfile &ramfile) {
212 hash_buffer(ramfile._data.data(), ramfile._data.length());
223 INLINE
void HashVal::
224 hash_string(
const string &data) {
225 hash_buffer(data.data(), data.length());
227 #endif // HAVE_OPENSSL 234 INLINE
char HashVal::
235 tohex(
unsigned int nibble) {
240 return nibble - 10 +
'a';
248 INLINE
unsigned int HashVal::
249 fromhex(
char digit) {
250 if (isdigit(digit)) {
253 return tolower(digit) -
'a' + 10;
258 INLINE ostream &operator << (ostream &out,
const HashVal &hv) {
A StreamWriter object is used to write sequential binary data directly to an ostream.
void input_dec(istream &in)
Inputs the HashVal as four unsigned decimal integers.
PN_uint32 get_uint32()
Extracts an unsigned 32-bit integer.
Stores a 128-bit value that represents the hashed contents (typically MD5) of a file or buffer...
PN_uint32 get_uint32()
Extracts an unsigned 32-bit integer.
void output_hex(ostream &out) const
Outputs the HashVal as a 32-digit hexadecimal number.
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.
void add_uint32(PN_uint32 value)
Adds an unsigned 32-bit integer to the stream.
An STL function object class, this is intended to be used on any ordered collection of class objects ...
void add_uint32(PN_uint32 value)
Adds an unsigned 32-bit integer to the datagram.
void output_dec(ostream &out) const
Outputs the HashVal as four unsigned decimal integers.
A class to retrieve the individual data elements previously stored in a Datagram. ...
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 ...