2011-08-16 12:53:13 +00:00
< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
< html lang = 'en' >
< head >
< meta http-equiv = "content-type" content = "text/html; charset=utf-8" >
2012-01-23 17:40:05 +00:00
< title > dyaml.node - D:YAML 0.4 API documentation< / title >
2011-08-16 12:53:13 +00:00
< link rel = "stylesheet" type = "text/css" href = "css/style.css" >
< / head >
< body > < div id = "top" >
< div id = "header" >
2012-01-23 17:40:05 +00:00
< img id = "logo" alt = "D:YAML logo" src = "images/logo.png" > < a id = "main-heading" href = "index.html" > D:YAML 0.4 API documentation< / a >
2011-08-16 12:53:13 +00:00
< / div >
< / div >
< div id = "navigation" >
< div class = "navblock" >
< div id = "toctop" >
< ul > < li > < a href = "../index.html" > Documentation home< / a > < / li >
< / ul >
< / div >
< / div >
< div class = "navblock" >
< ul > < li > < a href = "index.html" > Main page< / a > < / li >
< li > < a href = "dyaml.constructor.html" > dyaml.constructor< / a > < / li >
2011-10-14 08:34:53 +00:00
< li > < a href = "dyaml.dumper.html" > dyaml.dumper< / a > < / li >
< li > < a href = "dyaml.encoding.html" > dyaml.encoding< / a > < / li >
2011-08-16 12:53:13 +00:00
< li > < a href = "dyaml.exception.html" > dyaml.exception< / a > < / li >
2014-05-19 17:54:48 +00:00
< li > < a href = "dyaml.hacks.html" > dyaml.hacks< / a > < / li >
2011-10-14 08:34:53 +00:00
< li > < a href = "dyaml.linebreak.html" > dyaml.linebreak< / a > < / li >
2011-08-16 12:53:13 +00:00
< li > < a href = "dyaml.loader.html" > dyaml.loader< / a > < / li >
< li > < a href = "dyaml.node.html" > dyaml.node< / a > < / li >
2011-10-14 08:34:53 +00:00
< li > < a href = "dyaml.representer.html" > dyaml.representer< / a > < / li >
2011-08-16 12:53:13 +00:00
< li > < a href = "dyaml.resolver.html" > dyaml.resolver< / a > < / li >
2011-10-29 18:43:30 +00:00
< li > < a href = "dyaml.style.html" > dyaml.style< / a > < / li >
2011-08-16 12:53:13 +00:00
< / ul >
< / div >
< / div >
< div id = "content" >
< h1 > dyaml.node< / h1 >
<!-- Generated by Ddoc from dyaml/node.d -->
2011-10-14 08:34:53 +00:00
< p > Node of a YAML document. Used to read YAML data once it's loaded,
and to prepare data to emit.< / p >
2011-08-16 12:53:13 +00:00
2013-12-17 14:19:01 +00:00
< dl > < dt class = "d_decl" > < a name = "NodeException" > < / a > class < a name = "NodeException" > < / a > < span class = "ddoc_psymbol" > NodeException< / span > : dyaml.exception.YAMLException;
2011-08-16 12:53:13 +00:00
< / dt >
< dd > < p > Exception thrown at node related errors.< / p >
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "YAMLNull" > < / a > struct < a name = "YAMLNull" > < / a > < span class = "ddoc_psymbol" > YAMLNull< / span > ;
2011-08-16 12:53:13 +00:00
< / dt >
< dd > < p > Null YAML type. Used in nodes with null values.< / p >
2013-12-17 14:19:01 +00:00
< dl > < dt class = "d_decl" > < a name = "YAMLNull.toString" > < / a > const pure nothrow @safe string < a name = "toString" > < / a > < span class = "ddoc_psymbol" > toString< / span > ();
2011-10-30 17:12:02 +00:00
< / dt >
< dd > < p > Used for string conversion.< / p >
< / dd >
< / dl >
2011-08-16 12:53:13 +00:00
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node" > < / a > struct < a name = "Node" > < / a > < span class = "ddoc_psymbol" > Node< / span > ;
2011-08-16 12:53:13 +00:00
< / dt >
< dd > < p > YAML node.
< / p >
2011-10-14 08:34:53 +00:00
< p > This is a pseudo-dynamic type that can store any YAML value, including a
sequence or mapping of nodes. You can get data from a < a name = "Node" > < / a > < span class = "ddoc_psymbol" > Node< / span > directly or
iterate over it if it's a collection.< / p >
2011-08-16 12:53:13 +00:00
2013-12-17 14:19:01 +00:00
< dl > < dt class = "d_decl" > < a name = "Node.Pair" > < / a > struct < a name = "Pair" > < / a > < span class = "ddoc_psymbol" > Pair< / span > ;
2011-08-16 12:53:13 +00:00
< / dt >
2011-10-14 08:34:53 +00:00
< dd > < p > Key-value pair of YAML nodes, used in mappings.< / p >
2011-08-16 12:53:13 +00:00
2013-12-17 14:19:01 +00:00
< dl > < dt class = "d_decl" > < a name = "Node.Pair.key" > < / a > Node < a name = "key" > < / a > < span class = "ddoc_psymbol" > key< / span > ;
2011-08-16 12:53:13 +00:00
< / dt >
< dd > < p > Key node.< / p >
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.Pair.value" > < / a > Node < a name = "value" > < / a > < span class = "ddoc_psymbol" > value< / span > ;
2011-08-16 12:53:13 +00:00
< / dt >
< dd > < p > Value node.< / p >
2011-10-14 08:34:53 +00:00
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.Pair.this" > < / a > @safe this(K, V)(K < b > key< / b > , V < b > value< / b > );
2011-10-14 08:34:53 +00:00
< / dt >
< dd > < p > Construct a Pair from two values. Will be converted to Nodes if needed.< / p >
2011-08-16 12:53:13 +00:00
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.Pair.opEquals" > < / a > const @safe bool < a name = "opEquals" > < / a > < span class = "ddoc_psymbol" > opEquals< / span > (ref const Pair < b > rhs< / b > );
2011-08-16 12:53:13 +00:00
< / dt >
2011-10-14 08:34:53 +00:00
< dd > < p > Equality test with another Pair.< / p >
2011-08-16 12:53:13 +00:00
2013-12-17 14:19:01 +00:00
< / dd >
< dt class = "d_decl" > < a name = "Node.Pair.opAssign" > < / a > nothrow @safe void < a name = "opAssign" > < / a > < span class = "ddoc_psymbol" > opAssign< / span > (Pair < b > rhs< / b > );
< / dt >
< dd > < p > Assignment (shallow copy) by value.< / p >
< / dd >
< dt class = "d_decl" > < a name = "Node.Pair.opAssign" > < / a > nothrow @safe void < a name = "opAssign" > < / a > < span class = "ddoc_psymbol" > opAssign< / span > (ref Pair < b > rhs< / b > );
< / dt >
< dd > < p > Assignment (shallow copy) by reference.< / p >
2011-08-16 12:53:13 +00:00
< / dd >
< / dl >
2011-10-14 08:34:53 +00:00
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.this" > < / a > @trusted this(T)(T < b > value< / b > , const string < b > tag< / b > = null) if (isSomeString!T || !isArray!T & & !isAssociativeArray!T);
2011-10-14 08:34:53 +00:00
< / dt >
< dd > < p > Construct a Node from a value.
< / p >
2013-12-17 14:19:01 +00:00
< p > Any type except for Node can be stored in a Node, but default YAML
2011-10-14 08:34:53 +00:00
types (integers, floats, strings, timestamps, etc.) will be stored
2013-12-17 14:19:01 +00:00
more efficiently. To create a node representing a < b > null< / b > value,
construct it from YAMLNull.
2011-10-14 08:34:53 +00:00
< br >
< br >
Note that to emit any non-default types you store
in a node, you need a Representer to represent them in YAML -
otherwise emitting will fail.
< / p >
2013-12-17 14:19:01 +00:00
< b > Parameters:< / b > < div class = "pbr" > < table class = parms > < tr > < td valign = top > T value< / td >
2011-10-14 08:34:53 +00:00
< td valign = top > Value to store in the node.< / td > < / tr >
2013-12-17 14:19:01 +00:00
< tr > < td valign = top > string tag< / td >
2011-10-14 08:34:53 +00:00
< td valign = top > 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. Tag must
be in full form, e.g. "tag:yaml.org,2002:int", not
a shortcut, like "!!int".< / td > < / tr >
< / table > < / div >
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.this" > < / a > @safe this(T)(T[] < b > array< / b > , const string < b > tag< / b > = null) if (!isSomeString!(T[]));
2011-10-14 08:34:53 +00:00
< / dt >
< dd > < p > Construct a node from an array.
< / p >
< p > If array is an array of nodes or pairs, it is stored directly.
Otherwise, every value in the array is converted to a node, and
those nodes are stored.
< / p >
2013-12-17 14:19:01 +00:00
< b > Parameters:< / b > < div class = "pbr" > < table class = parms > < tr > < td valign = top > T[] array< / td >
2011-10-14 08:34:53 +00:00
< td valign = top > Values to store in the node.< / td > < / tr >
2013-12-17 14:19:01 +00:00
< tr > < td valign = top > string tag< / td >
2011-10-14 08:34:53 +00:00
< td valign = top > 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 sequences
("!!seq") and sets ("!!set"), which both are
internally represented as an array_ of nodes. Tag
must be in full form, e.g. "tag:yaml.org,2002:set",
not a shortcut, like "!!set".< / td > < / tr >
< / table > < / div >
2013-12-17 14:19:01 +00:00
< b > Examples:< / b > < div class = "pbr" > < pre class = "d_code" > < span class = "d_comment" > //Will be emitted as a sequence (default for arrays)
< / span > < span class = "d_keyword" > auto< / span > seq = Node([1, 2, 3, 4, 5]);
< span class = "d_comment" > //Will be emitted as a set (overriden tag)
< / span > < span class = "d_keyword" > auto< / span > set = Node([1, 2, 3, 4, 5], < span class = "d_string" > "tag:yaml.org,2002:set"< / span > );
2011-10-14 08:34:53 +00:00
< / pre >
< / div >
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.this" > < / a > @safe this(K, V)(V[K] < b > array< / b > , const string < b > tag< / b > = null);
2011-10-14 08:34:53 +00:00
< / dt >
< dd > < p > Construct a node from an associative array.
< / p >
< p > If keys and/or values of array are nodes, they stored directly.
Otherwise they are converted to nodes and then stored.
< / p >
2013-12-17 14:19:01 +00:00
< b > Parameters:< / b > < div class = "pbr" > < table class = parms > < tr > < td valign = top > V[K] array< / td >
2011-10-14 08:34:53 +00:00
< td valign = top > Values to store in the node.< / td > < / tr >
2013-12-17 14:19:01 +00:00
< tr > < td valign = top > string tag< / td >
2011-10-14 08:34:53 +00:00
< td valign = top > 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".< / td > < / tr >
< / table > < / div >
2013-12-17 14:19:01 +00:00
< b > Examples:< / b > < div class = "pbr" > < pre class = "d_code" > < span class = "d_comment" > //Will be emitted as an unordered mapping (default for mappings)
< / span > < span class = "d_keyword" > auto< / span > map = Node([1 : < span class = "d_string" > "a"< / span > , 2 : < span class = "d_string" > "b"< / span > ]);
< span class = "d_comment" > //Will be emitted as an ordered map (overriden tag)
< / span > < span class = "d_keyword" > auto< / span > omap = Node([1 : < span class = "d_string" > "a"< / span > , 2 : < span class = "d_string" > "b"< / span > ], < span class = "d_string" > "tag:yaml.org,2002:omap"< / span > );
< span class = "d_comment" > //Will be emitted as pairs (overriden tag)
< / span > < span class = "d_keyword" > auto< / span > pairs = Node([1 : < span class = "d_string" > "a"< / span > , 2 : < span class = "d_string" > "b"< / span > ], < span class = "d_string" > "tag:yaml.org,2002:pairs"< / span > );
2011-10-14 08:34:53 +00:00
< / pre >
< / div >
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.this" > < / a > @safe this(K, V)(K[] < b > keys< / b > , V[] < b > values< / b > , const string < b > tag< / b > = null) if (!(isSomeString!(K[]) || isSomeString!(V[])));
2011-10-14 08:34:53 +00:00
< / dt >
< dd > < p > Construct a node from arrays of keys and values.
< / p >
< p > Constructs a mapping node with key-value pairs from
keys and values, keeping their order. Useful when order
is important (ordered maps, pairs).
< br >
< br >
keys and values must have equal length.
< br >
< br >
If keys and/or values are nodes, they are stored directly/
Otherwise they are converted to nodes and then stored.
< / p >
2013-12-17 14:19:01 +00:00
< b > Parameters:< / b > < div class = "pbr" > < table class = parms > < tr > < td valign = top > K[] keys< / td >
2011-10-14 08:34:53 +00:00
< td valign = top > Keys of the mapping, from first to last pair.< / td > < / tr >
2013-12-17 14:19:01 +00:00
< tr > < td valign = top > V[] values< / td >
2011-10-14 08:34:53 +00:00
< td valign = top > Values of the mapping, from first to last pair.< / td > < / tr >
2013-12-17 14:19:01 +00:00
< tr > < td valign = top > string tag< / td >
2011-10-14 08:34:53 +00:00
< td valign = top > 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".< / td > < / tr >
< / table > < / div >
2013-12-17 14:19:01 +00:00
< b > Examples:< / b > < div class = "pbr" > < pre class = "d_code" > < span class = "d_comment" > //Will be emitted as an unordered mapping (default for mappings)
< / span > < span class = "d_keyword" > auto< / span > map = Node([1, 2], [< span class = "d_string" > "a"< / span > , < span class = "d_string" > "b"< / span > ]);
< span class = "d_comment" > //Will be emitted as an ordered map (overriden tag)
< / span > < span class = "d_keyword" > auto< / span > omap = Node([1, 2], [< span class = "d_string" > "a"< / span > , < span class = "d_string" > "b"< / span > ], < span class = "d_string" > "tag:yaml.org,2002:omap"< / span > );
< span class = "d_comment" > //Will be emitted as pairs (overriden tag)
< / span > < span class = "d_keyword" > auto< / span > pairs = Node([1, 2], [< span class = "d_string" > "a"< / span > , < span class = "d_string" > "b"< / span > ], < span class = "d_string" > "tag:yaml.org,2002:pairs"< / span > );
2011-10-14 08:34:53 +00:00
< / pre >
< / div >
2011-08-16 12:53:13 +00:00
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.isValid" > < / a > const pure nothrow @property @safe bool < a name = "isValid" > < / a > < span class = "ddoc_psymbol" > isValid< / span > ();
2011-08-16 12:53:13 +00:00
< / dt >
2014-05-19 17:54:48 +00:00
< dd > < p > Is this node valid (initialized)?< / p >
2011-08-16 12:53:13 +00:00
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.isScalar" > < / a > const nothrow @property @safe bool < a name = "isScalar" > < / a > < span class = "ddoc_psymbol" > isScalar< / span > ();
2011-08-16 12:53:13 +00:00
< / dt >
< dd > < p > Is this node a scalar value?< / p >
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.isSequence" > < / a > const nothrow @property @safe bool < a name = "isSequence" > < / a > < span class = "ddoc_psymbol" > isSequence< / span > ();
2011-08-16 12:53:13 +00:00
< / dt >
2011-10-14 08:34:53 +00:00
< dd > < p > Is this node a sequence?< / p >
2011-08-16 12:53:13 +00:00
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.isMapping" > < / a > const nothrow @property @safe bool < a name = "isMapping" > < / a > < span class = "ddoc_psymbol" > isMapping< / span > ();
2011-08-16 12:53:13 +00:00
< / dt >
2011-10-14 08:34:53 +00:00
< dd > < p > Is this node a mapping?< / p >
2011-08-16 12:53:13 +00:00
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.isUserType" > < / a > const nothrow @property @safe bool < a name = "isUserType" > < / a > < span class = "ddoc_psymbol" > isUserType< / span > ();
2011-08-16 12:53:13 +00:00
< / dt >
< dd > < p > Is this node a user defined type?< / p >
2011-10-22 15:06:32 +00:00
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.isNull" > < / a > const nothrow @property @safe bool < a name = "isNull" > < / a > < span class = "ddoc_psymbol" > isNull< / span > ();
< / dt >
< dd > < p > Is this node < b > null< / b > ?< / p >
< / dd >
< dt class = "d_decl" > < a name = "Node.tag" > < / a > const nothrow @property @safe string < a name = "tag" > < / a > < span class = "ddoc_psymbol" > tag< / span > ();
2011-10-22 15:06:32 +00:00
< / dt >
< dd > < p > Return < a name = "tag" > < / a > < span class = "ddoc_psymbol" > tag< / span > of the node.< / p >
2011-08-16 12:53:13 +00:00
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.opEquals" > < / a > const @safe bool < a name = "opEquals" > < / a > < span class = "ddoc_psymbol" > opEquals< / span > (T)(auto ref const T < b > rhs< / b > );
2011-08-16 12:53:13 +00:00
< / dt >
< dd > < p > Equality test.
< / p >
2011-10-14 08:34:53 +00:00
< p > If T is Node, recursively compare all subnodes.
This might be quite expensive if testing entire documents.
2011-08-16 12:53:13 +00:00
< br >
2013-12-17 14:19:01 +00:00
If T is not Node, get a value if type T from the node and test
equality with that.
< br >
To test equality with a < b > null< / b > YAML value, use YAMLNull.
2011-08-16 12:53:13 +00:00
< / p >
2013-12-17 14:19:01 +00:00
< b > Examples:< / b > < div class = "pbr" > < pre class = "d_code" > < span class = "d_keyword" > auto< / span > node = Node(42);
2011-10-14 08:34:53 +00:00
2013-12-17 14:19:01 +00:00
< span class = "d_keyword" > assert< / span > (node == 42);
< span class = "d_keyword" > assert< / span > (node != < span class = "d_string" > "42"< / span > );
< span class = "d_keyword" > assert< / span > (node != < span class = "d_string" > "43"< / span > );
2011-08-16 12:53:13 +00:00
< / pre >
< / div >
2013-12-17 14:19:01 +00:00
< b > Parameters:< / b > < div class = "pbr" > < table class = parms > < tr > < td valign = top > T rhs< / td >
2011-08-16 12:53:13 +00:00
< td valign = top > Variable to test equality with.< / td > < / tr >
< / table > < / div >
< b > Returns:< / b > < div class = "pbr" > < b > true< / b > if equal, < b > false< / b > otherwise.< / div >
2011-10-22 15:06:32 +00:00
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.as" > < / a > alias < a name = "as" > < / a > < span class = "ddoc_psymbol" > as< / span > = get(T, Flag stringConversion = Yes.stringConversion)() if (!is(T == const));
2011-10-22 15:06:32 +00:00
< / dt >
< dd > < p > Shortcut for get().< / p >
2011-08-16 12:53:13 +00:00
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.get" > < / a > @trusted T < a name = "get" > < / a > < span class = "ddoc_psymbol" > get< / span > (T, Flag!"stringConversion" stringConversion = Yes.stringConversion)() if (!is(T == const));
2011-08-16 12:53:13 +00:00
< / dt >
< dd > < p > Get the value of the node as specified type.
< / p >
< p > If the specifed type does not match type in the node,
2013-12-17 14:19:01 +00:00
conversion is attempted. The stringConversion template
parameter can be used to disable conversion from non-string
types to strings.
2011-08-16 12:53:13 +00:00
< br >
2011-10-17 11:13:02 +00:00
Numeric values are range checked, throwing if out of range of
requested type.
< br >
2011-08-16 12:53:13 +00:00
Timestamps are stored as std.datetime.SysTime.
Binary values are decoded and stored as ubyte[].
< br >
2013-12-17 14:19:01 +00:00
To < a name = "get" > < / a > < span class = "ddoc_psymbol" > get< / span > a < b > null< / b > value, use < a name = "get" > < / a > < span class = "ddoc_psymbol" > get< / span > !YAMLNull . This is to
prevent getting < b > null< / b > values for types such as strings or classes.
< br >
2011-08-16 12:53:13 +00:00
< br > < b > Mapping default values:< / b >
< br >
< div class = "pbr" > The '=' key can be used to denote the default value of a mapping.
This can be used when a node is scalar in early versions of a program,
but is replaced by a mapping later. Even if the node is a mapping, the
< a name = "get" > < / a > < span class = "ddoc_psymbol" > get< / span > method can be used as if it was a scalar if it has a default value.
This way, new YAML files where the node is a mapping can still be read
2011-10-14 08:34:53 +00:00
by old versions of the program, which expect the node to be a scalar.
2011-08-16 12:53:13 +00:00
< / div >
< / p >
< b > Examples:< / b > < div class = "pbr" > Automatic type conversion:
2013-12-17 14:19:01 +00:00
< pre class = "d_code" > < span class = "d_keyword" > auto< / span > node = Node(42);
2011-10-14 08:34:53 +00:00
2013-12-17 14:19:01 +00:00
< span class = "d_keyword" > assert< / span > (node.as!< span class = "d_keyword" > int< / span > == 42);
< span class = "d_keyword" > assert< / span > (node.as!string == < span class = "d_string" > "42"< / span > );
< span class = "d_keyword" > assert< / span > (node.as!< span class = "d_keyword" > double< / span > == 42.0);
2011-08-16 12:53:13 +00:00
< / pre >
< / div >
< b > Returns:< / b > < div class = "pbr" > Value of the node as specified type.
< / div >
2011-10-17 11:13:02 +00:00
< b > Throws:< / b > < div class = "pbr" > NodeException if unable to convert to specified type, or if
the value is out of range of requested type.< / div >
2011-08-16 12:53:13 +00:00
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.get" > < / a > const @trusted T < a name = "get" > < / a > < span class = "ddoc_psymbol" > get< / span > (T, Flag!"stringConversion" stringConversion = Yes.stringConversion)() if (is(T == const));
< / dt >
< dd > < p > Ditto.< / p >
< / dd >
< dt class = "d_decl" > < a name = "Node.length" > < / a > const @property @safe size_t < a name = "length" > < / a > < span class = "ddoc_psymbol" > length< / span > ();
2011-08-16 12:53:13 +00:00
< / dt >
2011-10-14 08:34:53 +00:00
< dd > < p > If this is a collection, return its length.
2011-08-16 12:53:13 +00:00
< / p >
< p > Otherwise, throw NodeException.
< / p >
< b > Returns:< / b > < div class = "pbr" > Number of elements in a sequence or key-value pairs in a mapping.
< / div >
< b > Throws:< / b > < div class = "pbr" > NodeException if this is not a sequence nor a mapping.< / div >
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.opIndex" > < / a > @trusted Node < a name = "opIndex" > < / a > < span class = "ddoc_psymbol" > opIndex< / span > (T)(T < b > index< / b > );
2011-08-16 12:53:13 +00:00
< / dt >
2011-10-14 08:34:53 +00:00
< dd > < p > Get the element at specified index.
2011-08-16 12:53:13 +00:00
< / p >
< p > If the node is a sequence, index must be integral.
2011-10-14 08:34:53 +00:00
< br >
2011-08-16 12:53:13 +00:00
< br >
If the node is a mapping, return the value corresponding to the first
2013-12-17 14:19:01 +00:00
key equal to index.
< br >
To get element at a < b > null< / b > index, use YAMLNull for index.
2011-08-16 12:53:13 +00:00
< / p >
2013-12-17 14:19:01 +00:00
< b > Parameters:< / b > < div class = "pbr" > < table class = parms > < tr > < td valign = top > T index< / td >
2011-08-16 12:53:13 +00:00
< td valign = top > Index to use.< / td > < / tr >
< / table > < / div >
< b > Returns:< / b > < div class = "pbr" > Value corresponding to the index.
< / div >
2011-10-14 08:34:53 +00:00
< b > Throws:< / b > < div class = "pbr" > NodeException if the index could not be found,
non-integral index is used with a sequence or the node is
not a collection.< / div >
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.contains" > < / a > const @safe bool < a name = "contains" > < / a > < span class = "ddoc_psymbol" > contains< / span > (T)(T < b > rhs< / b > );
< / dt >
< dd > < p > D etermine if a collection < a name = "contains" > < / a > < span class = "ddoc_psymbol" > contains< / span > specified value.
< / p >
< p > If the node is a sequence, check if it < a name = "contains" > < / a > < span class = "ddoc_psymbol" > contains< / span > the specified value.
If it's a mapping, check if it has a value that matches specified value.
< br >
To check for a < b > null< / b > value, use YAMLNull for rhs.
< / p >
< b > Parameters:< / b > < div class = "pbr" > < table class = parms > < tr > < td valign = top > T rhs< / td >
< td valign = top > Item to look for.< / td > < / tr >
< / table > < / div >
< b > Returns:< / b > < div class = "pbr" > < b > true< / b > if rhs was found, < b > false< / b > otherwise.
< / div >
< b > Throws:< / b > < div class = "pbr" > NodeException if the node is not a collection.< / div >
< / dd >
< dt class = "d_decl" > < a name = "Node.containsKey" > < / a > const @safe bool < a name = "containsKey" > < / a > < span class = "ddoc_psymbol" > containsKey< / span > (T)(T < b > rhs< / b > );
< / dt >
< dd > < p > Determine if a collection contains specified key.
< / p >
< p > If the node is a mapping, check if it has a key
that matches specified key.
< br >
To check for a < b > null< / b > key, use YAMLNull for rhs.
< / p >
< b > Parameters:< / b > < div class = "pbr" > < table class = parms > < tr > < td valign = top > T rhs< / td >
< td valign = top > Item to look for.< / td > < / tr >
< / table > < / div >
< b > Returns:< / b > < div class = "pbr" > < b > true< / b > if rhs was found, < b > false< / b > otherwise.
< / div >
< b > Throws:< / b > < div class = "pbr" > NodeException if the node is not a mapping.< / div >
< / dd >
< dt class = "d_decl" > < a name = "Node.opAssign" > < / a > nothrow @safe void < a name = "opAssign" > < / a > < span class = "ddoc_psymbol" > opAssign< / span > (Node < b > rhs< / b > );
< / dt >
< dd > < p > Assignment (shallow copy) by value.< / p >
< / dd >
< dt class = "d_decl" > < a name = "Node.opAssign" > < / a > nothrow @trusted void < a name = "opAssign" > < / a > < span class = "ddoc_psymbol" > opAssign< / span > (ref Node < b > rhs< / b > );
< / dt >
< dd > < p > Assignment (shallow copy) by reference.< / p >
< / dd >
< dt class = "d_decl" > < a name = "Node.opIndexAssign" > < / a > @safe void < a name = "opIndexAssign" > < / a > < span class = "ddoc_psymbol" > opIndexAssign< / span > (K, V)(V < b > value< / b > , K < b > index< / b > );
2011-10-14 08:34:53 +00:00
< / dt >
< dd > < p > Set element at specified index in a collection.
< / p >
< p > This method can only be called on collection nodes.
< br >
If the node is a sequence, index must be integral.
< br >
If the node is a mapping, sets the value corresponding to the first
key matching index (including conversion, so e.g. "42" matches 42).
< br >
If the node is a mapping and no key matches index, a new key-value
pair is added to the mapping. In sequences the index must be in
range. This ensures behavior siilar to D arrays and associative
arrays.
2013-12-17 14:19:01 +00:00
< br >
To set element at a < b > null< / b > index, use YAMLNull for index.
2011-10-14 08:34:53 +00:00
< / p >
2013-12-17 14:19:01 +00:00
< b > Parameters:< / b > < div class = "pbr" > < table class = parms > < tr > < td valign = top > K index< / td >
2011-10-14 08:34:53 +00:00
< td valign = top > Index of the value to set.< / td > < / tr >
< / table > < / div >
< b > Throws:< / b > < div class = "pbr" > NodeException if the node is not a collection, index is out
of range or if a non-integral index is used on a sequence node.< / div >
2011-08-16 12:53:13 +00:00
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.opApply" > < / a > @trusted int < a name = "opApply" > < / a > < span class = "ddoc_psymbol" > opApply< / span > (T)(int delegate(ref T) < b > dg< / b > );
2011-08-16 12:53:13 +00:00
< / dt >
2012-01-23 14:57:26 +00:00
< dd > < p > Foreach over a sequence, getting each element as T.
2011-08-16 12:53:13 +00:00
< / p >
< p > If T is Node, simply iterate over the nodes in the sequence.
Otherwise, convert each node to T during iteration.
< / p >
< b > Throws:< / b > < div class = "pbr" > NodeException if the node is not a sequence or an
element could not be converted to specified type.< / div >
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.opApply" > < / a > @trusted int < a name = "opApply" > < / a > < span class = "ddoc_psymbol" > opApply< / span > (K, V)(int delegate(ref K, ref V) < b > dg< / b > );
2011-08-16 12:53:13 +00:00
< / dt >
2012-01-23 14:57:26 +00:00
< dd > < p > Foreach over a mapping, getting each key/value as K/V.
2011-08-16 12:53:13 +00:00
< / p >
< p > If the K and/or V is Node, simply iterate over the nodes in the mapping.
Otherwise, convert each key/value to T during iteration.
< / p >
< b > Throws:< / b > < div class = "pbr" > NodeException if the node is not a mapping or an
element could not be converted to specified type.< / div >
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.add" > < / a > @safe void < a name = "add" > < / a > < span class = "ddoc_psymbol" > add< / span > (T)(T < b > value< / b > );
2011-08-16 12:53:13 +00:00
< / dt >
2011-10-14 08:34:53 +00:00
< dd > < p > Add an element to a sequence.
< / p >
< p > This method can only be called on sequence nodes.
< br >
If value is a node, it is copied to the sequence directly. Otherwise
value is converted to a node and then stored in the sequence.
< br >
< p > When emitting, all values in the sequence will be emitted. When
using the !!set tag, the user needs to ensure that all elements in
the sequence are unique, otherwise < b > invalid< / b > YAML code will be
emitted.< / p >
< / p >
2013-12-17 14:19:01 +00:00
< b > Parameters:< / b > < div class = "pbr" > < table class = parms > < tr > < td valign = top > T value< / td >
2011-10-14 08:34:53 +00:00
< td valign = top > Value to add to the sequence.< / td > < / tr >
< / table > < / div >
2011-08-16 12:53:13 +00:00
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.add" > < / a > @safe void < a name = "add" > < / a > < span class = "ddoc_psymbol" > add< / span > (K, V)(K < b > key< / b > , V < b > value< / b > );
2011-08-16 12:53:13 +00:00
< / dt >
2011-10-14 08:34:53 +00:00
< dd > < p > Add a key-value pair to a mapping.
< / p >
< p > This method can only be called on mapping nodes.
< br >
If key and/or value is a node, it is copied to the mapping directly.
Otherwise it is converted to a node and then stored in the mapping.
< br >
< p > It is possible for the same key to be present more than once in a
mapping. When emitting, all key-value pairs will be emitted.
This is useful with the "!!pairs" tag, but will result in
< b > invalid< / b > YAML with "!!map" and "!!omap" tags.< / p >
< / p >
2013-12-17 14:19:01 +00:00
< b > Parameters:< / b > < div class = "pbr" > < table class = parms > < tr > < td valign = top > K key< / td >
2011-10-14 08:34:53 +00:00
< td valign = top > Key to add.< / td > < / tr >
2013-12-17 14:19:01 +00:00
< tr > < td valign = top > V value< / td >
2011-10-14 08:34:53 +00:00
< td valign = top > Value to add.< / td > < / tr >
< / table > < / div >
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.opBinaryRight" > < / a > @trusted Node* < a name = "opBinaryRight" > < / a > < span class = "ddoc_psymbol" > opBinaryRight< / span > (string op, K)(K < b > key< / b > ) if (op == "in");
< / dt >
< dd > < p > Determine whether a key is in a mapping, and access its value.
< / p >
< p > This method can only be called on mapping nodes.
< / p >
< b > Parameters:< / b > < div class = "pbr" > < table class = parms > < tr > < td valign = top > K key< / td >
< td valign = top > Key to search for.< / td > < / tr >
< / table > < / div >
< b > Returns:< / b > < div class = "pbr" > A pointer to the value (as a Node) corresponding to key,
or < b > null< / b > if not found.
< / div >
< p > < b > Note:< / b > < br >
Any modification to the node can invalidate the returned
pointer.
< / p >
< b > See Also:< / b > < div class = "pbr" > contains< / div >
< / dd >
< dt class = "d_decl" > < a name = "Node.remove" > < / a > @trusted void < a name = "remove" > < / a > < span class = "ddoc_psymbol" > remove< / span > (T)(T < b > rhs< / b > );
2011-10-14 08:34:53 +00:00
< / dt >
< dd > < p > Remove first (if any) occurence of a value in a collection.
< / p >
< p > This method can only be called on collection nodes.
< br >
2013-12-17 14:19:01 +00:00
If the node is a sequence, the first node matching value is removed.
2011-10-14 08:34:53 +00:00
If the node is a mapping, the first key-value pair where value
matches specified value is removed.
< / p >
2013-12-17 14:19:01 +00:00
< b > Parameters:< / b > < div class = "pbr" > < table class = parms > < tr > < td valign = top > T rhs< / td >
2011-10-14 08:34:53 +00:00
< td valign = top > Value to remove.< / td > < / tr >
< / table > < / div >
< b > Throws:< / b > < div class = "pbr" > NodeException if the node is not a collection.< / div >
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.removeAt" > < / a > @trusted void < a name = "removeAt" > < / a > < span class = "ddoc_psymbol" > removeAt< / span > (T)(T < b > index< / b > );
2011-10-14 08:34:53 +00:00
< / dt >
< dd > < p > Remove element at the specified index of a collection.
< / p >
< p > This method can only be called on collection nodes.
< br >
If the node is a sequence, index must be integral.
< br >
If the node is a mapping, remove the first key-value pair where
2013-12-17 14:19:01 +00:00
key matches index.
2011-10-14 08:34:53 +00:00
< br >
If the node is a mapping and no key matches index, nothing is removed
and no exception is thrown. This ensures behavior siilar to D arrays
and associative arrays.
< / p >
2013-12-17 14:19:01 +00:00
< b > Parameters:< / b > < div class = "pbr" > < table class = parms > < tr > < td valign = top > T index< / td >
2011-10-14 08:34:53 +00:00
< td valign = top > Index to remove at.< / td > < / tr >
< / table > < / div >
< b > Throws:< / b > < div class = "pbr" > NodeException if the node is not a collection, index is out
of range or if a non-integral index is used on a sequence node.< / div >
2011-08-16 12:53:13 +00:00
2012-01-23 14:57:26 +00:00
< / dd >
2013-12-17 14:19:01 +00:00
< dt class = "d_decl" > < a name = "Node.opCmp" > < / a > const @safe int < a name = "opCmp" > < / a > < span class = "ddoc_psymbol" > opCmp< / span > (ref const Node < b > node< / b > );
2012-01-23 14:57:26 +00:00
< / dt >
< dd > < p > Compare with another node.< / p >
2011-08-16 12:53:13 +00:00
< / dd >
< / dl >
< / dd >
< / dl >
< / div >
< div id = "copyright" >
Copyright © Ferdinand Majerech 2011. Based on < a href = "http://www.pyyaml.org" > PyYAML< / a > by Kirill Simonov. |
2012-01-23 14:57:26 +00:00
Page generated by AutoDDoc and < a href = "http://www.digitalmars.com/d/2.0/ddoc.html" > Ddoc< / a > .
2011-08-16 12:53:13 +00:00
< / div >
< / body >
< / html >