update examples so they can compile again, and make them visible to dub
This commit is contained in:
parent
b44f96bd9f
commit
4680e1b5b2
11
dub.json
11
dub.json
|
@ -7,5 +7,14 @@
|
|||
"license": "Boost 1.0",
|
||||
"dependencies": { "tinyendian" : { "version" : "~>0.1.0" } },
|
||||
"homepage": "https://github.com/dlang-community/D-YAML",
|
||||
"copyright": "Copyright © 2011-2014, Ferdinand Majerech"
|
||||
"copyright": "Copyright © 2011-2014, Ferdinand Majerech",
|
||||
"subPackages": [
|
||||
"examples/constructor",
|
||||
"examples/getting_started",
|
||||
"examples/representer",
|
||||
"examples/resolver",
|
||||
"examples/yaml_bench",
|
||||
"examples/yaml_gen",
|
||||
"examples/yaml_stats"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
"mainSourceFile": "main.d",
|
||||
"dependencies":
|
||||
{
|
||||
"dyaml": { "version" : "~>0.5.0"},
|
||||
},
|
||||
"dyaml": { "version" : "*"}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import std.stdio;
|
||||
import std.string;
|
||||
import dyaml.all;
|
||||
import dyaml;
|
||||
|
||||
struct Color
|
||||
{
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
"mainSourceFile": "main.d",
|
||||
"dependencies":
|
||||
{
|
||||
"dyaml": { "version" : "~>0.5.0" },
|
||||
},
|
||||
"dyaml": { "version" : "*" }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import std.stdio;
|
||||
import dyaml.all;
|
||||
import dyaml;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
"mainSourceFile": "main.d",
|
||||
"dependencies":
|
||||
{
|
||||
"dyaml": { "version" : "~>0.5.0" },
|
||||
},
|
||||
"dyaml": { "version" : "*" }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import std.stdio;
|
||||
import dyaml.all;
|
||||
import dyaml;
|
||||
|
||||
struct Color
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ struct Color
|
|||
}
|
||||
}
|
||||
|
||||
Node representColor(ref Node node, Representer representer)
|
||||
Node representColor(ref Node node, Representer representer) @safe
|
||||
{
|
||||
//The node is guaranteed to be Color as we add representer for Color.
|
||||
Color color = node.as!Color;
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
"mainSourceFile": "main.d",
|
||||
"dependencies":
|
||||
{
|
||||
"dyaml": { "version" : "~>0.5.0" },
|
||||
},
|
||||
"dyaml": { "version" : "*" }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import std.stdio;
|
||||
import std.string;
|
||||
import dyaml.all;
|
||||
import dyaml;
|
||||
|
||||
struct Color
|
||||
{
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
{
|
||||
"name": "yaml_bench",
|
||||
"name": "benchmark",
|
||||
"targetType": "executable",
|
||||
"sourceFiles": ["yaml_bench.d"],
|
||||
"mainSourceFile": "yaml_bench.d",
|
||||
"dependencies":
|
||||
{
|
||||
"dyaml": { "version" : "~>0.5.0" },
|
||||
},
|
||||
"buildTypes":
|
||||
{
|
||||
"debug": { "buildOptions": ["debugMode", "debugInfoC"] },
|
||||
"release": { "buildOptions": ["releaseMode", "optimize", "inline", "noBoundsCheck"] },
|
||||
"profile": { "buildOptions": ["releaseMode", "optimize", "noBoundsCheck", "debugInfoC"] }
|
||||
"dyaml": { "version" : "*" }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,32 +1,32 @@
|
|||
|
||||
module dyaml.yaml_bench;
|
||||
//Benchmark that loads, and optionally extracts data from and/or emits a YAML file.
|
||||
//Benchmark that loads, and optionally extracts data from and/or emits a YAML file.
|
||||
|
||||
import std.conv;
|
||||
import std.datetime;
|
||||
import std.stdio;
|
||||
import std.string;
|
||||
import dyaml.all;
|
||||
import dyaml;
|
||||
|
||||
///Print help information.
|
||||
void help()
|
||||
{
|
||||
string help =
|
||||
"D:YAML benchmark\n"
|
||||
"Copyright (C) 2011-2014 Ferdinand Majerech\n"
|
||||
"Usage: yaml_bench [OPTION ...] [YAML_FILE]\n"
|
||||
"\n"
|
||||
"Loads and optionally extracts data and/or dumps a YAML file.\n"
|
||||
"\n"
|
||||
"Available options:\n"
|
||||
" -h --help Show this help information.\n"
|
||||
" -g --get Extract data from the file (using Node.as()).\n"
|
||||
" -d --dump Dump the loaded data (to YAML_FILE.dump).\n"
|
||||
" -r --runs=NUM Repeat parsing the file NUM times.\n"
|
||||
" --reload Reload the file from the diskl on every repeat\n"
|
||||
" By default, the file is loaded to memory once\n"
|
||||
" and repeatedly parsed from memory.\n"
|
||||
" -s --scan-only Do not execute the entire parsing process, only\n"
|
||||
"D:YAML benchmark\n"~
|
||||
"Copyright (C) 2011-2014 Ferdinand Majerech\n"~
|
||||
"Usage: yaml_bench [OPTION ...] [YAML_FILE]\n"~
|
||||
"\n"~
|
||||
"Loads and optionally extracts data and/or dumps a YAML file.\n"~
|
||||
"\n"~
|
||||
"Available options:\n"~
|
||||
" -h --help Show this help information.\n"~
|
||||
" -g --get Extract data from the file (using Node.as()).\n"~
|
||||
" -d --dump Dump the loaded data (to YAML_FILE.dump).\n"~
|
||||
" -r --runs=NUM Repeat parsing the file NUM times.\n"~
|
||||
" --reload Reload the file from the diskl on every repeat\n"~
|
||||
" By default, the file is loaded to memory once\n"~
|
||||
" and repeatedly parsed from memory.\n"~
|
||||
" -s --scan-only Do not execute the entire parsing process, only\n"~
|
||||
" scanning. Overrides '--dump'.\n";
|
||||
writeln(help);
|
||||
}
|
||||
|
@ -71,10 +71,10 @@ void main(string[] args)
|
|||
string file = null;
|
||||
|
||||
//Parse command line args
|
||||
foreach(arg; args[1 .. $])
|
||||
foreach(arg; args[1 .. $])
|
||||
{
|
||||
auto parts = arg.split("=");
|
||||
if(arg[0] == '-') switch(parts[0])
|
||||
if(arg[0] == '-') switch(parts[0])
|
||||
{
|
||||
case "--help", "-h": help(); return;
|
||||
case "--get", "-g": get = true; break;
|
||||
|
@ -88,8 +88,8 @@ void main(string[] args)
|
|||
{
|
||||
if(file !is null)
|
||||
{
|
||||
writeln("\nUnknown argument or file specified twice: ", arg, "\n\n");
|
||||
help();
|
||||
writeln("\nUnknown argument or file specified twice: ", arg, "\n\n");
|
||||
help();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -98,8 +98,8 @@ void main(string[] args)
|
|||
}
|
||||
if(file is null)
|
||||
{
|
||||
writeln("\nFile not specified.\n\n");
|
||||
help();
|
||||
writeln("\nFile not specified.\n\n");
|
||||
help();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
"mainSourceFile": "yaml_gen.d",
|
||||
"dependencies":
|
||||
{
|
||||
"dyaml": { "version" : "~>0.5.0" },
|
||||
},
|
||||
"dyaml": { "version" : "*" }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import std.math;
|
|||
import std.random;
|
||||
import std.stdio;
|
||||
import std.string;
|
||||
import dyaml.all;
|
||||
import dyaml;
|
||||
|
||||
|
||||
Node config;
|
||||
|
@ -220,7 +220,7 @@ Node pairs(bool root, bool complex, Node range, string tag)
|
|||
{
|
||||
auto key = generateNode(randomType(typesScalarKey ~ (complex ? typesCollection : [])));
|
||||
// Maps can't contain duplicate keys
|
||||
while(tag.endsWith("map") && keys[0 .. i].canFind(key))
|
||||
while(tag.endsWith("map") && keys[0 .. i].canFind(key))
|
||||
{
|
||||
key = generateNode(randomType(typesScalarKey ~ (complex ? typesCollection : [])));
|
||||
}
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
"mainSourceFile": "yaml_stats.d",
|
||||
"dependencies":
|
||||
{
|
||||
"dyaml": { "version" : "~>0.5.0" },
|
||||
},
|
||||
"dyaml": { "version" : "*" }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import std.stdio;
|
||||
import std.string;
|
||||
import dyaml.all;
|
||||
import dyaml;
|
||||
|
||||
|
||||
///Collects statistics about a YAML document and returns them as string.
|
||||
|
@ -66,8 +66,8 @@ string statistics(ref Node document)
|
|||
"\nMappings: %s" ~
|
||||
"\n\nAverage sequence length: %s" ~
|
||||
"\nAverage mapping length: %s" ~
|
||||
"\n\n%s",
|
||||
nodes, scalars, sequences, mappings,
|
||||
"\n\n%s",
|
||||
nodes, scalars, sequences, mappings,
|
||||
sequences == 0.0 ? 0.0 : cast(real)seqItems / sequences,
|
||||
mappings == 0.0 ? 0.0 : cast(real)mapPairs / mappings,
|
||||
tagStats);
|
||||
|
|
Loading…
Reference in a new issue