C++ 带有空格的yaml cpp格式映射

C++ 带有空格的yaml cpp格式映射,c++,yaml-cpp,C++,Yaml Cpp,使用yaml cpp库,是否可以使用空格格式化yaml::Emitter?例如,如果我有一个发射类似这样东西的结构: Fruit: - {Name: Apple, Number: 32} - {Name: Oranges, Number: 64} - {Name: Pineapple, Number: 128} Fruit: - {Name: Apple, Number: 32} - {Name: Oranges,

使用yaml cpp库,是否可以使用空格格式化yaml::Emitter?例如,如果我有一个发射类似这样东西的结构:

    Fruit:
     - {Name: Apple, Number: 32}
     - {Name: Oranges, Number: 64}
     - {Name: Pineapple, Number: 128}
    Fruit:
     - {Name: Apple,      Number: 32}
     - {Name: Oranges,    Number: 64}
     - {Name: Pineapple,  Number: 128}
我可以输出如下内容:

    Fruit:
     - {Name: Apple, Number: 32}
     - {Name: Oranges, Number: 64}
     - {Name: Pineapple, Number: 128}
    Fruit:
     - {Name: Apple,      Number: 32}
     - {Name: Oranges,    Number: 64}
     - {Name: Pineapple,  Number: 128}
这样做的动机是,我有非常大的地图,如果有一种方法可以格式化它们,使键按列排列,那么这些地图将更容易阅读。我之所以使用YAML::Flow而不是YAML::Block作为映射格式,是因为使用块格式,文件变得很长,很难读取。关于如何实现这一目标或类似目标,有什么想法吗


谢谢

你不能那样做;这不是yaml cpp的一个功能。您必须在块格式和流格式之间做出决定。

您不能这样做;这不是yaml cpp的一个功能。您必须在块格式和流格式之间做出决定