diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2021-03-03 10:51:41 -0500 | 
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2021-03-23 14:17:10 -0400 | 
| commit | e897eee6d6157314ef3396a4afca3c331eee9fe1 (patch) | |
| tree | 2ec9d0e8b06086962651de34675c8bcaa78f7418 /src/ext_depends/D-YAML/examples/constructor/main.d | |
| parent | ext depends meta info: ver hash, license (diff) | |
make set_depends run dub describe, track json output
- traded $PWD for project root as ./, i.e. from dub describe json
- dub describe deletes parts of dependencies that are unreferenced by
  the project build; these are available elsewhere and there is little
  reason to keep them
Diffstat (limited to 'src/ext_depends/D-YAML/examples/constructor/main.d')
| -rw-r--r-- | src/ext_depends/D-YAML/examples/constructor/main.d | 91 | 
1 files changed, 0 insertions, 91 deletions
diff --git a/src/ext_depends/D-YAML/examples/constructor/main.d b/src/ext_depends/D-YAML/examples/constructor/main.d deleted file mode 100644 index 50826f1..0000000 --- a/src/ext_depends/D-YAML/examples/constructor/main.d +++ /dev/null @@ -1,91 +0,0 @@ -import std.stdio; -import std.string; -import dyaml; - -struct Color -{ -   ubyte red; -   ubyte green; -   ubyte blue; - -   this(ubyte r, ubyte g, ubyte b) @safe -   { -        red = r; -        green = g; -        blue = b; -   } - -   this(const Node node, string tag) @safe -   { -        if (tag == "!color-mapping") -        { -            //Will throw if a value is missing, is not an integer, or is out of range. -            red = node["r"].as!ubyte; -            green = node["g"].as!ubyte; -            blue = node["b"].as!ubyte; -        } -        else -        { -            string value = node.as!string; - -            if(value.length != 6) -            { -                throw new Exception("Invalid color: " ~ value); -            } -            //We don't need to check for uppercase chars this way. -            value = value.toLower(); - -            //Get value of a hex digit. -            uint hex(char c) -            { -                import std.ascii; -                if(!std.ascii.isHexDigit(c)) -                { -                    throw new Exception("Invalid color: " ~ value); -                } - -                if(std.ascii.isDigit(c)) -                { -                    return c - '0'; -                } -                return c - 'a' + 10; -            } - -            red   = cast(ubyte)(16 * hex(value[0]) + hex(value[1])); -            green = cast(ubyte)(16 * hex(value[2]) + hex(value[3])); -            blue  = cast(ubyte)(16 * hex(value[4]) + hex(value[5])); -        } -   } -} - -void main(string[] args) -{ -   auto red = Color(255, 0, 0); -   auto orange = Color(255, 255, 0); - -   string path = "input.yaml"; -   if (args.length > 1) -   { -        path = args[1]; -   } - -   try -   { -       auto root = Loader.fromFile(path).load(); - -       if(root["scalar-red"].as!Color     == red && -          root["mapping-red"].as!Color    == red && -          root["scalar-orange"].as!Color  == orange && -          root["mapping-orange"].as!Color == orange) -       { -           writeln("SUCCESS"); -           return; -       } -   } -   catch(YAMLException e) -   { -       writeln(e.msg); -   } - -   writeln("FAILURE"); -}  | 
