summaryrefslogtreecommitdiffstats
path: root/src/Settings.hpp
blob: 91321616ad21234bd09d195b5e60f6d4b0c29b9c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#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));
	}

}