blob: e3ef68fe220b648266e5fa5b85c44c51e456e78d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include "config.h"
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <iostream>
namespace pt = boost::property_tree;
namespace {
const std::string default_datapath {"/var/lib/whiteboard"};
const std::string config_filename{"/etc/webserver.conf"};
}
Config::Config(): m_dataPath{default_datapath}
{
try {
pt::ptree tree;
pt::read_xml(config_filename, tree, pt::xml_parser::no_comments | pt::xml_parser::trim_whitespace);
m_dataPath = tree.get<std::string>("config.datapath", default_datapath);
} catch (const std::exception& ex) {
std::cerr << "Error reading config file " << config_filename << ". Using " << default_datapath << "." << std::endl;
}
}
std::string Config::getDataPath()
{
return m_dataPath;
}
|