diff options
author | dec05eba <0xdec05eba@gmail.com> | 2018-05-08 17:53:10 +0200 |
---|---|---|
committer | dec05eba <0xdec05eba@gmail.com> | 2018-05-08 17:53:12 +0200 |
commit | e3b6538c17884b5985a78e3d7c507d02b7af2e78 (patch) | |
tree | 05920cc3abe4e560496d546936a30438a15c8a6e /src | |
parent | f3b18e0309ca2dbb997908583f1d44d13d9fc830 (diff) |
Add more comparison functions to hash
Diffstat (limited to 'src')
-rw-r--r-- | src/Hash.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Hash.cpp b/src/Hash.cpp index 364cddd..4b045a4 100644 --- a/src/Hash.cpp +++ b/src/Hash.cpp @@ -17,6 +17,8 @@ namespace odhtdb static SodiumInitializer __sodiumInitializer; + static const Hash EMPTY_HASH; + Hash::Hash() { memset(data, 0, HASH_BYTE_SIZE); @@ -44,8 +46,18 @@ namespace odhtdb return memcmp(data, other.data, HASH_BYTE_SIZE) == 0; } + bool Hash::operator!=(const Hash &other) const + { + return !operator==(other); + } + std::string Hash::toString() const { return bin2hex(data, HASH_BYTE_SIZE); } + + bool Hash::isEmpty() const + { + return *this == EMPTY_HASH; + } } |