-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathConfig.cpp
executable file
·76 lines (61 loc) · 2.3 KB
/
Config.cpp
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <boost/property_tree/ini_parser.hpp>
#include "Config.h"
#include "FS/FS.h"
#include "App.h"
bool Config::loadConfig() {
char path[512];
FS::charPathFromVectorPath(path, FS::getConfigPath());
//Log(LOG_LEVEL_INFO) << "FS::readFile(FS::getConfigPath()):" << FS::readFile(FS::getConfigPath());
try {
boost::property_tree::ptree pt;
boost::property_tree::ini_parser::read_ini(path, pt);
this->blockchainPath = pt.get<std::string>("blockchainPath");
this->allowFrom = pt.get<std::string>("allowFrom");
this->donationAddress = pt.get<std::string>("donationAddress");
this->apiKey = pt.get<std::string>("apiKey");
this->numberOfAdresses = (uint32_t)std::stoi(pt.get<std::string>("numberOfAdresses"));
this->mintingStatus = pt.get<std::string>("minting");
this->logLevel = LOG_LEVEL_INFO;
if(pt.get<std::string>("logLevel") == "NOTICE") {
this->logLevel = LOG_LEVEL_NOTICE;
} else if(pt.get<std::string>("logLevel") == "INFO") {
this->logLevel = LOG_LEVEL_INFO;
} else if(pt.get<std::string>("logLevel") == "WARNING") {
this->logLevel = LOG_LEVEL_WARNING;
} else if(pt.get<std::string>("logLevel") == "ERROR") {
this->logLevel = LOG_LEVEL_ERROR;
} else if(pt.get<std::string>("logLevel") == "CRITICAL") {
this->logLevel = LOG_LEVEL_CRITICAL_ERROR;
}
} catch (const std::exception& e) {
Log(LOG_LEVEL_ERROR) << "Config::loadConfig() exception:" << e.what();
App &app = App::Instance();
app.immediateTerminate();
return false;
}
return true;
}
std::string Config::getBlockchainPath() {
return this->blockchainPath;
}
std::string Config::getAllowFrom() {
return this->allowFrom;
}
uint32_t Config::getNumberOfAdresses() {
return this->numberOfAdresses;
}
uint8_t Config::getLogLevel() {
return this->logLevel;
}
std::string Config::getDonationAddress() {
return this->donationAddress;
}
std::string Config::getApiKey() {
return this->apiKey;
}
void Config::setMintingStatus(std::string mintingStatus) {
this->mintingStatus = mintingStatus;
}
bool Config::isMintingEnabled() {
return this->mintingStatus.compare("ON") == 0 || this->mintingStatus.compare("on") == 0;
}