Node.this

Construct a node from arrays of _keys and _values.

Constructs a mapping node with key-value pairs from _keys and _values, keeping their order. Useful when order is important (ordered maps, pairs).

More...
  1. this(T value, const string tag = null)
  2. this(T value, const string tag = null)
  3. this(T[] array, const string tag = null)
  4. this(V[K] array, const string tag = null)
  5. this(K[] keys, V[] values, const string tag = null)
    struct Node
    this
    @trusted
    (
    K
    V
    )
    (
    K[] keys
    ,
    V[] values
    ,
    const string tag = null
    )
    if (
    !(
    isSomeString!(K[]) ||
    isSomeString!(V[])
    )
    )
    in { assert (keys.length == values.length, "Lengths of keys and values arrays to construct " ~ "a YAML node from don't match"); }

Parameters

values
Type: V[]

Values of the mapping, from first to last pair.

tag
Type: string

Overrides tag of the node when emitted, regardless of tag determined by Representer. Representer uses this to determine YAML data type when a D data type maps to multiple different YAML data types. This is used to differentiate between YAML unordered mappings ("!!map"), ordered mappings ("!!omap"), and pairs ("!!pairs") which are all internally represented as an array of node pairs. Tag must be in full form, e.g. "tag:yaml.org,2002:omap", not a shortcut, like "!!omap".

Detailed Description

keys and values must have equal length.

If _keys and/or _values are nodes, they are stored directly/ Otherwise they are converted to nodes and then stored.

Examples

1 // Will be emitted as an unordered mapping (default for mappings)
2 auto map   = Node([1, 2], ["a", "b"]);
3 // Will be emitted as an ordered map (overriden tag)
4 auto omap  = Node([1, 2], ["a", "b"], "tag:yaml.org,2002:omap");
5 // Will be emitted as pairs (overriden tag)
6 auto pairs = Node([1, 2], ["a", "b"], "tag:yaml.org,2002:pairs");

Meta