summaryrefslogblamecommitdiffstats
path: root/src/Settings.hpp
blob: 91321616ad21234bd09d195b5e60f6d4b0c29b9c (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12











                                                                                  
























                                                                               
 
#pragma once

#include <string>

namespace Settings {
	void Load();

	void Save();

	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));
	}

}