From dc93b1e9b3e05dfd3e271aaccbee1210180a6906 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 7 Nov 2024 21:19:01 +0100 Subject: update clang-format and run `make format` over my (loek)s files --- src/crepe/api/SaveManager.cpp | 53 ++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 18 deletions(-) (limited to 'src/crepe/api/SaveManager.cpp') 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(value); } -template <> int8_t SaveManager::deserialize(const string & value) const noexcept { return deserialize(value); } -template <> uint16_t SaveManager::deserialize(const string & value) const noexcept { return deserialize(value); } -template <> int16_t SaveManager::deserialize(const string & value) const noexcept { return deserialize(value); } -template <> uint32_t SaveManager::deserialize(const string & value) const noexcept { return deserialize(value); } -template <> int32_t SaveManager::deserialize(const string & value) const noexcept { return deserialize(value); } - -SaveManager::SaveManager() { - dbg_trace(); +template <> +uint8_t SaveManager::deserialize(const string & value) const noexcept { + return deserialize(value); +} +template <> +int8_t SaveManager::deserialize(const string & value) const noexcept { + return deserialize(value); +} +template <> +uint16_t SaveManager::deserialize(const string & value) const noexcept { + return deserialize(value); +} +template <> +int16_t SaveManager::deserialize(const string & value) const noexcept { + return deserialize(value); +} +template <> +uint32_t SaveManager::deserialize(const string & value) const noexcept { + return deserialize(value); +} +template <> +int32_t SaveManager::deserialize(const string & value) const noexcept { + return deserialize(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 ValueBroker SaveManager::get(const string & key, const T & default_value) { - if (!this->has(key)) - this->set(key, default_value); + if (!this->has(key)) this->set(key, default_value); return this->get(key); } template ValueBroker SaveManager::get(const string &, const uint8_t &); template ValueBroker SaveManager::get(const string &, const int8_t &); -template ValueBroker SaveManager::get(const string &, const uint16_t &); +template ValueBroker SaveManager::get(const string &, + const uint16_t &); template ValueBroker SaveManager::get(const string &, const int16_t &); -template ValueBroker SaveManager::get(const string &, const uint32_t &); +template ValueBroker SaveManager::get(const string &, + const uint32_t &); template ValueBroker SaveManager::get(const string &, const int32_t &); -template ValueBroker SaveManager::get(const string &, const uint64_t &); +template ValueBroker SaveManager::get(const string &, + const uint64_t &); template ValueBroker SaveManager::get(const string &, const int64_t &); template ValueBroker SaveManager::get(const string &, const float &); template ValueBroker SaveManager::get(const string &, const double &); @@ -138,8 +156,8 @@ template ValueBroker SaveManager::get(const string & key) { T value; return { - [this, key] (const T & target) { this->set(key, target); }, - [this, key, value] () mutable -> const T & { + [this, key](const T & target) { this->set(key, target); }, + [this, key, value]() mutable -> const T & { value = this->deserialize(this->get_db().get(key)); return value; }, @@ -156,4 +174,3 @@ template ValueBroker SaveManager::get(const string &); template ValueBroker SaveManager::get(const string &); template ValueBroker SaveManager::get(const string &); template ValueBroker SaveManager::get(const string &); - -- cgit v1.2.3