From e4483eca01b48b943cd0461e24a74ae1a3139ed4 Mon Sep 17 00:00:00 2001 From: Nicolas James Date: Wed, 12 Feb 2025 21:57:46 +1100 Subject: Update to most recent version (old initial commit) --- src/client/settings.hh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/client/settings.hh') diff --git a/src/client/settings.hh b/src/client/settings.hh index d65022b..11b785c 100644 --- a/src/client/settings.hh +++ b/src/client/settings.hh @@ -9,7 +9,7 @@ #include -#include "client/shared.hh" +//#include "client/shared.hh" #include "shared/shared.hh" // This settings file just provides functionality for persistent variables, @@ -18,20 +18,20 @@ namespace client { namespace settings { -void set_setting_str( - const std::pair loc, - const std::string& value) noexcept; +using setting_pair_t = std::pair; -std::string -get_setting_str(const std::pair loc, - const std::string default_value) noexcept; +std::optional maybe_get_setting_str(const setting_pair_t&); + +void set_setting_str(const setting_pair_t& loc, const std::string& value); + +std::string get_setting_str(const setting_pair_t& loc, + const std::string default_value); // Attempts to read the setting in the file, returning it if it exists. // If either name or category does not exist, writes the default value in // the file under the expected headings. template -T get(const std::pair& loc, - const T& default_value) noexcept { +T get(const setting_pair_t& loc, const T& default_value) { const std::string value = get_setting_str(loc, boost::lexical_cast(default_value)); return boost::lexical_cast(value); @@ -40,12 +40,11 @@ T get(const std::pair& loc, // Attempts to set the setting in the file, overwriting the pre-existing // value or writing a new entry. template -void set(const std::pair& loc, - const T& value) noexcept { +void set(const setting_pair_t& loc, const T& value) { set_setting_str(loc, boost::lexical_cast(value)); } -void save() noexcept; +void save(); } // namespace settings } // namespace client -- cgit v1.2.3