aboutsummaryrefslogtreecommitdiff
path: root/source/Uid.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Uid.cpp')
-rw-r--r--source/Uid.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/source/Uid.cpp b/source/Uid.cpp
index 2520d1e..1930cd8 100644
--- a/source/Uid.cpp
+++ b/source/Uid.cpp
@@ -3,6 +3,7 @@
#include "RapidJsonHelper.hpp"
#include <rapidjson/document.h>
+#include <cstring>
#include <random>
Uid Uid::Create() {
@@ -22,6 +23,16 @@ bool Uid::IsNull() const {
return upper == 0 && lower == 0;
}
+void Uid::ReadString(std::string_view str) {
+ sscanf(str.data(), BRUSSEL_Uid_SCAN_STR, &upper, &lower);
+}
+
+std::string Uid::WriteString() {
+ char buf[256];
+ snprintf(buf, sizeof(buf), BRUSSEL_Uid_FORMAT_STR, upper, lower);
+ return std::string(buf);
+}
+
void Uid::Read(const rapidjson::Value& value) {
assert(value.IsArray());
assert(value.Size() == 2);