-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.h
53 lines (36 loc) · 1.85 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
53
#pragma once
namespace settings
{
wstring path = L"C:\\nbu_parser"; //ïóòü äëÿ ñîõðàíåíèÿ äàííûõ
wstring rates_filename = L"rates.json"; //íàçâàíèå ôàéëà ñ äàííûìè î âàëþòå
wstring logs_filename = L"logs.txt"; //íàçâàíèå ôàéëà ñ ëîãàìè
json currencies = json::parse(LR"(["EUR", "USD"])");//êàêèå âàëþòû íóæíî ñîõðàíÿòü
int update_rate = 60000; //÷àñòîòà ñîõðàíåíèÿ äàííûõ î âàëþòå â ìèëëèñåêóíäàõ
bool logs = true; //íóæíî ëè çàïèñûâàòü ëîãè
//ïðîñòàÿ çàãðóçêà äàííûõ èç ðååñòðà
void load()
{
RegKey key;
RegResult result = key.TryOpen(HKEY_LOCAL_MACHINE, L"SOFTWARE\\nbu_parser");
if (!result)
key.Create(HKEY_LOCAL_MACHINE, L"SOFTWARE\\nbu_parser");
if (!key.TryGetStringValue(L"path").IsValid())
key.SetStringValue(L"path", L"C:\\\\nbu_parser");
path = key.GetStringValue(L"path");
if (!key.TryGetStringValue(L"rates_filename").IsValid())
key.SetStringValue(L"rates_filename", L"rates.json");
rates_filename = key.GetStringValue(L"rates_filename");
if (!key.TryGetStringValue(L"logs_filename").IsValid())
key.SetStringValue(L"logs_filename", L"logs.txt");
logs_filename = key.GetStringValue(L"logs_filename");
if (!key.TryGetStringValue(L"currencies").IsValid())
key.SetStringValue(L"currencies", LR"(["EUR", "USD"])");
currencies = json::parse(key.GetStringValue(L"currencies"));
if (!key.TryGetDwordValue(L"update_rate").IsValid())
key.SetDwordValue(L"update_rate", 60000);
update_rate = key.GetDwordValue(L"update_rate");
if (!key.TryGetDwordValue(L"logs").IsValid())
key.SetDwordValue(L"logs", 1);
logs = (bool)key.GetDwordValue(L"logs");
}
}