summaryrefslogtreecommitdiffstats
path: root/lib/Utils/Settings.cpp
diff options
context:
space:
mode:
authorZdenek Prikryl <zdeny@dhcp-lab-218.englab.brq.redhat.com>2009-02-05 11:17:38 +0100
committerZdenek Prikryl <zdeny@dhcp-lab-218.englab.brq.redhat.com>2009-02-05 11:17:38 +0100
commit73a7417887cb9a78b3c85d63f7c7d5040b3a8daf (patch)
tree77caa531c33eaf6a8193761e41d407e3035fe495 /lib/Utils/Settings.cpp
parentccac2e863c0be13969ec48805130e680050a6f0a (diff)
downloadabrt-73a7417887cb9a78b3c85d63f7c7d5040b3a8daf.tar.gz
abrt-73a7417887cb9a78b3c85d63f7c7d5040b3a8daf.tar.xz
abrt-73a7417887cb9a78b3c85d63f7c7d5040b3a8daf.zip
Create new Utils library (it uses old DebugDump and adds more functionality)
Diffstat (limited to 'lib/Utils/Settings.cpp')
-rw-r--r--lib/Utils/Settings.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/lib/Utils/Settings.cpp b/lib/Utils/Settings.cpp
new file mode 100644
index 00000000..866adc57
--- /dev/null
+++ b/lib/Utils/Settings.cpp
@@ -0,0 +1,64 @@
+
+#include "Settings.h"
+#include <fstream>
+
+
+void load_settings(const std::string& path, map_settings_t& settings)
+{
+ std::ifstream fIn;
+ fIn.open(path.c_str());
+ if (fIn.is_open())
+ {
+ std::string line;
+ while (!fIn.eof())
+ {
+ getline(fIn, line);
+
+ int ii;
+ bool is_value = false;
+ bool valid = false;
+ std::string key = "";
+ std::string value = "";
+ for (ii = 0; ii < line.length(); ii++)
+ {
+ if (isspace(line[ii]))
+ {
+ continue;
+ }
+ if (line[ii] == '#')
+ {
+ break;
+ }
+ else if (line[ii] == '=')
+ {
+ is_value = true;
+ }
+ else if (line[ii] == '=' && is_value)
+ {
+ key = "";
+ value = "";
+ break;
+ }
+ else if (!is_value)
+ {
+ key += line[ii];
+ }
+ else
+ {
+ valid = true;
+ value += line[ii];
+ }
+ }
+ if (valid)
+ {
+ settings[key] = value;
+ }
+ }
+ fIn.close();
+ }
+}
+
+void save_settings(const std::string& path, const map_settings_t& settings)
+{
+ //TODO: write this
+}