Writing a sequence

x::yaml::newnode seq=x::yaml::newsequence::create
    ([]
    (x::yaml::newsequence &info)
    {
        std::list<x::yaml::newnode> list;

        list.push_back(x::yaml::newscalarnode::create("apple"));
        list.push_back(x::yaml::newscalarnode::create("fruit"));
        list.push_back(x::yaml::newscalarnode::create("banana"));
        info(list.begin(), list.end());
    });

x::yaml::newsequence::create() constructs a x::yaml::newnode that writes a sequence in a YAML document.

create() takes a lambda or a functor for a parameter, which gets called to define the sequence. The lambda functor takes one parameter, an instance of x::yaml::newsequence that's passed by reference, with the following members:

anchor

An optional anchor for an alias reference to this node.

tag

An optional YAML tag handle for this sequence node. This handle must be included in the x::yaml::newdocumentnode's tags map.

style

One of YAML_ANY_MAPPING_STYLE (default), YAML_BLOCK_MAPPING_STYLE, or YAML_FLOW_MAPPING_STYLE.

implicit

Defaulting to true this specifies that this node's YAML tag is optional.

The lambda/functor can modify these members from their default values before invoking the object's () operator, which takes two parameters, a beginning and an ending iterator. The above example creates a temporary list of x::yaml::newnodes but the iterators can be of any type that define an input sequence over x::yaml::newnodes or x::yaml::const_newnode; this sequence defines the YAML sequence that gets written to the new document.