summaryrefslogtreecommitdiff
path: root/lib/configuration.cc
diff options
context:
space:
mode:
authordeva <deva>2006-08-16 23:48:22 +0000
committerdeva <deva>2006-08-16 23:48:22 +0000
commit6c07f9219bed6ccddc9b65ad40414cf0a9f7d633 (patch)
tree95f5fe5db16808d7b13511a6344bc269692e6e17 /lib/configuration.cc
parentcca64725502c1035ca50675dda6c42dad18f0cbf (diff)
Finished the Configuration class (Still missing vector<string> though!)
Replaced the old MiavConfig class with the new Configuration class in all the the appropriate places.
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;
+}
+
+