summaryrefslogtreecommitdiff
path: root/src/uuid.cpp
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2020-03-18 22:53:40 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2020-03-23 21:37:30 +0100
commit627d135bf5108f514161e1d37acf6b97c4b3c4a3 (patch)
tree601b2560bb484aedbe51f25a6da3beeae62a78fc /src/uuid.cpp
parent29ade9784fe65ecd686b5e8e18d84e6acc30b37a (diff)
Move UUID and time definitions to separate modules
Diffstat (limited to 'src/uuid.cpp')
-rw-r--r--src/uuid.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/uuid.cpp b/src/uuid.cpp
new file mode 100644
index 0000000..e1f044a
--- /dev/null
+++ b/src/uuid.cpp
@@ -0,0 +1,31 @@
+#include <erebos/uuid.h>
+
+#include <stdexcept>
+
+using namespace erebos;
+
+using std::runtime_error;
+using std::string;
+
+UUID::UUID(string str)
+{
+ if (uuid_parse(str.c_str(), uuid) != 0)
+ throw runtime_error("invalid UUID");
+}
+
+UUID::operator string() const
+{
+ string str(UUID_STR_LEN - 1, '\0');
+ uuid_unparse_lower(uuid, str.data());
+ return str;
+}
+
+bool UUID::operator==(const UUID & other) const
+{
+ return std::equal(std::begin(uuid), std::end(uuid), std::begin(other.uuid));
+}
+
+bool UUID::operator!=(const UUID & other) const
+{
+ return !(*this == other);
+}