summaryrefslogtreecommitdiffstats
path: root/comm/third_party/botan/src/lib/utils/uuid/uuid.h
diff options
context:
space:
mode:
Diffstat (limited to 'comm/third_party/botan/src/lib/utils/uuid/uuid.h')
-rw-r--r--comm/third_party/botan/src/lib/utils/uuid/uuid.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/comm/third_party/botan/src/lib/utils/uuid/uuid.h b/comm/third_party/botan/src/lib/utils/uuid/uuid.h
new file mode 100644
index 0000000000..8f95f4d672
--- /dev/null
+++ b/comm/third_party/botan/src/lib/utils/uuid/uuid.h
@@ -0,0 +1,69 @@
+/*
+* UUID type
+* (C) 2015,2018 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#ifndef BOTAN_UUID_H_
+#define BOTAN_UUID_H_
+
+#include <botan/types.h>
+#include <vector>
+#include <string>
+
+BOTAN_FUTURE_INTERNAL_HEADER(uuid.h)
+
+namespace Botan {
+
+class RandomNumberGenerator;
+
+class BOTAN_UNSTABLE_API UUID final
+ {
+ public:
+ /**
+ * Create an uninitialized UUID object
+ */
+ UUID() : m_uuid() {}
+
+ /**
+ * Create a random UUID
+ */
+ UUID(RandomNumberGenerator& rng);
+
+ /**
+ * Load a UUID from a 16 byte vector
+ */
+ UUID(const std::vector<uint8_t>& blob);
+
+ UUID& operator=(const UUID& other) = default;
+ UUID(const UUID& other) = default;
+
+ /**
+ * Decode a UUID string
+ */
+ UUID(const std::string& uuid_str);
+
+ /**
+ * Convert the UUID to a string
+ */
+ std::string to_string() const;
+
+ const std::vector<uint8_t>& binary_value() const { return m_uuid; }
+
+ bool operator==(const UUID& other) const
+ {
+ return m_uuid == other.m_uuid;
+ }
+
+ bool operator!=(const UUID& other) const { return !(*this == other); }
+
+ bool is_valid() const { return m_uuid.size() == 16; }
+
+ private:
+ std::vector<uint8_t> m_uuid;
+ };
+
+}
+
+#endif