多次加载属性树xml解析器异常
Multiple loads of property tree xml-parser exception
我正在使用属性树xml解析来编辑应用程序的一些设置我创建了一个struct default-settings
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");
}
和I访问变量: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..
你有什么建议?
问题是使用const std::string作为参数!
相关文章:
- 处理多个异常集合的C++方法
- 我在c++代码中生成了一个运行时#3异常
- Cppcheck生成xml转储文件
- 孤立代码块在结构中引发异常
- C++中的赋值发生,尽管右侧出现异常
- 从构造函数抛出异常时如何克服内存泄漏
- 异常属于C++中的线程还是进程
- 当类定义不可见时捕获异常
- 引发异常:读取访问冲突**dynamicArray**为0x1118235.发生
- 为什么异常不退出程序?
- 如何在pugixml中获取节点的内部XML
- 如何使用tinyxml2从XML加载父实体和子实体
- 为什么我应该在异常处理中使用std::cerr而不是std::cout
- 如何修复链表类实现的未处理异常0xDDDDDDDD
- 关于:C++中异常对象的范围:为什么我没有得到副本?
- 是什么导致了Unity 3D中的"错误线程异常"?
- C#.Net 4.0应用程序中托管的C++ActiveX控件中出现Xml.Serializer非法强制转换异常
- 如何从ptree异常中获取xml行号
- 多次加载属性树xml解析器异常
- POCO C++SAX解析器:如果xml文档编码是ANSI,那么下一条语句不是读取并抛出编码错误异常