nx_metadata_sdk 1.0 Metadata SDK

uuid.h
1 // Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
2
3 #pragma once
4
5 #include <array>
6 #include <cstring>
7
8 namespace nx {
9 namespace sdk {
10
11 using UuidBase = std::array<uint8_t, 16>;
12
21 class Uuid: public UuidBase
22 {
23 public:
24 static constexpr int kSize = (int) std::tuple_size<UuidBase>();
25 static constexpr int size() { return kSize; } //< For C++14, to avoid the definition.
26
27 constexpr Uuid(
28 uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3,
29 uint8_t b4, uint8_t b5, uint8_t b6, uint8_t b7,
30 uint8_t b8, uint8_t b9, uint8_t bA, uint8_t bB,
31 uint8_t bC, uint8_t bD, uint8_t bE, uint8_t bF)
32 :
33 UuidBase({b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, bA, bB, bC, bD, bE, bF})
34 {
35 }
36
37 explicit Uuid(const uint8_t (&byteArray)[kSize])
38 {
39 memcpy(data(), byteArray, kSize);
40 }
41
42 constexpr Uuid(): UuidBase{} {} //< All zeros.
43
44 bool isNull() const { return *this == Uuid(); }
45 };
46
47 } // namespace sdk
48 } // namespace nx
nx::sdk::Uuid
Definition: uuid.h:21
nx
Definition: apple_utils.h:6