MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / LoadConfig

Function LoadConfig

src/Settings.cpp:122–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120namespace cfg_details {
121
122 TStatus LoadConfig(ProgramConfig& cfg) {
123 try {
124
125 auto p = ProgramConfig::GetPath_Conf();
126 if (!std::filesystem::is_regular_file(p)) {
127 // конфиг файла еще нет - считаем что загружены конфигом по-умолчанию.
128 RETURN_SUCCESS;
129 }
130
131 std::ifstream ifs(p, std::ios::binary);
132
133 json data = json::parse(ifs, nullptr, true, true);
134 data.get_to(cfg);
135
136 const auto& arr = data["hotkeys"];
137
138 if (arr.is_object()) {
139 for (auto& elem : cfg.hotkeysList) {
140 auto key = HotKeyTypeName(elem.hkId);
141 if (key.empty()) continue;
142 auto it = arr.find(key);
143 if (it != arr.end()) {
144 elem.keys = it.value();
145 }
146 }
147 }
148
149 cfg.NormalizePaths();
150
151 if (cfg.force_DbgMode) {
152 SetLogLevel_print_info(cfg.logLevel);
153 }
154
155
156 }
157 catch (std::exception& e) {
158 LOG_ANY("error load={}", e.what());
159 return SW_ERR_JSON;
160 }
161
162
163 RETURN_SUCCESS;
164 }
165
166
167 TStatus Save_conf(const ProgramConfig& gui) {

Callers 1

ReloadGuiConfigFunction · 0.85

Calls 9

parseFunction · 0.85
HotKeyTypeNameFunction · 0.85
SetLogLevel_print_infoFunction · 0.85
get_toMethod · 0.80
findMethod · 0.80
NormalizePathsMethod · 0.80
emptyMethod · 0.45
endMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected