azure-core
uuid.hpp
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // SPDX-License-Identifier: MIT
3 
9 #pragma once
10 
11 #include "azure/core/platform.hpp"
12 
13 #include <cstring>
14 #include <string>
15 
16 namespace Azure { namespace Core {
20  class Uuid final {
21 
22  private:
23  static constexpr size_t UuidSize = 16;
24 
25  uint8_t m_uuid[UuidSize];
26  // The UUID reserved variants.
27  static constexpr uint8_t ReservedNCS = 0x80;
28  static constexpr uint8_t ReservedRFC4122 = 0x40;
29  static constexpr uint8_t ReservedMicrosoft = 0x20;
30  static constexpr uint8_t ReservedFuture = 0x00;
31 
32  private:
33  Uuid(uint8_t const uuid[UuidSize]) { std::memcpy(m_uuid, uuid, UuidSize); }
34 
35  public:
40  std::string ToString();
41 
46  static Uuid CreateUuid();
47  };
48 }} // namespace Azure::Core
Azure::Core::Uuid::CreateUuid
static Uuid CreateUuid()
Creates a new random UUID.
Definition: uuid.cpp:50
Azure
Azure SDK abstractions.
Definition: azure_assert.hpp:55
Azure::Core::Uuid::ToString
std::string ToString()
Gets Uuid as a string.
Definition: uuid.cpp:20
platform.hpp
Platform-specific macros.
Azure::Core::Uuid
Universally unique identifier.
Definition: uuid.hpp:20