Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/153.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ yaml cpp从文件导入字符串会产生工件吗?_C++_Yaml Cpp - Fatal编程技术网

C++ 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 cpp做某事时,我被绳子卡住了。。特别是因为他们似乎不是往返的好

当我从一个文件中读取一个字符串,然后再导出该字符串时,在导出时似乎有一个工件。。即字符串:

%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"