Pregunta

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.

¿Fue útil?

Solución

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);

Otros consejos

That's currently not possible, but I've submitted it as a feature request:

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top