aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/SaveManager.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-07 21:19:01 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-07 21:19:01 +0100
commitdc93b1e9b3e05dfd3e271aaccbee1210180a6906 (patch)
tree8a66c8087fb8cbcf14b0827b78a11ec0fb7b08ce /src/crepe/api/SaveManager.cpp
parentace974504e410eb7d98ca021d75511d8f84b9bdc (diff)
update clang-format and run `make format` over my (loek)s files
Diffstat (limited to 'src/crepe/api/SaveManager.cpp')
-rw-r--r--src/crepe/api/SaveManager.cpp53
1 files changed, 35 insertions, 18 deletions
diff --git a/src/crepe/api/SaveManager.cpp b/src/crepe/api/SaveManager.cpp
index 23587e4..43276c5 100644
--- a/src/crepe/api/SaveManager.cpp
+++ b/src/crepe/api/SaveManager.cpp
@@ -2,8 +2,8 @@
#include "../util/log.h"
#include "Config.h"
-#include "ValueBroker.h"
#include "SaveManager.h"
+#include "ValueBroker.h"
using namespace std;
using namespace crepe;
@@ -65,17 +65,33 @@ string SaveManager::deserialize(const string & value) const noexcept {
return value;
}
-template <> uint8_t SaveManager::deserialize(const string & value) const noexcept { return deserialize<uint64_t>(value); }
-template <> int8_t SaveManager::deserialize(const string & value) const noexcept { return deserialize<int64_t>(value); }
-template <> uint16_t SaveManager::deserialize(const string & value) const noexcept { return deserialize<uint64_t>(value); }
-template <> int16_t SaveManager::deserialize(const string & value) const noexcept { return deserialize<int64_t>(value); }
-template <> uint32_t SaveManager::deserialize(const string & value) const noexcept { return deserialize<uint64_t>(value); }
-template <> int32_t SaveManager::deserialize(const string & value) const noexcept { return deserialize<int64_t>(value); }
-
-SaveManager::SaveManager() {
- dbg_trace();
+template <>
+uint8_t SaveManager::deserialize(const string & value) const noexcept {
+ return deserialize<uint64_t>(value);
+}
+template <>
+int8_t SaveManager::deserialize(const string & value) const noexcept {
+ return deserialize<int64_t>(value);
+}
+template <>
+uint16_t SaveManager::deserialize(const string & value) const noexcept {
+ return deserialize<uint64_t>(value);
+}
+template <>
+int16_t SaveManager::deserialize(const string & value) const noexcept {
+ return deserialize<int64_t>(value);
+}
+template <>
+uint32_t SaveManager::deserialize(const string & value) const noexcept {
+ return deserialize<uint64_t>(value);
+}
+template <>
+int32_t SaveManager::deserialize(const string & value) const noexcept {
+ return deserialize<int64_t>(value);
}
+SaveManager::SaveManager() { dbg_trace(); }
+
SaveManager & SaveManager::get_instance() {
dbg_trace();
static SaveManager instance;
@@ -118,17 +134,19 @@ template void SaveManager::set(const string &, const double &);
template <typename T>
ValueBroker<T> SaveManager::get(const string & key, const T & default_value) {
- if (!this->has(key))
- this->set<T>(key, default_value);
+ if (!this->has(key)) this->set<T>(key, default_value);
return this->get<T>(key);
}
template ValueBroker<uint8_t> SaveManager::get(const string &, const uint8_t &);
template ValueBroker<int8_t> SaveManager::get(const string &, const int8_t &);
-template ValueBroker<uint16_t> SaveManager::get(const string &, const uint16_t &);
+template ValueBroker<uint16_t> SaveManager::get(const string &,
+ const uint16_t &);
template ValueBroker<int16_t> SaveManager::get(const string &, const int16_t &);
-template ValueBroker<uint32_t> SaveManager::get(const string &, const uint32_t &);
+template ValueBroker<uint32_t> SaveManager::get(const string &,
+ const uint32_t &);
template ValueBroker<int32_t> SaveManager::get(const string &, const int32_t &);
-template ValueBroker<uint64_t> SaveManager::get(const string &, const uint64_t &);
+template ValueBroker<uint64_t> SaveManager::get(const string &,
+ const uint64_t &);
template ValueBroker<int64_t> SaveManager::get(const string &, const int64_t &);
template ValueBroker<float> SaveManager::get(const string &, const float &);
template ValueBroker<double> SaveManager::get(const string &, const double &);
@@ -138,8 +156,8 @@ template <typename T>
ValueBroker<T> SaveManager::get(const string & key) {
T value;
return {
- [this, key] (const T & target) { this->set<T>(key, target); },
- [this, key, value] () mutable -> const T & {
+ [this, key](const T & target) { this->set<T>(key, target); },
+ [this, key, value]() mutable -> const T & {
value = this->deserialize<T>(this->get_db().get(key));
return value;
},
@@ -156,4 +174,3 @@ template ValueBroker<int64_t> SaveManager::get(const string &);
template ValueBroker<float> SaveManager::get(const string &);
template ValueBroker<double> SaveManager::get(const string &);
template ValueBroker<string> SaveManager::get(const string &);
-