summaryrefslogtreecommitdiffstats
path: root/src/ConfigReader/ConfigReader.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/ConfigReader/ConfigReader.h')
-rw-r--r--src/ConfigReader/ConfigReader.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/ConfigReader/ConfigReader.h b/src/ConfigReader/ConfigReader.h
new file mode 100644
index 0000000..2819f41
--- /dev/null
+++ b/src/ConfigReader/ConfigReader.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2016 Tobias Frust
+ *
+ * ConfigReader.h
+ *
+ * Created on: 18.04.2016
+ * Author: Tobias Frust (t.frust@hzdr.de)
+ */
+
+#ifndef CONFIGREADER_H
+#define CONFIGREADER_H
+#pragma once
+
+#include <boost/log/trivial.hpp>
+
+#include <libconfig.h++>
+
+#include <string>
+
+class ConfigReader {
+public:
+ ConfigReader(const char* configFile);
+ ConfigReader(const ConfigReader& configReader) {
+ }
+
+ template<typename T>
+ bool lookupValue(const std::string& identifier, T& value) {
+ bool ret = cfg.lookupValue(identifier.c_str(), value);
+ BOOST_LOG_TRIVIAL(debug) << "Configuration value " << identifier << ": " << value;
+ return ret;
+ }
+
+ template<typename T>
+ bool lookupValue(const std::string& identifier, int index, T& value) {
+ libconfig::Setting& s = cfg.lookup(identifier.c_str());
+ if(s.getLength() > index){
+ value = s[index];
+ BOOST_LOG_TRIVIAL(debug) << "Configuration value " << identifier << "[" << index << "]: " << value;
+ return true;
+ }
+ return false;
+ }
+
+private:
+ libconfig::Config cfg;
+};
+
+#endif