1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #pragma once
7 
8 #include <aws/core/Core_EXPORTS.h>
9 #include <aws/core/utils/memory/stl/AWSString.h>
10 #include <aws/core/utils/Array.h>
11 
12 namespace Aws
13 {
14     namespace Utils
15     {
16         static const size_t UUID_BINARY_SIZE = 0x10;
17 
18         /**
19          * Class encapsulating a UUID. This is platform dependent. The method you are most likely interested in is RandomUUID().
20          */
21         class AWS_CORE_API UUID
22         {
23         public:
24             /**
25              * Parses a GUID string into the raw data.
26              */
27             UUID(const Aws::String&);
28             /**
29              * Sets the raw uuid data
30              */
31             UUID(const unsigned char uuid[UUID_BINARY_SIZE]);
32 
33             /**
34              * Returns the current UUID as a GUID string
35              */
36             operator Aws::String() const;
37             /**
38              * Returns a copy of the raw uuid
39              */
ByteBuffer()40             inline operator ByteBuffer() const { return ByteBuffer(m_uuid, sizeof(m_uuid)); }
41 
42             /**
43              * Generates a UUID. It will always try to prefer a random implementation from the entropy source on the machine. If none, is available, it will
44              * fallback to the mac address and timestamp implementation.
45              */
46             static UUID RandomUUID();
47 
48         private:
49             unsigned char m_uuid[UUID_BINARY_SIZE];
50         };
51     }
52 }
53