diff options
author | Your Name <you@example.com> | 2020-11-05 15:50:11 -0500 |
---|---|---|
committer | Your Name <you@example.com> | 2020-11-05 15:50:11 -0500 |
commit | 2fe897e2cf750339a7e466aeafe64f45fb650f10 (patch) | |
tree | d27bbda7c1ef5368a90704843deea014e6c810de /settings.cc | |
download | libbible-2fe897e2cf750339a7e466aeafe64f45fb650f10.tar.gz libbible-2fe897e2cf750339a7e466aeafe64f45fb650f10.tar.bz2 libbible-2fe897e2cf750339a7e466aeafe64f45fb650f10.zip |
Initial commit
Diffstat (limited to 'settings.cc')
-rw-r--r-- | settings.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/settings.cc b/settings.cc new file mode 100644 index 0000000..848e22f --- /dev/null +++ b/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()); +} |