Define ConfigLoader interface

And privatize internal classes
This commit is contained in:
Mike Bierlee 2022-09-24 17:05:47 +03:00
parent e293baf526
commit 373f2fc1c3

View file

@ -26,11 +26,11 @@ class PathParseException : Exception {
} }
} }
interface ConfigNode { private interface ConfigNode {
string nodeType(); string nodeType();
} }
class ValueNode : ConfigNode { private class ValueNode : ConfigNode {
string value; string value;
this() { this() {
@ -45,7 +45,7 @@ class ValueNode : ConfigNode {
} }
} }
class ObjectNode : ConfigNode { private class ObjectNode : ConfigNode {
ConfigNode[string] children; ConfigNode[string] children;
this() { this() {
@ -66,7 +66,7 @@ class ObjectNode : ConfigNode {
} }
} }
class ArrayNode : ConfigNode { private class ArrayNode : ConfigNode {
ConfigNode[] children; ConfigNode[] children;
this() { this() {
@ -87,10 +87,10 @@ class ArrayNode : ConfigNode {
} }
} }
interface PathSegment { private interface PathSegment {
} }
class ArrayPathSegment : PathSegment { private class ArrayPathSegment : PathSegment {
const size_t index; const size_t index;
this(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; const string propertyName;
this(const string propertyName) { this(const string propertyName) {
@ -106,7 +106,7 @@ class PropertyPathSegment : PathSegment {
} }
} }
class ConfigPath { private class ConfigPath {
private const string path; private const string path;
private string[] previousSegments; private string[] previousSegments;
private string[] segments; private string[] segments;
@ -261,6 +261,11 @@ class ConfigDictionary {
} }
} }
interface ConfigLoader {
ConfigDictionary parseConfig(string contents);
ConfigDictionary loadFile(string path);
}
version (unittest) { version (unittest) {
import std.exception : assertThrown; import std.exception : assertThrown;