blob: d3a3510f85f8d1da041d73f2a2051c4a9d19e5fc (
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
33
34
35
36
37
38
39
40
|
#pragma once
#include <array>
#include <cstring>
#include <optional>
#include <string>
namespace erebos {
struct UUID
{
UUID(): uuid({}) {}
explicit UUID(const std::string &);
explicit operator std::string() const;
static std::optional<UUID> fromString(const std::string &);
static bool fromString(const std::string &, UUID &);
static UUID generate();
bool operator==(const UUID &) const;
bool operator!=(const UUID &) const;
std::array<uint8_t, 16> uuid;
};
}
namespace std
{
template<> struct hash<erebos::UUID>
{
std::size_t operator()(const erebos::UUID & uuid) const noexcept
{
std::size_t res;
std::memcpy(&res, uuid.uuid.data(), sizeof res);
return res;
}
};
}
|