Initial submit
This commit is contained in:
29
config.cpp
29
config.cpp
@@ -1,12 +1,31 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <json/json.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace Yc {
|
||||
namespace Lib {
|
||||
namespace Lib {
|
||||
|
||||
Config::Config()
|
||||
{
|
||||
Config::Config() {
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
}
|
||||
void Config::loadConfig() {
|
||||
std::ifstream configStream("/etc/yourpart/chatconfig.json", std::ifstream::binary);
|
||||
configStream >> jsonConfig;
|
||||
}
|
||||
|
||||
} // namespace Lib
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user