diff options
Diffstat (limited to 'src/settings.cc')
-rw-r--r-- | src/settings.cc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/settings.cc b/src/settings.cc index d19acde..7004e1d 100644 --- a/src/settings.cc +++ b/src/settings.cc @@ -5,9 +5,9 @@ #include <stdexcept> namespace settings { - std::vector<std::string> getLabels() { + std::vector<std::string> readVector(std::string heading) { cfg_opt_t opts[] = { - CFG_STR_LIST("labels", NULL, CFGF_NONE), + CFG_STR_LIST(heading.c_str(), NULL, CFGF_NONE), CFG_END() }; cfg_t *cfg = cfg_init(opts, CFGF_IGNORE_UNKNOWN); @@ -17,12 +17,21 @@ namespace settings { try { std::vector<std::string> ret; std::size_t i; - for(i = 0; i < cfg_size(cfg, "labels"); i++) { - ret.push_back(cfg_getnstr(cfg, "labels", i)); + for(i = 0; i < cfg_size(cfg, heading.c_str()); i++) { + ret.push_back(cfg_getnstr(cfg, heading.c_str(), i)); } return ret; } catch(std::exception& e) { - throw std::runtime_error("Cannot find 'labels' in configuration file"); + throw std::runtime_error("Cannot find '" + heading + "' in configuration file"); } } + + std::vector<std::string> getLabels() { + return readVector("labels"); + } + + std::vector<std::string> getRectangleLabels() { + return readVector("rectangles"); + } } + |