#include "RcfConfig.h" #include #include using namespace std; #pragma comment(lib,"libyaml-cppmd-mt.lib") #define YAMLCONFIGFILEPATH "RcfConfig.yml" RcfConfig::RcfConfig() { try { YAML::Node node = YAML::LoadFile(YAMLCONFIGFILEPATH); if (node["Rcf"]) { this->m_RcfIp = node["Rcf"]["IP"].as(); this->m_RcfPort = node["Rcf"]["PORT"].as(); } } catch (const std::exception&) { // 配置文件 读取异常,重新初始化配置文件 YAML::Node node; std::ofstream fout(YAMLCONFIGFILEPATH); node["Rcf"]["IP"] = "127.0.0.1"; node["Rcf"]["PORT"] = 8821; fout << node; fout.close(); this->m_RcfIp = node["ACD"]["IP"].as(); this->m_RcfPort = node["ACD"]["PORT"].as(); } } RcfConfig RcfConfig::instance;