diff options
Diffstat (limited to 'source/Uid.hpp')
-rw-r--r-- | source/Uid.hpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/source/Uid.hpp b/source/Uid.hpp new file mode 100644 index 0000000..a076533 --- /dev/null +++ b/source/Uid.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include "Utils.hpp" + +#include <rapidjson/fwd.h> +#include <cstdint> +#include <functional> + +struct Uid { + uint64_t upper = 0; + uint64_t lower = 0; + + static Uid Create(); + + bool IsNull() const; + + void Read(const rapidjson::Value& value); + void WriteInto(rapidjson::Value& value, rapidjson::Document& root); + rapidjson::Value Write(rapidjson::Document& root); + + auto operator<=>(const Uid&) const = default; +}; + +template <> +struct std::hash<Uid> { + size_t operator()(const Uid& uid) const { + size_t hash = 0; + Utils::HashCombine(hash, uid.upper); + Utils::HashCombine(hash, uid.lower); + return hash; + } +}; |