-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.cpp
More file actions
76 lines (69 loc) · 1.62 KB
/
Copy pathConfig.cpp
File metadata and controls
76 lines (69 loc) · 1.62 KB
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 "Config.h"
#include <stdio.h>
#include <iostream>
#include <json/json.h>
#include <fstream>
#include <filesystem>
#include <glog/logging.h>
namespace fs = std::filesystem;
CConfig* CConfig::m_pObj = nullptr;
CConfig::CConfig() {
fs::path lsPath = fs::current_path();
lsPath.append("config.json");
if (!fs::exists(lsPath)) {
LOG(ERROR) << "Not Found" << lsPath;
exit(0);
}
Json::Reader reader;
Json::Value root;
std::ifstream in(lsPath, std::ios::binary);
if (!in.is_open()) {
LOG(ERROR) << "Open Err" << lsPath;
exit(0);
}
if (!reader.parse(in, root)){
LOG(ERROR) << "Parse Err" << lsPath;
exit(0);
}
if (root.isMember("fullbfq") && root["fullbfq"].isString()) {
m_sBfqDBPath = root["fullbfq"].asString();
}
if (root.isMember("fullqfq") && root["fullqfq"].isString()) {
m_sQfqDBPath = root["fullqfq"].asString();
}
if (root.isMember("fullhfq") && root["fullhfq"].isString()) {
m_sHfqDBPath = root["fullhfq"].asString();
}
LOG(INFO) << "BFQ DB " << m_sBfqDBPath;
LOG(INFO) << "QFQ DB " << m_sQfqDBPath;
LOG(INFO) << "HFQ DB " << m_sHfqDBPath;
}
CConfig::~CConfig() {
}
CConfig* CConfig::GetConfig() {
if (nullptr == m_pObj) {
m_pObj = new CConfig();
}
return m_pObj;
}
std::string CConfig::GetBFQDbPath() {
CConfig* obj = CConfig::GetConfig();
if (nullptr != obj){
return obj->m_sBfqDBPath;
}
return "";
}
std::string CConfig::GetQFQDbPath() {
CConfig* obj = CConfig::GetConfig();
if (nullptr != obj) {
return obj->m_sQfqDBPath;
}
return "";
}
std::string CConfig::GetHFQDbPath() {
CConfig* obj = CConfig::GetConfig();
if (nullptr != obj) {
return obj->m_sHfqDBPath;
}
return "";
}