Sketched out new config system.
authorethereal <ethereal@ethv.net>
Sun, 10 Nov 2013 07:11:29 +0000 (00:11 -0700)
committerethereal <ethereal@ethv.net>
Sun, 10 Nov 2013 07:11:29 +0000 (00:11 -0700)
14 files changed:
data/arguments.config [deleted file]
data/arguments.xml [new file with mode: 0644]
data/skeleton.config [deleted file]
newclass.pl
src/config/ArgvParser.cpp [new file with mode: 0644]
src/config/ArgvParser.h [new file with mode: 0644]
src/config/Node.cpp [new file with mode: 0644]
src/config/Node.h [new file with mode: 0644]
src/config/XMLParser.cpp [new file with mode: 0644]
src/config/XMLParser.h [new file with mode: 0644]
src/main.cpp
src/resource/File.h
src/resource/Registry.h
src/resource/XML.h

diff --git a/data/arguments.config b/data/arguments.config
deleted file mode 100644 (file)
index 25890b5..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-arguments: {
-
-long_form: {
-
-help: {
-    type: "boolean";
-    link: "runtime.help";
-    desc: "Displays a help/usage message";
-}
-
-}
-
-short_form: {
-h: "help";
-}
-
-}
-
-runtime: {
-
-help: false;
-
-}
diff --git a/data/arguments.xml b/data/arguments.xml
new file mode 100644 (file)
index 0000000..1c7648c
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" ?>
+
+<arguments>
+
+<argument type="toggle">
+    <long-form>help</long-form>
+    <short-form>h</short-form>
+
+    <absent>false</absent>
+    <present>true</present>
+
+    <config-node>runtime.help</config-node>
+</argument>
+
+<argument type="replace">
+    <long-form>log-level</long-form>
+
+    <default>0</default>
+    
+    <config-node>runtime.log-level</config-node>
+</argument>
+
+<argument type="replace">
+    <long-form>log-file</long-form>
+
+    <default>logs/%d.log</default>
+
+    <config-node>runtime.log-file</config-node>
+</argument>
+
+</arguments>
diff --git a/data/skeleton.config b/data/skeleton.config
deleted file mode 100644 (file)
index c61847f..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-log: {
-    filename: "logs/%d.log";
-}
index 883755d..882b04a 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # Perl script by DWK to create a new .cpp/.h combination template
 
-my $project = "Skeleton";
+my $project = 'Skeleton';
 
 if(scalar(@ARGV) < 1) {
     die "Usage: $0 <C++-name-of-class>\n" .
@@ -54,7 +54,7 @@ sub create_h_file {
     $guard =~ s/([^_])::([^:]+)$/$1_$2/;    # put two underscores at last ::
     $guard =~ s/([^_])::([^_])/$1_$2/g;
     $guard =~ s/:://g;
-    $guard = uc($guard) . "_H";
+    $guard = uc($project) . "_" . uc($guard) . "_H";
     
     my @namespaces = generate_namespaces($class);
     
diff --git a/src/config/ArgvParser.cpp b/src/config/ArgvParser.cpp
new file mode 100644 (file)
index 0000000..f433318
--- /dev/null
@@ -0,0 +1,7 @@
+#include "ArgvParser.h"
+
+namespace Skeleton {
+namespace Config {
+
+}  // namespace Config
+}  // namespace Skeleton
diff --git a/src/config/ArgvParser.h b/src/config/ArgvParser.h
new file mode 100644 (file)
index 0000000..89cd8fd
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef SKELETON_CONFIG__ARGV_PARSER_H
+#define SKELETON_CONFIG__ARGV_PARSER_H
+
+namespace Skeleton {
+namespace Config {
+
+class ArgvParser {
+public:
+};
+
+}  // namespace Config
+}  // namespace Skeleton
+
+#endif
diff --git a/src/config/Node.cpp b/src/config/Node.cpp
new file mode 100644 (file)
index 0000000..71f7541
--- /dev/null
@@ -0,0 +1,7 @@
+#include "Node.h"
+
+namespace Skeleton {
+namespace Config {
+
+}  // namespace Config
+}  // namespace Skeleton
diff --git a/src/config/Node.h b/src/config/Node.h
new file mode 100644 (file)
index 0000000..897ea63
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef SKELETON_CONFIG__NODE_H
+#define SKELETON_CONFIG__NODE_H
+
+namespace Skeleton {
+namespace Config {
+
+class Node {
+public:
+    
+};
+
+}  // namespace Config
+}  // namespace Skeleton
+
+#endif
diff --git a/src/config/XMLParser.cpp b/src/config/XMLParser.cpp
new file mode 100644 (file)
index 0000000..ee48637
--- /dev/null
@@ -0,0 +1,7 @@
+#include "XMLParser.h"
+
+namespace Skeleton {
+namespace Config {
+
+}  // namespace Config
+}  // namespace Skeleton
diff --git a/src/config/XMLParser.h b/src/config/XMLParser.h
new file mode 100644 (file)
index 0000000..e6fd9f6
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef SKELETON_CONFIG__XMLPARSER_H
+#define SKELETON_CONFIG__XMLPARSER_H
+
+namespace Skeleton {
+namespace Config {
+
+class XMLParser {
+public:
+};
+
+}  // namespace Config
+}  // namespace Skeleton
+
+#endif
index 7360b1d..abaf621 100644 (file)
@@ -8,7 +8,8 @@
 int main(int argc, char *argv[]) {
     using namespace Skeleton;
 
-    auto result = Resource::Registry::get<Resource::XML>("data/config.xml");
+    auto configXML = Resource::Registry::get<Resource::XML>("data/config.xml");
+    Resource::Registry::alias<Resource::XML>("data/config.xml", "config");
 
     return 0;
 }
index 0815290..39a53f7 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef RESOURCE__FILE_H
-#define RESOURCE__FILE_H
+#ifndef SKELETON_RESOURCE__FILE_H
+#define SKELETON_RESOURCE__FILE_H
 
 #include <string>
 #include <sstream>
index c56a2e8..b9ea824 100644 (file)
@@ -16,8 +16,7 @@ private:
     Registry() {}
 public:
     template<typename ResourceType>
-    static std::shared_ptr<ResourceType> alias(std::string existing,
-        std::string newname) {
+    static void alias(std::string existing, std::string newname) {
 
         auto &reg = ResourceType::s_registryElements;
 
index 0470708..65c32ad 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef RESOURCE__XML_H
-#define RESOURCE__XML_H
+#ifndef SKELETON_RESOURCE__XML_H
+#define SKELETON_RESOURCE__XML_H
 
 #include <pugixml.hpp>