boost:property_tree::ini_parser:::read_ini 读取ini时崩溃
原因:
1 路径错误
2 配置文件中某一行缺少=,例如用// 做注释的,前面应该加";"
解决办法:
添加异常处理,实例代码如下:
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
boost::property_tree::ptree pt;
try
{
boost::property_tree::ini_parser::read_ini("./config.ini", pt);
}
catch(std::exception e)
{
cout<<e.what();
LOG(INFO)<<e.what();
return false;
}
m_strIP= pt.get<string>("HQSec.ip","127.0.0.1");