1
我想用YAML-CPP库按以下格式发出的映射关系的映射seqence在YAML-CPP的序列:如何发出额外的换行符
-
name: <some_name>
value: <some_value>
我使用这个代码:
Emitter out;
out << YAML::BeginSeq;
for (unsigned int i = 0; i < prof_info_.numOfSettings; ++i)
{
str = NvUS_to_string(stgs[i].settingName);
if (str != "")
{
out << YAML::BeginMap;
out << YAML::Key << "name";
out << YAML::Value << str;
string d_str = get_value_name_from_value_id(stgs[i].settingId, (unsigned int)stgs[i].u32CurrentValue);
out << YAML::Key << "value";
out << YAML::Value << d_str;
out << YAML::EndMap;
}
}
out << YAML::EndSeq;
f_out << out.c_str();
和我越来越:
- name: <some_name>
value: <some_value>
我尝试添加
out << YAML::NewLine;
在地图的开头,但它给出了错误的结果。我怎样才能得到我想要的输出?
你想要的格式无效YAML。 –
为什么? [http://www.yaml.org/](http://www.yaml.org/spec/1.2/spec.html#id2759963) – toodef
yaml中的缩进问题。你想让它看起来像你的链接中的例子2.4吗? –