azure-core
Loading...
Searching...
No Matches
uuid.hpp
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
9#pragma once
10
12
13#include <array>
14#include <cstdint> // defines std::uint8_t
15#include <cstring>
16#include <stdint.h> // deprecated, defines uint8_t in global namespace. TODO: Remove in the future when references to uint8_t and friends are removed.
17#include <string>
18
19namespace Azure { namespace Core {
23 class Uuid final {
24
25 private:
26 static constexpr size_t UuidSize = 16;
27
28 std::array<uint8_t, UuidSize> m_uuid{};
29
30 private:
31 Uuid(uint8_t const uuid[UuidSize]) { std::memcpy(m_uuid.data(), uuid, UuidSize); }
32
33 public:
38 std::string ToString();
39
45 std::array<uint8_t, UuidSize> const& AsArray() const { return m_uuid; }
46
51 static Uuid CreateUuid();
52
57 static Uuid CreateFromArray(std::array<uint8_t, UuidSize> const& uuid);
58 };
59}} // namespace Azure::Core
Universally unique identifier.
Definition uuid.hpp:23
std::string ToString()
Gets Uuid as a string.
Definition uuid.cpp:20
std::array< uint8_t, UuidSize > const & AsArray() const
Returns the binary value of the Uuid for consumption by clients who need non-string representation of...
Definition uuid.hpp:45
static Uuid CreateUuid()
Creates a new random UUID.
Definition uuid.cpp:50
static Uuid CreateFromArray(std::array< uint8_t, UuidSize > const &uuid)
Construct a Uuid from an existing UUID represented as an array of bytes.
Definition uuid.cpp:87
Compute the hash value for the input binary data, using SHA256, SHA384 and SHA512.
Definition azure_assert.hpp:57
Platform-specific macros.