Grindstone Game Engine v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
Uuid.hpp
1#pragma once
2
3#include <stdint.h>
4#include <string>
5
6namespace Grindstone {
7 class Uuid {
8 public:
9 static bool MakeFromString(const std::string& str, Grindstone::Uuid& outUuid);
10 static bool MakeFromString(const char* str, Grindstone::Uuid& outUuid);
11
12 Uuid();
13 void operator=(const Uuid& other);
14 std::string ToString() const;
15 bool operator==(const Uuid& other) const;
16 bool operator!=(const Uuid& other) const;
17 bool operator<(const Uuid& other) const;
18 bool IsValid() const;
19 operator std::string() const;
20
21 static Uuid CreateRandom();
22
23 union {
24 uint8_t asUint8[16];
25 uint16_t asUint16[8];
26 uint32_t asUint32[4];
27 uint64_t asUint64[2];
28 };
29 };
30}
31
32template <>
33struct std::hash<Grindstone::Uuid>
34{
35 std::size_t operator()(const Grindstone::Uuid& k) const {
36 using std::size_t;
37
38 return k.asUint64[0] ^ k.asUint64[1];
39 }
40};
Definition Uuid.hpp:7