aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/ao_read_config_files.d
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2016-06-25 06:37:22 -0400
committerRalph Amissah <ralph@amissah.com>2019-04-04 14:48:18 -0400
commitf0c845eba3718fd0c732aebf25eb33e689798e03 (patch)
treec2ea36e199950647b1d3cce153691bb8f4fec378 /src/sdp/ao_read_config_files.d
parentstep5.1 headers sdlang (like native headers) converted to json for common int... (diff)
step6 headers (&config), native & sdlang to json internally
Diffstat (limited to 'src/sdp/ao_read_config_files.d')
-rw-r--r--src/sdp/ao_read_config_files.d56
1 files changed, 52 insertions, 4 deletions
diff --git a/src/sdp/ao_read_config_files.d b/src/sdp/ao_read_config_files.d
index 47980da..e53c656 100644
--- a/src/sdp/ao_read_config_files.d
+++ b/src/sdp/ao_read_config_files.d
@@ -2,7 +2,7 @@
ao_config_files.d
- read config files
+/
-template SiSUconfiguration() {
+template SiSUconfigIn() {
private import
std.exception,
// std.regex,
@@ -14,9 +14,9 @@ template SiSUconfiguration() {
// mixin RgxInit;
// auto rgx = Rgx();
private
- struct Config {
+ struct ConfigIn {
private import std.file;
- final private string readInConfigFile() {
+ final private string readInConfigFile(string conf_sdl) {
// enforce(
// exists(fn_src)!=0,
// "file not found"
@@ -27,7 +27,6 @@ template SiSUconfiguration() {
environment["HOME"] ~ "/.sisu",
"/etc/sisu"
];
- string conf_sdl = "conf.sdl";
string config_file_str;
foreach(pth; possible_config_path_locations) {
auto conf_file = format(
@@ -69,3 +68,52 @@ template SiSUconfiguration() {
}
}
}
+/+
+
++/
+template SiSUconfigSDLang() {
+ struct ConfigSDLangRootTag {
+ private auto configSDLangRootTag(string configuration, string conf_sdl_filename) {
+ Tag sdl_root_conf;
+ try {
+ sdl_root_conf = parseSource(configuration);
+ }
+ catch(SDLangParseException e) {
+ stderr.writeln("SDLang problem with content for ", conf_sdl_filename);
+ // Error messages of the form:
+ // myFile.sdl(5:28): Error: Invalid integer suffix.
+ stderr.writeln(e.msg);
+ }
+ debug(sdlang) {
+ // Value is a std.variant.Algebraic
+ Value output_dir_structure_by = sdl_root_conf.tags["output_dir_structure_by"][0].values[0];
+ assert(output_dir_structure_by.type == typeid(string));
+ writeln(output_dir_structure_by);
+ // Tag person = sdl_root_conf.namespaces["myNamespace"].tags["person"][0];
+ // writeln("Name: ", person.attributes["name"][0].value);
+ //
+ // int age = person.tags["age"][0].values[0].get!int();
+ // writeln("Age: ", age);
+ writeln("conf SDL:");
+ writeln(sdl_root_conf.toSDLDocument());
+ }
+ return sdl_root_conf;
+ }
+ }
+}
+/+
+
++/
+template SiSUconfigSDLangHub() {
+ mixin SiSUconfigIn;
+ mixin SiSUconfigSDLang;
+ struct ConfigHub {
+ final private auto configSDLang(string conf_sdl) {
+ auto conf_get = ConfigIn();
+ auto configuration = conf_get.readInConfigFile(conf_sdl);
+ auto conf = ConfigSDLangRootTag();
+ auto sdl_root = conf.configSDLangRootTag(configuration, conf_sdl);
+ return sdl_root;
+ }
+ }
+}