28 #include <boost/property_tree/info_parser.hpp>
36 : m_unknownSectionCallback(unknownSectionCallback)
42 const std::string& sectionName,
46 NDN_THROW(
Error(
"Error processing configuration file " + filename +
47 ": no module subscribed for section '" + sectionName +
"'"));
52 const std::string& sectionName,
61 const std::string& sectionName)
63 auto value = node.get_value<std::string>();
68 else if (value ==
"no") {
73 key +
"' in section '" + sectionName +
"'"));
80 m_subscriptions[sectionName] = subscriber;
86 std::ifstream inputFile(filename);
87 if (!inputFile.good() || !inputFile.is_open()) {
90 parse(inputFile, isDryRun, filename);
97 std::istringstream inputStream(input);
98 parse(inputStream, isDryRun, filename);
105 boost::property_tree::read_info(input, m_global);
107 catch (
const boost::property_tree::info_parser_error& error) {
108 NDN_THROW(
Error(
"Failed to parse configuration file " + filename +
109 ": " + error.message() +
" on line " +
to_string(error.line())));
112 process(isDryRun, filename);
119 process(isDryRun, filename);
123 ConfigFile::process(
bool isDryRun,
const std::string& filename)
const
125 BOOST_ASSERT(!filename.empty());
127 for (
const auto& i : m_global) {
130 subscriber(i.second, isDryRun, filename);
132 catch (
const std::out_of_range&) {
133 m_unknownSectionCallback(filename, i.first, i.second, isDryRun);