Added a shortcut alias called "as" for Node.get(), and replaced

get() with as() all over the code, tutorials, examples and docs.
Fixed a bug in YAML benchmark makefile.
Fixed a bug in autoddoc configuration.
This commit is contained in:
Ferdinand Majerech 2011-10-22 17:06:32 +02:00
parent fb67e775e4
commit 13ea5f0c24
33 changed files with 236 additions and 215 deletions

View file

@ -90,7 +90,7 @@ into the file:
{
writeln(word);
}
writeln("The answer is ", root["Answer"].get!int);
writeln("The answer is ", root["Answer"].as!int);
//Dump the loaded document to output.yaml.
Dumper("output.yaml").dump(root);
@ -115,7 +115,7 @@ possible.
mapping (associative array) or a scalar (value). Here the root node is a
mapping, and we use the index operator to get subnodes with keys "Hello World"
and "Answer". We iterate over the first, as it is a sequence, and use the
*Node.get()* method on the second to get its value as an integer.
*Node.as()* method on the second to read its value as an integer.
You can iterate over a mapping or sequence as if it was an associative or normal
array. If you try to iterate over a scalar, it will throw a *YAMLException*.
@ -128,9 +128,9 @@ not possible to convert to iterated type, a *YAMLException* is thrown. For
instance, if we specified *int* here, we would get an error, as "Hello"
cannot be converted to an integer.
The *Node.get()* method is used to get value of a scalar node, allowing to
specify type. D:YAML will try to return the scalar as this type, converting if
needed, throwing *YAMLException* if not possible.
The *Node.as()* method is used to read value of a scalar node as specified type.
D:YAML will try to return the scalar as this type, converting if needed,
throwing *YAMLException* if not possible.
Finally we dump the document we just read to ``output.yaml`` with the
*Dumper.dump()* method. *Dumper* is a struct used to dump YAML documents.