Representer.representSequence

Represent a _sequence with specified _tag, representing children first.

This is used by representer functions that produce sequences.

class Representer
@trusted
representSequence

Parameters

sequence Node[]

Sequence of nodes.

style CollectionStyle

Style of the _sequence. If invalid, default _style will be used. If the node was loaded before, previous _style will always be used.

Return Value

Type: Node

The represented node.

Throws

RepresenterException if a child could not be represented.

Examples

struct MyStruct
{
    int x, y, z;

    //Any D:YAML type must have a custom opCmp operator.
    //This is used for ordering in mappings.
    const int opCmp(ref const MyStruct s)
    {
        if(x != s.x){return x - s.x;}
        if(y != s.y){return y - s.y;}
        if(z != s.z){return z - s.z;}
        return 0;
    }        
}

Node representMyStruct(ref Node node, Representer representer)
{ 
    auto value = node.as!MyStruct;
    auto nodes = [Node(value.x), Node(value.y), Node(value.z)];
    //use flow style
    return representer.representSequence("!mystruct.tag", nodes,
                                         CollectionStyle.Flow);
}

Meta