How to set emit style for specific yaml-cpp node

I emit a YAML document as follows:

YAML::Node doc; // ...populate doc... YAML::Emitter out; out << doc; 

Somewhere in the node hierarchy, I have a specific sequence that I would like to emit in the Flow style, and everything else should use the default style settings.

I canโ€™t find a way to do this otherwise than manually emit each node and keep track of the nodes that interest me. It seems like a high price to pay for something relatively simple.

Ideally, I would like to tag the Node tag to say: "If you are emitting, do it with the following style." But I do not think there is support for this.

Can anyone think about how to manually fix the entire document?

Thank you very much.

+4
source share
2 answers

This feature has already been implemented as indicated in this question .

You can set the node style with the following code

 node.SetStyle(YAML::EmitterStyle::Flow); 

or

 node.SetStyle(YAML::EmitterStyle::Block); 
+2
source

This is currently not possible, but I presented it as a function request:

http://code.google.com/p/yaml-cpp/issues/detail?id=184

+1
source

All Articles