diff options
Diffstat (limited to 'src/client/settings.hh')
| -rw-r--r-- | src/client/settings.hh | 23 |
1 files changed, 11 insertions, 12 deletions
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 <boost/lexical_cast.hpp> -#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<const std::string&, const std::string&> loc, - const std::string& value) noexcept; +using setting_pair_t = std::pair<std::string, std::string>; -std::string -get_setting_str(const std::pair<const std::string&, const std::string&> loc, - const std::string default_value) noexcept; +std::optional<std::string> 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 <typename T> -T get(const std::pair<const std::string, const std::string>& 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<std::string>(default_value)); return boost::lexical_cast<T>(value); @@ -40,12 +40,11 @@ T get(const std::pair<const std::string, const std::string>& loc, // Attempts to set the setting in the file, overwriting the pre-existing // value or writing a new entry. template <typename T> -void set(const std::pair<const std::string, const std::string>& loc, - const T& value) noexcept { +void set(const setting_pair_t& loc, const T& value) { set_setting_str(loc, boost::lexical_cast<std::string>(value)); } -void save() noexcept; +void save(); } // namespace settings } // namespace client |
