From 123f741e3f5374b93ac39887b62bfa0d66762ae2 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sun, 22 May 2022 23:05:03 -0700 Subject: Changeset: 36 Add basic machinery for levels (no saving/loading yet) --- source/Uid.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source/Uid.cpp') 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 +#include #include 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); -- cgit v1.2.3-70-g09d2