mirror of
https://github.com/mbierlee/mirage-config.git
synced 2024-11-15 04:44:01 +01:00
Add basic config dictionary
This commit is contained in:
parent
525e82410f
commit
5ab78d08d6
54
source/poodinis/config/dictionary.d
Normal file
54
source/poodinis/config/dictionary.d
Normal file
|
@ -0,0 +1,54 @@
|
|||
module poodinis.config.dictionary;
|
||||
|
||||
interface ConfigNode {
|
||||
}
|
||||
|
||||
class NodeValue : ConfigNode {
|
||||
string value;
|
||||
|
||||
this() {
|
||||
}
|
||||
|
||||
this(string value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
class NodeObject : ConfigNode {
|
||||
ConfigNode[string] children;
|
||||
|
||||
this() {
|
||||
}
|
||||
|
||||
this(ConfigNode[string] children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
|
||||
class NodeArray : ConfigNode {
|
||||
ConfigNode[] children;
|
||||
|
||||
this() {
|
||||
}
|
||||
|
||||
this(ConfigNode[] children...) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
|
||||
class ConfigDictionary {
|
||||
ConfigNode rootNode;
|
||||
}
|
||||
|
||||
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 dictionary = new ConfigDictionary();
|
||||
dictionary.rootNode = root;
|
||||
}
|
||||
}
|
|
@ -8,3 +8,5 @@
|
|||
*/
|
||||
|
||||
module poodinis.config;
|
||||
|
||||
public import poodinis.config.dictionary;
|
||||
|
|
Loading…
Reference in a new issue