Botan  2.11.0
Crypto and TLS for C++11
uuid.h
Go to the documentation of this file.
1 /*
2 * UUID type
3 * (C) 2015,2018 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_UUID_H_
9 #define BOTAN_UUID_H_
10 
11 #include <botan/types.h>
12 #include <vector>
13 #include <string>
14 
15 namespace Botan {
16 
17 class RandomNumberGenerator;
18 
20  {
21  public:
22  /**
23  * Create an uninitialized UUID object
24  */
25  UUID() : m_uuid() {}
26 
27  /**
28  * Create a random UUID
29  */
31 
32  /**
33  * Load a UUID from a 16 byte vector
34  */
35  UUID(const std::vector<uint8_t>& blob);
36 
37  UUID& operator=(const UUID& other) = default;
38  UUID(const UUID& other) = default;
39 
40  /**
41  * Decode a UUID string
42  */
43  UUID(const std::string& uuid_str);
44 
45  /**
46  * Convert the UUID to a string
47  */
48  std::string to_string() const;
49 
50  const std::vector<uint8_t>& binary_value() const { return m_uuid; }
51 
52  bool operator==(const UUID& other) const
53  {
54  return m_uuid == other.m_uuid;
55  }
56 
57  bool operator!=(const UUID& other) const { return !(*this == other); }
58 
59  bool is_valid() const { return m_uuid.size() == 16; }
60 
61  private:
62  std::vector<uint8_t> m_uuid;
63  };
64 
65 }
66 
67 #endif
#define BOTAN_UNSTABLE_API
Definition: compiler.h:38
const std::vector< uint8_t > & binary_value() const
Definition: uuid.h:50
int(* final)(unsigned char *, CTX *)
std::string to_string(ErrorType type)
Convert an ErrorType to string.
Definition: exceptn.cpp:11
Definition: alg_id.cpp:13
bool operator==(const UUID &other) const
Definition: uuid.h:52
UUID()
Definition: uuid.h:25
bool is_valid() const
Definition: uuid.h:59
bool operator!=(const UUID &other) const
Definition: uuid.h:57