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:
parent
fb67e775e4
commit
13ea5f0c24
33 changed files with 236 additions and 215 deletions
|
@ -341,7 +341,7 @@ TestClass constructClass(Mark start, Mark end, ref Node node)
|
|||
{
|
||||
try
|
||||
{
|
||||
return new TestClass(node["x"].get!int, node["y"].get!int, node["z"].get!int);
|
||||
return new TestClass(node["x"].as!int, node["y"].as!int, node["z"].as!int);
|
||||
}
|
||||
catch(NodeException e)
|
||||
{
|
||||
|
@ -352,7 +352,7 @@ TestClass constructClass(Mark start, Mark end, ref Node node)
|
|||
|
||||
Node representClass(ref Node node, Representer representer)
|
||||
{
|
||||
auto value = node.get!TestClass;
|
||||
auto value = node.as!TestClass;
|
||||
auto pairs = [Node.Pair("x", value.x),
|
||||
Node.Pair("y", value.y),
|
||||
Node.Pair("z", value.z)];
|
||||
|
@ -364,14 +364,14 @@ Node representClass(ref Node node, Representer representer)
|
|||
///Constructor function for TestStruct.
|
||||
TestStruct constructStruct(Mark start, Mark end, ref Node node)
|
||||
{
|
||||
return TestStruct(to!int(node.get!string));
|
||||
return TestStruct(to!int(node.as!string));
|
||||
}
|
||||
|
||||
///Representer function for TestStruct.
|
||||
Node representStruct(ref Node node, Representer representer)
|
||||
{
|
||||
string[] keys, values;
|
||||
auto value = node.get!TestStruct;
|
||||
auto value = node.as!TestStruct;
|
||||
return representer.representScalar("!tag2", to!string(value.value));
|
||||
}
|
||||
|
||||
|
|
|
@ -58,13 +58,13 @@ void testUnicodeInput(bool verbose, string unicodeFilename)
|
|||
string expected = data.split().join(" ");
|
||||
|
||||
Node output = Loader(new MemoryStream(to!(char[])(data))).load();
|
||||
assert(output.get!string == expected);
|
||||
assert(output.as!string == expected);
|
||||
|
||||
foreach(stream; [new MemoryStream(cast(byte[])(bom16() ~ to!(wchar[])(data))),
|
||||
new MemoryStream(cast(byte[])(bom32() ~ to!(dchar[])(data)))])
|
||||
{
|
||||
output = Loader(stream).load();
|
||||
assert(output.get!string == expected);
|
||||
assert(output.as!string == expected);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue