aboutsummaryrefslogtreecommitdiff
path: root/source/Uid.hpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-04-18 20:59:31 -0700
committerrtk0c <[email protected]>2022-04-18 20:59:31 -0700
commit7f871b04470766f0f5266cf949b65a54b7a6f79e (patch)
tree541b316fb564ffe12885586131a6ccd17662f662 /source/Uid.hpp
parent7af9992ca81c699bc1cf05eb691e284bf424f050 (diff)
Changeset: 10 Add Uid for IresObject
Diffstat (limited to 'source/Uid.hpp')
-rw-r--r--source/Uid.hpp32
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;
+ }
+};