aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-08 11:36:39 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-08 11:36:39 +0100
commitbf177644dc5de58791eb80b11af9d6b4877b0a24 (patch)
treed85656633677397152dae729e7ec67069c13ec3e /src/crepe/api
parent1c4156ee127b14760ed3b1a0cd16ad12180c7ac6 (diff)
`make format`
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/Config.cpp1
-rw-r--r--src/crepe/api/Config.h6
-rw-r--r--src/crepe/api/SaveManager.cpp53
-rw-r--r--src/crepe/api/SaveManager.h7
4 files changed, 41 insertions, 26 deletions
diff --git a/src/crepe/api/Config.cpp b/src/crepe/api/Config.cpp
index d6206da..0100bcc 100644
--- a/src/crepe/api/Config.cpp
+++ b/src/crepe/api/Config.cpp
@@ -6,4 +6,3 @@ Config & Config::get_instance() {
static Config instance;
return instance;
}
-
diff --git a/src/crepe/api/Config.h b/src/crepe/api/Config.h
index 56e3af5..8c9e643 100644
--- a/src/crepe/api/Config.h
+++ b/src/crepe/api/Config.h
@@ -7,6 +7,7 @@ namespace crepe {
class Config {
private:
Config() = default;
+
public:
~Config() = default;
@@ -16,8 +17,8 @@ public:
// singleton
Config(const Config &) = delete;
Config(Config &&) = delete;
- Config & operator = (const Config &) = delete;
- Config & operator = (Config &&) = delete;
+ Config & operator=(const Config &) = delete;
+ Config & operator=(Config &&) = delete;
public:
//! Logging-related settings
@@ -60,4 +61,3 @@ public:
};
} // namespace crepe
-
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 &);
-
diff --git a/src/crepe/api/SaveManager.h b/src/crepe/api/SaveManager.h
index 3073656..4be85fb 100644
--- a/src/crepe/api/SaveManager.h
+++ b/src/crepe/api/SaveManager.h
@@ -93,8 +93,8 @@ public:
static SaveManager & get_instance();
SaveManager(const SaveManager &) = delete;
SaveManager(SaveManager &&) = delete;
- SaveManager & operator = (const SaveManager &) = delete;
- SaveManager & operator = (SaveManager &&) = delete;
+ SaveManager & operator=(const SaveManager &) = delete;
+ SaveManager & operator=(SaveManager &&) = delete;
private:
/**
@@ -110,5 +110,4 @@ private:
static DB & get_db();
};
-}
-
+} // namespace crepe