32 lines
749 B
C++
Executable File
32 lines
749 B
C++
Executable File
#include "config.h"
|
|
|
|
#include <json/json.h>
|
|
#include <fstream>
|
|
#include <iostream>
|
|
|
|
namespace Yc {
|
|
namespace Lib {
|
|
|
|
Config::Config() {
|
|
loadConfig();
|
|
}
|
|
|
|
void Config::loadConfig() {
|
|
std::ifstream configStream("/etc/yourpart/chatconfig.json", std::ifstream::binary);
|
|
configStream >> jsonConfig;
|
|
}
|
|
|
|
Json::Value Config::value(std::string groupName, std::string field) {
|
|
if (jsonConfig[groupName].isNull()) {
|
|
return "";
|
|
}
|
|
return jsonConfig[groupName][field];
|
|
}
|
|
|
|
Json::Value Config::group(std::string groupName) {
|
|
return jsonConfig[groupName];
|
|
}
|
|
|
|
} // namespace Lib
|
|
} // namespace Yc
|