-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsettings.h
52 lines (40 loc) · 1.36 KB
/
settings.h
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
COPYRIGHT (C) 2025 ETHAN CHAN
ALL RIGHTS RESERVED. UNAUTHORIZED COPYING, MODIFICATION, DISTRIBUTION, OR USE
OF THIS SOFTWARE WITHOUT PRIOR PERMISSION IS STRICTLY PROHIBITED.
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM,
OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
PROJECT NAME: DieKnow
FILENAME: src/settings.h
DESCRIPTION: Setting configuration for DieKnow
AUTHOR: Ethan Chan
DATE: 2024-11-13
VERSION: 1.0.1
*/
#ifndef SETTINGS_H
#define SETTINGS_H
#include <unordered_map>
#include <string>
class Settings {
std::unordered_map<std::string, std::string> settings;
std::string path;
public:
bool load(const std::string& file_name);
template <typename T>
T get(const std::string& key, const T& default_value = T()) const;
bool set(const std::string& key, const std::string& value);
void print() const;
void update();
};
extern Settings settings;
template <>
bool Settings::get<bool>(
const std::string& key,
const bool& default_value
) const;
#endif // SETTINGS_H