aboutsummaryrefslogtreecommitdiff
path: root/source/Uid.hpp
blob: a076533d5097f01814b354cc4ec825571552bd8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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;
	}
};