我正在使用属性树 xml-parsing 为我的应用程序编辑一些设置我创建了一个结构默认设置
struct default_settings
{
std::string imPath;
std::string calPath;
std::string solPath;
void load(const std::string &filename);
void save(const std::string &filename,const std::string &image_path,const std::string &cal_path,const std::string &sol_path);
};
void default_settings::save(const std::string &filename,const std::string &image_path,const std::string &cal_path,const std::string &sol_path)
{
ptree pt;
pt.put("default.image-path", image_path);
pt.put("default.cal-path", cal_path);
pt.put("default.sol-path", sol_path);
write_xml(filename, pt);
}
void default_settings::load(const std::string &filename)
{
ptree pt;
read_xml(filename, pt);
imPath = pt.get<std::string>("default.image-path");
calPath = pt.get<std::string>("default.cal-path");
solPath = pt.get<std::string>("default.sol-path");
}
我通过在我的应用程序 default_settings ds 中创建一个全局变量并通过此变量 (ds.imPath) 调用它们来访问变量:imPath、calPath、.. 等
奇怪的是,它在加载完成一次但我得到一个异常时工作
boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::property_tree::xml_parser::xml_parser_error> > at memory location 0x0016bf54..
你有什么建议?