aboutsummaryrefslogtreecommitdiff
path: root/src/lib/settings.cc
diff options
context:
space:
mode:
authorYour Name <you@example.com>2022-02-18 20:35:38 -0500
committerYour Name <you@example.com>2022-02-18 20:35:38 -0500
commit55d58a16e2511741cc625e203205dec86144faf3 (patch)
tree311be7e5fbaf1bc8ece47dd4261af053f2da1c7c /src/lib/settings.cc
parentaa9dabdeaead3c8b1b11f9d4f321265c439bfbfc (diff)
downloadlibbible-55d58a16e2511741cc625e203205dec86144faf3.tar.gz
libbible-55d58a16e2511741cc625e203205dec86144faf3.tar.bz2
libbible-55d58a16e2511741cc625e203205dec86144faf3.zip
Reorganized repository layout
Diffstat (limited to 'src/lib/settings.cc')
-rw-r--r--src/lib/settings.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lib/settings.cc b/src/lib/settings.cc
new file mode 100644
index 0000000..848e22f
--- /dev/null
+++ b/src/lib/settings.cc
@@ -0,0 +1,23 @@
+#include "libbible.h"
+#include <sword/swconfig.h>
+
+std::string path = (std::getenv("HOME")) + std::string("/.sword/libbible.conf");
+sword::SWConfig config(path.c_str());
+
+void libbible::settingsWrite(std::string key, std::string value) {
+ config["General"][key.c_str()] = sword::SWBuf(value.c_str());
+ config.save();
+}
+
+std::string libbible::settingsRead(std::string key) {
+ return config["General"][key.c_str()].c_str();
+}
+
+void libbible::settingsWriteInt(std::string key, int value) {
+ config["General"][key.c_str()] = sword::SWBuf(std::to_string(value).c_str());
+ config.save();
+}
+
+int libbible::settingsReadInt(std::string key) {
+ return atoi(config["General"][key.c_str()].c_str());
+}