From 373f2fc1c308696c41fbe9a823c65733b4617a25 Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Sat, 24 Sep 2022 17:05:47 +0300 Subject: [PATCH] Define ConfigLoader interface And privatize internal classes --- source/mirage/config.d | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/source/mirage/config.d b/source/mirage/config.d index e379408..e7ef380 100644 --- a/source/mirage/config.d +++ b/source/mirage/config.d @@ -26,11 +26,11 @@ class PathParseException : Exception { } } -interface ConfigNode { +private interface ConfigNode { string nodeType(); } -class ValueNode : ConfigNode { +private class ValueNode : ConfigNode { string value; this() { @@ -45,7 +45,7 @@ class ValueNode : ConfigNode { } } -class ObjectNode : ConfigNode { +private class ObjectNode : ConfigNode { ConfigNode[string] children; this() { @@ -66,7 +66,7 @@ class ObjectNode : ConfigNode { } } -class ArrayNode : ConfigNode { +private class ArrayNode : ConfigNode { ConfigNode[] children; this() { @@ -87,10 +87,10 @@ class ArrayNode : ConfigNode { } } -interface PathSegment { +private interface PathSegment { } -class ArrayPathSegment : PathSegment { +private class ArrayPathSegment : PathSegment { const size_t index; this(const size_t index) { @@ -98,7 +98,7 @@ class ArrayPathSegment : PathSegment { } } -class PropertyPathSegment : PathSegment { +private class PropertyPathSegment : PathSegment { const string propertyName; this(const string propertyName) { @@ -106,7 +106,7 @@ class PropertyPathSegment : PathSegment { } } -class ConfigPath { +private class ConfigPath { private const string path; private string[] previousSegments; private string[] segments; @@ -261,6 +261,11 @@ class ConfigDictionary { } } +interface ConfigLoader { + ConfigDictionary parseConfig(string contents); + ConfigDictionary loadFile(string path); +} + version (unittest) { import std.exception : assertThrown;