-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.cpp
More file actions
41 lines (29 loc) · 792 Bytes
/
Config.cpp
File metadata and controls
41 lines (29 loc) · 792 Bytes
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
//
// Created by neoql on 1/6/18.
//
#include <fstream>
#include <iostream>
#include "Config.h"
#ifdef _WIN32
#define CONFIG_PATH "./config/"
#else
#define CONFIG_PATH "/etc/WechatJumpHelper/"
#endif
using namespace std;
Config::Config(const char *path) {
Json::CharReaderBuilder builder;
ifstream ifs(path);
this->root = new Json::Value;
Json::parseFromStream(builder, ifs, this->root, nullptr);
}
Config::Config(const int &height, const int &width) {
char path[128];
sprintf(path, "%s%dx%d/config.json", CONFIG_PATH, height, width);
new (this)Config(path);
}
Config::~Config() {
delete this->root;
}
const Json::Value &Config::operator[](const char *key) const {
return this->root->operator[](key);
}