- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
现在我想通过Boost ptree
生成一个加密的XML文件。
using boost::property_tree::ptree;
ptree pt;
pt.add("License.Unalterable.Signed.Guid", m_Guid);
pt.add("License.Unalterable.Signed.CustomerId", m_CustomerId);
pt.add("License.Unalterable.Signed.Name", m_Name);
pt.add("License.Unalterable.Signed.Version", m_version);
write_xml(licenseFileName, pt);
我想在调用 write_xml()
之前加密整个 xml 文件。通过阅读write_xml
的代码,我知道xml节点是从ptree中一个一个的读取出来的,然后立即一个一个的写入到fstream
中。 有没有办法在将其写入文件之前获取整个 xml 数据流?这样我就可以加密整个数据流,然后将它们写入文件。
目前,我的解决方案是在write_xml
创建后重新读取这个xml文件,然后加密xml内容后再写回。
最佳答案
评论者建议:
std::ostringstream oss;
write_xml(oss, pt);
// now you can encrypt
std::string plain_text = oss.str();
现在你可以加密明文并将密文写入文件
关于c++ - 如何通过 boost property_tree 加密 xml 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25785249/
我需要在我的程序中使用 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
我是一名优秀的程序员,十分优秀!