c++ - 将属性树 boost 为字符串

标签 c++ boost

需要通过互联网传输存储在 ini 文件中的系统配置。我正在使用 boost 来处理配置 ini 文件。如何将整个属性树保存为字符串?

最佳答案

只需写入一个std::stringstream:

std::ostringstream oss;
boost::property_tree::ini_parser::write_ini(oss, my_ptree);

std::string inifile_text = oss.str();

酌情替换为wstring/wostringstream

关于c++ - 将属性树 boost 为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27291726/

相关文章:

c++ - 在 Linux 中从内存中压缩文件

c++ - 在过渡到 C++11 期间管理外部库(例如 boost)

c++ - 当通知程序/信号超出范围时,取消分配 boost 绑定(bind)中的回调监听器对象

c++ - 编译llvm 3.1时,为什么会出错: ‘>’ token 之前的预期主表达式

c++ - 将元素插入排序数组并找到其索引的最有效方法

boost multi_index_container 和删除性能

c++ - 使用流中的 boost binary_iarchive 序列化和反序列化

c++ - Ubuntu:C++::Boost库升级

c++ - Dan Bernstein 为 C++ 编写的 djb2

c++ - 访问 vector 的通用迭代器