I'm emitting a YAML document as follows:
YAML::Node doc; // ...populate doc...
YAML::Emitter out;
out << doc;
Somewhere in the hierarchy of nodes I have a particular sequence that I would like to emit in the Flow
style while everything else should use the default style settings.
I can't seem to find any way of doing this other than emitting by hand every node and watching out for the nodes I'm interested in. This seems like a high price to pay for something relatively straightforward.
Ideally I'd like to be able to tag the Node
to say "If you get emitted, do so with the following style". But I don't think there's any support for this.
Can anyone think of a way around having to emit the whole document by hand?
Many thanks.
This feature has already been implemented as pointed out in this question.
You can set the node style with the following code
node.SetStyle(YAML::EmitterStyle::Flow);
or
node.SetStyle(YAML::EmitterStyle::Block);