C++ yaml cpp从文件导入字符串会产生工件吗?
当我尝试用yaml cpp做某事时,我被绳子卡住了。。特别是因为他们似乎不是往返的好 当我从一个文件中读取一个字符串,然后再导出该字符串时,在导出时似乎有一个工件。。即字符串:C++ yaml cpp从文件导入字符串会产生工件吗?,c++,yaml-cpp,C++,Yaml Cpp,当我尝试用yaml cpp做某事时,我被绳子卡住了。。特别是因为他们似乎不是往返的好 当我从一个文件中读取一个字符串,然后再导出该字符串时,在导出时似乎有一个工件。。即字符串: %YAML 1.2 --- key1: "this is a string" key2: this is another ... 当我简单地读写一些额外的字符添加到第一个“keyvalue”时: ::YAML::Node y(YAML::LoadFile(“testyaml.txt”); std::fstream ou
%YAML 1.2
---
key1: "this is a string"
key2: this is another
...
当我简单地读写一些额外的字符添加到第一个“keyvalue”时:
::YAML::Node y(YAML::LoadFile(“testyaml.txt”);
std::fstream out(“testyaml2.yml”,std::ios_base::out);
YAML::发射极em(输出);
em.SetIndent(2);
em.setString格式(双引号)//只是加上引号
相对长度单位
我可以忍受“丢失”标题信息,或者到处添加引号(我只是告诉解析器这样做对吗?)。然而,代码>不好。特别是因为这将在每个周期中持续进行(第二个读/写周期将增加两倍的工件等)
有没有办法阻止那些感叹号——为什么会有
::YAML::Node y(YAML::LoadFile("testyaml.txt"));
std::fstream out("testyaml2.yml", std::ios_base::out);
YAML::Emitter em(out);
em.SetIndent(2);
em.SetStringFormat(DoubleQuoted); //just to add quotes
em << y;
"key1": !<!> "this is a string"
"key2": "this is another"