majintao0131 / yaml-cpp

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

An emitter's option to strip starting "---" from the output #81

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The goal of the enhancement is to permit YAML::Emitter to be used in simple 
scenarios, like dumping simple data structures, or data structures intended to 
be aggregated as part of larger document:

struct Point {
    int x;
    int y;

    string ToString() const
    {
        YAML::Emitter out;
        out << YAML::Flow << YAML::BeginSeq << x << y << YAML::EndSeq;
        return out.c_str();
    }
};

Point pt = { 1, 2 };
string str = pt.ToString();
// should produce str = "[1, 2]", but produces "--- [1, 2]"

Original issue reported on code.google.com by polus...@gmail.com on 7 Nov 2010 at 9:58

GoogleCodeExporter commented 9 years ago
You're right, this should be an option.

Original comment by jbe...@gmail.com on 9 Nov 2010 at 8:00

GoogleCodeExporter commented 9 years ago
Fixed, r459.

The default now is *not* to write the doc start. If you want it (or a doc end), 
you can get it with `YAML::BeginDoc` or `YAML::EndDoc` (used just like 
begin/end seq/map).

Original comment by jbe...@gmail.com on 3 Mar 2011 at 9:27