#include "config.h" #include #include #include namespace pt = boost::property_tree; namespace { const std::string default_datapath {"/var/lib/whiteboard"}; const uint64_t default_maxage{0}; // timeout in seconds; 0 = no timeout } Config::Config(const std::string& config_filename): m_dataPath{default_datapath}, m_maxage{default_maxage} { try { pt::ptree tree; pt::read_xml(config_filename, tree, pt::xml_parser::no_comments | pt::xml_parser::trim_whitespace); m_dataPath = tree.get("config.datapath", default_datapath); m_maxage = tree.get("config.maxage", default_maxage); } catch (const std::exception& ex) { std::cerr << "Error reading config file " << config_filename << ". Using defaults." << std::endl; } } std::string Config::getDataPath() const { return m_dataPath; } uint64_t Config::getMaxage() const { return m_maxage; }