summaryrefslogtreecommitdiff
path: root/lib/configuration.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/configuration.cc')
-rw-r--r--lib/configuration.cc79
1 files changed, 79 insertions, 0 deletions
diff --git a/lib/configuration.cc b/lib/configuration.cc
index dbc0dfd..64153d9 100644
--- a/lib/configuration.cc
+++ b/lib/configuration.cc
@@ -26,3 +26,82 @@
*/
#include "configuration.h"
+const char preload[] =
+"a = 42.0\n"
+"b = 42\n"
+"c = 42\n"
+"d = \"42\"\n";
+
+Configuration::Configuration(char *configfile)
+{
+ // Preload default values.
+ lua.loadBuffer((char*)preload);
+
+ // Load the conf file.
+ lua.loadFile(configfile);
+}
+
+Configuration::~Configuration()
+{
+}
+
+int Configuration::get(char *node, std::string *retval)
+{
+ try {
+ *retval = lua.getString(node);
+ } catch(...) {
+ return 1;
+ }
+ return 0;
+}
+
+int Configuration::get(char *node, std::vector<std::string> *retval)
+{/*
+ try {
+ *retval = lua.getString(node);
+ } catch(...) {
+ return 1;
+ }
+ return 0;
+ */
+ return 1;
+}
+
+int Configuration::get(char *node, double *retval)
+{
+ try {
+ *retval = lua.getReal(node);
+ } catch(...) {
+ return 1;
+ }
+ return 0;
+}
+
+int Configuration::get(char *node, int *retval)
+{
+ try {
+ *retval = lua.getInteger(node);
+ } catch(...) {
+ return 1;
+ }
+ return 0;
+}
+
+int Configuration::get(char *node, bool *retval)
+{
+ try {
+ *retval = lua.getBoolean(node);
+ } catch(...) {
+ return 1;
+ }
+ return 0;
+}
+
+Configuration *MIaV::config = NULL;
+
+void MIaV::initConfig(Configuration *config)
+{
+ MIaV::config = config;
+}
+
+