Chapter 56. Writing YAML documents

Index

x::yaml::newdocumentnodes
Writing x::yaml::newnodes
Writing a sequence
Writing a mapping
Writing a scalar value
Writing an alias reference
Example of writing a YAML document

Writing a YAML document consists of instantiating reference-counted objects that represent the mapping, sequences, scalars, and alias references that form a YAML document. Each one of these objects are paired with a functor or a lambda, that gets invoked to create the values for its corresponding object.

The object that represents the YAML document's top level node gets returned by a lambda or a functor that's attached to a x::yaml::newdocumentnode.

x::yaml::newdocumentnodes

x::yaml::newnode list_of_highest_points_to_yaml();

// ...

x::yaml::newdocumentnode highest_points=x::yaml::make_newdocumentnode
    ([]
    {
        return list_of_highest_points_to_yaml();
    });

x::yaml::newdocumentnode is an object that represents a new YAML document that gets written to an output iterator.

Each x::yaml::newdocumentnode gets created by x::yaml::make_newdocumentnode, whose parameter is a lambda or a functor. The functions described in the next section invoke the lambda or the functor to retrieve the object that represents the document's top level node, a sequence or mapping. The top level's lambda/functor consequently constructs the values that go into the sequence or mapping, and their corresponding lambda/functors then construct the corresponding objects, and so on, until the entire document gets formed.

highest_point->start_implicit=false;

The reference-counted object referenced by a x::yaml::newdocumentnode has several members.

start_implicit (true by default)

Specifies whether the document's start indicator is implicit.

end_implicit (true by default)

Specifies whether the document's end indicator is implicit.

tags

This is a std::map<std::string, std::string> that maps YAML tags to prefixes.