gpt4 book ai didi

c++ - 如何为 Boost.PropertyTree 提供字符串而不是文件?

转载 作者:IT老高 更新时间:2023-10-28 22:18:53 25 4
gpt4 key购买 nike

Boost 有 tutorial on how to load XML from a file .如何使用我在代码中创建或从用户接收的字符串(例如使用 cin)提供它?

最佳答案

这里有一些适合我的代码...

// Create an empty property tree object
ptree xmlTree;

// Read the XML config string into the property tree. Catch any exception
try {
stringstream ss; ss << xmlConfigString;
read_xml(ss, xmlTree);
}
catch (xml_parser_error &e) {
LOGERROR ("Failed to read config xml " << e.what());
}
catch (...) {
LOGERROR ("Failed to read config xml with unknown error");
}

关于c++ - 如何为 Boost.PropertyTree 提供字符串而不是文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5289086/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com