diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-05 15:46:58 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-05 15:46:58 -0400 |
commit | 149e7c0836927e14a926a952bd1a7f0d1b49e779 (patch) | |
tree | 2c7ac89387eb890d3d345217b79929e9a23f4ecf /tracker_config.cpp | |
parent | 0dace7831673170bd31eefa6bbe6e705211d3061 (diff) | |
download | lingo-ap-tracker-149e7c0836927e14a926a952bd1a7f0d1b49e779.tar.gz lingo-ap-tracker-149e7c0836927e14a926a952bd1a7f0d1b49e779.tar.bz2 lingo-ap-tracker-149e7c0836927e14a926a952bd1a7f0d1b49e779.zip |
Organised repo
Diffstat (limited to 'tracker_config.cpp')
-rw-r--r-- | tracker_config.cpp | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/tracker_config.cpp b/tracker_config.cpp deleted file mode 100644 index 96bb60a..0000000 --- a/tracker_config.cpp +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | #include "tracker_config.h" | ||
2 | |||
3 | #include <fstream> | ||
4 | #include <yaml-cpp/yaml.h> | ||
5 | |||
6 | constexpr const char* CONFIG_FILE_NAME = "config.yaml"; | ||
7 | |||
8 | void TrackerConfig::Load() { | ||
9 | try { | ||
10 | YAML::Node file = YAML::LoadFile(CONFIG_FILE_NAME); | ||
11 | |||
12 | ap_server = file["ap_server"].as<std::string>(); | ||
13 | ap_player = file["ap_player"].as<std::string>(); | ||
14 | ap_password = file["ap_password"].as<std::string>(); | ||
15 | } catch (const std::exception&) { | ||
16 | // It's fine if the file can't be loaded. | ||
17 | } | ||
18 | } | ||
19 | |||
20 | void TrackerConfig::Save() { | ||
21 | YAML::Node output; | ||
22 | output["ap_server"] = ap_server; | ||
23 | output["ap_player"] = ap_player; | ||
24 | output["ap_password"] = ap_password; | ||
25 | |||
26 | std::ofstream filewriter(CONFIG_FILE_NAME); | ||
27 | filewriter << output; | ||
28 | } | ||
29 | |||
30 | TrackerConfig& GetTrackerConfig() { | ||
31 | static TrackerConfig* instance = new TrackerConfig(); | ||
32 | return *instance; | ||
33 | } | ||