0
我使用属性树的多路负载XML的解析,为我的应用程序 编辑一些设置,我创建了一个结构默认设置属性树XML解析器异常
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");
}
,我访问的变量:Impath的, calPath ..等 在我的应用程序default_settings DS 创建一个全局变量,并要求他们通过这个变量(ds.imPath)
奇怪的是,它的作品当负载一旦这样做,但我得到一个异常
boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::property_tree::xml_parser::xml_parser_error> > at memory location 0x0016bf54..
你有什么建议?
你试过调试过吗?你每次都使用_same属性tree_作为目标吗?注入的错误信息是什么? – sehe
因为你看到我创建一个新的ptree每次我访问函数加载 –
我试图使用1 ptree作为一个全局变量和clear()它每次我输入函数,但仍然是同样的问题! –