aboutsummaryrefslogtreecommitdiff
path: root/settings.cc
blob: 848e22fb66d90e336119ca70cfa4fb5be2712cb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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());
}