nx_server_plugin_sdk 1.0 Server Plugin 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 #include <stdint.h>
9
10 namespace nx::sdk {
11
12 using UuidBase = std::array<uint8_t, 16>;
13
22 class Uuid: public UuidBase
23 {
24 public:
25 static constexpr int kSize = (int) std::tuple_size<UuidBase>();
26 static constexpr int size() { return kSize; } //< For C++14, to avoid the definition.
27
28 constexpr Uuid(
29 uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3,
30 uint8_t b4, uint8_t b5, uint8_t b6, uint8_t b7,
31 uint8_t b8, uint8_t b9, uint8_t bA, uint8_t bB,
32 uint8_t bC, uint8_t bD, uint8_t bE, uint8_t bF)
33 :
34 UuidBase({b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, bA, bB, bC, bD, bE, bF})
35 {
36 }
37
38 explicit Uuid(const uint8_t (&byteArray)[kSize])
39 {
40 memcpy(data(), byteArray, kSize);
41 }
42
43 constexpr Uuid(): UuidBase{} {} //< All zeros.
44
45 bool isNull() const { return *this == Uuid(); }
46 };
47
48 } // namespace nx::sdk
nx::sdk::Uuid
Definition: uuid.h:22
nx::sdk
Definition: device_agent.h:12