From cde58e1224a567f3d410e6d8a6e24c4584b610c0 Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Sat, 24 Sep 2022 01:15:16 +0300 Subject: [PATCH] Rename node objects --- source/poodinis/config/dictionary.d | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/source/poodinis/config/dictionary.d b/source/poodinis/config/dictionary.d index 2a076f0..ea0e86b 100644 --- a/source/poodinis/config/dictionary.d +++ b/source/poodinis/config/dictionary.d @@ -29,7 +29,7 @@ class PathParseException : Exception { interface ConfigNode { } -class NodeValue : ConfigNode { +class ValueNode : ConfigNode { string value; this() { @@ -40,7 +40,7 @@ class NodeValue : ConfigNode { } } -class NodeObject : ConfigNode { +class ObjectNode : ConfigNode { ConfigNode[string] children; this() { @@ -51,7 +51,7 @@ class NodeObject : ConfigNode { } } -class NodeArray : ConfigNode { +class ArrayNode : ConfigNode { ConfigNode[] children; this() { @@ -63,7 +63,7 @@ class NodeArray : ConfigNode { this(string[] values...) { foreach (string value; values) { - children ~= new NodeValue(value); + children ~= new ValueNode(value); } } } @@ -126,7 +126,7 @@ class ConfigDictionary { enforce!ConfigReadException(configPath.length > 0, "Supplied config path is empty"); if (configPath == ".") { - auto rootValue = cast(NodeValue) rootNode; + auto rootValue = cast(ValueNode) rootNode; if (rootValue) { return rootValue.value; } else { @@ -140,7 +140,7 @@ class ConfigDictionary { while (currentPathSegment !is null) { auto arrayPath = cast(ArrayPathSegment) currentPathSegment; if (arrayPath) { - auto arrayNode = cast(NodeArray) currentNode; + auto arrayNode = cast(ArrayNode) currentNode; if (arrayNode) { currentNode = arrayNode.children[arrayPath.index]; } @@ -149,7 +149,7 @@ class ConfigDictionary { currentPathSegment = path.getNextSegment(); } - auto value = cast(NodeValue) currentNode; + auto value = cast(ValueNode) currentNode; if (value) { return value.value; } else { @@ -164,9 +164,9 @@ version (unittest) { @("Dictionary creation") unittest { - auto root = new NodeObject([ - "english": new NodeArray([new NodeValue("one"), new NodeValue("two")]), - "spanish": new NodeArray(new NodeValue("uno"), new NodeValue("dos")) + auto root = new ObjectNode([ + "english": new ArrayNode([new ValueNode("one"), new ValueNode("two")]), + "spanish": new ArrayNode(new ValueNode("uno"), new ValueNode("dos")) ]); auto dictionary = new ConfigDictionary(); @@ -183,7 +183,7 @@ version (unittest) { @("Get value in dictionary with empty path fails") unittest { auto dictionary = new ConfigDictionary(); - dictionary.rootNode = new NodeValue("hehehe"); + dictionary.rootNode = new ValueNode("hehehe"); assertThrown!ConfigReadException(dictionary.get("")); } @@ -191,7 +191,7 @@ version (unittest) { @("Get value in root") unittest { auto dictionary = new ConfigDictionary(); - dictionary.rootNode = new NodeValue("yup"); + dictionary.rootNode = new ValueNode("yup"); assert(dictionary.get(".") == "yup"); } @@ -199,7 +199,7 @@ version (unittest) { @("Get value in root fails when root is not a value") unittest { auto dictionary = new ConfigDictionary(); - dictionary.rootNode = new NodeArray(); + dictionary.rootNode = new ArrayNode(); assertThrown!ConfigReadException(dictionary.get(".")); } @@ -207,7 +207,7 @@ version (unittest) { @("Get array value from root") unittest { auto dictionary = new ConfigDictionary(); - dictionary.rootNode = new NodeArray("aap", "noot", "mies"); + dictionary.rootNode = new ArrayNode("aap", "noot", "mies"); assert(dictionary.get("[0]") == "aap"); assert(dictionary.get("[1]") == "noot");