aboutsummaryrefslogtreecommitdiff
path: root/source/Uid.cpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-05-22 23:05:03 -0700
committerrtk0c <[email protected]>2022-05-22 23:05:03 -0700
commit123f741e3f5374b93ac39887b62bfa0d66762ae2 (patch)
treecedbc4b2dd87e2caadfde48a0c12a0336672bdd3 /source/Uid.cpp
parentc568f0a8c9f0aef00c770b494ee1ff3a89ab48de (diff)
Changeset: 36 Add basic machinery for levels (no saving/loading yet)
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);