diff options
Diffstat (limited to 'src/Settings.hpp')
-rw-r--r-- | src/Settings.hpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Settings.hpp b/src/Settings.hpp index 194e736..9132161 100644 --- a/src/Settings.hpp +++ b/src/Settings.hpp @@ -10,4 +10,29 @@ namespace Settings { std::string Read(const std::string &key, const std::string &defaultValue); void Write(const std::string &key, const std::string &value); + + inline bool ReadBool(const std::string &key, bool defaultValue) { + return Read(key, std::to_string(defaultValue)) == "true"; + } + + inline void WriteBool(const std::string &key, bool value) { + Write(key, value ? "true" : "false"); + } + + inline int ReadInt(const std::string &key, int defaultValue) { + return std::stoi(Read(key, std::to_string(defaultValue))); + } + + inline void WriteInt(const std::string &key, int value) { + Write(key, std::to_string(value)); + } + + inline double ReadDouble(const std::string &key, double defaultValue) { + return std::stod(Read(key, std::to_string(defaultValue))); + } + + inline void WriteDouble(const std::string &key, double value) { + Write(key, std::to_string(value)); + } + }
\ No newline at end of file |