majintao0131 / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

Option to add newlines in the emitter #77

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
You should be able to add a newline whenever you want while emitting YAML.

Original issue reported on code.google.com by jbe...@gmail.com on 21 Oct 2010 at 9:24

GoogleCodeExporter commented 9 years ago
Done! (r420)

The syntax is

{{{
emitter << YAML::BeginSeq;
emitter << "a" << YAML::Newline << "b" << "c";
emitter << YAML::EndSeq;
}}}

which outputs

{{{
---
- a

- b
- c
}}}

The only time a newline is not allowed is after an implicit key, since you 
can't have

foo
: bar

We could have it do

foo:
  bar

but that's more work (so maybe later/never).

Original comment by jbe...@gmail.com on 22 Oct 2010 at 4:19

GoogleCodeExporter commented 9 years ago

Original comment by jbe...@gmail.com on 22 Oct 2010 at 4:26