- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
以下代码在调用 boost::property_tree::read_xml() 时因段错误而崩溃。只有在使用 boost::asio::spawn() 生成的 io_service 处理程序内部调用它时才会发生这种情况。如果处理程序刚刚发布,它就可以正常工作。是否有解决方法或解决方法?( boost 1.61)
#include <boost/asio/spawn.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <iostream>
#include <sstream>
#include <thread>
void process()
{
std::cerr << "start"<< std::endl;
std::istringstream is("<t>1</t>");
boost::property_tree::ptree pt;
boost::property_tree::read_xml(is, pt); // <<< seg fault here
std::cerr << std::endl << "end" << std::endl;
}
int main()
{
boost::asio::io_service io_service;
boost::asio::spawn(io_service, [] (boost::asio::yield_context y){
process();
});
io_service.run();
return 0;
}
最佳答案
经过一番挖掘,我们发现 seg 错误是由协程的堆栈溢出引起的,因为在 boost::property_tree::read_xml() 中使用的 rapidxml 解析器默认为每个 xml 文档中的静态内存池在堆栈上分配 64KB。
解决方案是减小池的大小,如下所示:
#define BOOST_PROPERTY_TREE_RAPIDXML_STATIC_POOL_SIZE 512
#include <boost/property_tree/xml_parser.hpp>
另一种解决方案是增加协程的堆栈大小。
关于c++ - 使用 boost::asio::spawn 生成的 asio 处理程序中的 boost::property_tree::read_xml 段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41030285/
我需要在我的程序中使用 boost::property_tree。现在我很难弄清楚如何将它与自定义路径类型一起使用。我想要的路径类型是 Framework::CommonClientServer::I
如何在循环数组时向属性树添加节点? 这可能是一件简单的事情,但我只是不明白如何使用 boost_property_tree。 我有一组值,我想将其添加到属性树并将其输出为 xml。如果我对节点进行硬编
请考虑两个“boost::property_tree”-s。 ptree1: { "node1" : 1, "node_that_only_appears_in_this_one" :
我正在使用 boost::property_tree 从/向文件加载/保存一组参数。其中许多参数是枚举(不同类型)。所以我需要一种从 boost::property_tree 获取枚举的方法(即将字符
我想使用 boost property_tree 解析下面的 xml 结构。 我能够解析上面 xml 的第一
是否可以在 boost 属性树中存储指向对象的指针,然后使用迭代器检索数据?我正在尝试做类似的事情: property_tree::ptree pt; pt.put("1.2.3.4", new My
感谢 Boost::Property_Tree,我正在尝试配置我的 XML 文件。我想要的聊天是: 10 我所拥有的是: first>10 我发现我不得不使用 boost::property_
我需要从文件中读取属性以影响程序行为。看起来 boost::property_tree 会做得很好。但是,我想知道在获取不同类型的值时,库是否可能会多次读取文件? 出于性能原因,我希望它只有一次。大多
我正在加载一个带有 boost property_tree 的 ini 文件。我的 ini 文件主要包含“简单”类型(即字符串、整数、 double 等),但我确实有一些值表示数组。 [Example
我的 JSON 是这样的: { "apps":[ { "id":"x", "val":"y", } ]
我发现 boost::property_tree::ptree 有巨大的内存开销。我的估计是一个空的 ptree 大约有 150 个字节,并且,放入 ptree 中的任何条目至少增加了 150 个字节
我想要的是这样的: Mr. Heik 37/100
我正在读取 xml 文件并存储到 boost::property_tree::ptree pt(object) 中。 我正在尝试使用在 ptree_serialization.hpp 中定义的方法 s
考虑以下示例: #include #include typedef boost::property_tree::ptree PT; struct Foo { int bar; in
假设我有两个 XML: foo foo 有没有办法在不指定绝对路径的情况下使用属性树从两个 xml 中提取 my_value? 目前我能做的最好的是: std::string first("some.
我正在类成员函数中执行 ptree.put()。 class Writer{ private: boost::property_tree::ptree ptree_; public:
我正在尝试使用显示的方法从 boost::property_tree 中读取数组数据 in this question .在该示例中,数组首先作为字符串读取,转换为字符串流,然后读入数组。在实现该解决
我正在寻找与 boost::property_tree 非常相似的结构.但是它应该更加类型安全,例如我想在我这样做时得到一个异常(exception): #include int main() {
我需要解析一些 INI 文件。为此,我尝试使用 boost::property_tree,但在我的系统中不允许出现异常。 如何在使用 boost::property_tree 时禁用异常支持? 如果没
如何从 boost::property_tree 中获取枚举? 这是我的“非工作”示例。 配置文件 EMISSION::EMIT1 42 main.cpp #include #inclu
我是一名优秀的程序员,十分优秀!