From eda9a7bbefc5587bf1ff895a9214f450e64575fa Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 5 Mar 2018 22:45:56 +0100 Subject: Implement 'create' operation, add seeding Seeding is currently only done on the key you specify, in the future the user should request data that it can seed. --- include/Hash.hpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 include/Hash.hpp (limited to 'include/Hash.hpp') diff --git a/include/Hash.hpp b/include/Hash.hpp new file mode 100644 index 0000000..d7c90b0 --- /dev/null +++ b/include/Hash.hpp @@ -0,0 +1,46 @@ +#pragma once + +#include "utils.hpp" +#include +#include +#include + +namespace odhtdb +{ + const int HASH_BYTE_SIZE = 32; + + class HashException : public std::runtime_error + { + public: + HashException(const std::string &errMsg) : std::runtime_error(errMsg) {} + }; + + class Hash + { + public: + Hash(); + // Throws HashException on failure + Hash(const void *input, const size_t inputSize); + + void* getData() const { return (void*)data; } + size_t getSize() const { return HASH_BYTE_SIZE; } + + size_t operator()() const; + bool operator==(const Hash &other) const; + + std::string toString() const; + private: + char data[HASH_BYTE_SIZE]; + }; + + struct HashHasher + { + size_t operator()(const Hash &hash) const + { + return hash(); + } + }; + + template + using MapHashKey = std::unordered_map; +} -- cgit v1.2.3