#include "../pch/pch.h" #include "CConfigReader.h" std::map CConfigReader::m_mapConfigInfo; CConfigReader::CConfigReader() { } CConfigReader::~CConfigReader() { } /* *读取配置文件内容,以#注释的忽略掉 **/ void CConfigReader::ReadConfigFile() { ifstream configFile; string path = "conf/config.ini"; configFile.open(path.c_str()); string str_line; if (configFile.is_open()) { while (!configFile.eof()) { getline(configFile, str_line); //过滤掉注释信息,即如果首个字符为#就过滤掉这一行 if (str_line.find('#') == 0) { continue; } size_t pos = str_line.find('='); string str_key = str_line.substr(0, pos); string str_value = str_line.substr(pos + 1); //去掉首尾的空格 CLewaimaiString::trim(str_key); CLewaimaiString::trim(str_value); CConfigReader::m_mapConfigInfo[str_key] = str_value; } } else { cout << "找不到配置文件,启动失败!"; LOG_INFO("找不到配置文件,启动失败!"); exit(-1); } } std::string CConfigReader::getConfigValue(std::string key) { if (CConfigReader::m_mapConfigInfo.find(key) == CConfigReader::m_mapConfigInfo.end()) { cout << "找不到配置文件参数:"< 10) { n_deliveryman_max_order_num = 10; } if (n_deliveryman_max_order_num < 1) { n_deliveryman_max_order_num = 1; } return n_deliveryman_max_order_num; }