Representer.representSequence

Represent a _sequence with specified _tag, representing children first.

This is used by representer functions that produce sequences.

class Representer
representSequence
@trusted

Parameters

sequence
Type: Node[]

Sequence of nodes.

style

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

1 struct MyStruct
2 {
3    int x, y, z;
4 
5    //Any D:YAML type must have a custom opCmp operator.
6    //This is used for ordering in mappings.
7    const int opCmp(ref const MyStruct s)
8    {
9        if(x != s.x){return x - s.x;}
10        if(y != s.y){return y - s.y;}
11        if(z != s.z){return z - s.z;}
12        return 0;
13    }        
14 }
15 
16 Node representMyStruct(ref Node node, Representer representer)
17 { 
18    auto value = node.as!MyStruct;
19    auto nodes = [Node(value.x), Node(value.y), Node(value.z)];
20    //use flow style
21    return representer.representSequence("!mystruct.tag", nodes,
22                                         CollectionStyle.Flow);
23 }

Meta