25 #ifndef NFD_CORE_CONFIG_FILE_HPP 26 #define NFD_CORE_CONFIG_FILE_HPP 30 #include <boost/property_tree/ptree.hpp> 37 typedef function<void(
const ConfigSection& ,
42 typedef function<void(
const std::string& ,
44 const ConfigSection& ,
51 class Error :
public std::runtime_error
56 :
std::runtime_error(what)
66 const std::string& sectionName,
67 const ConfigSection& section,
72 const std::string& sectionName,
73 const ConfigSection& section,
79 ConfigSectionHandler subscriber);
89 parse(
const std::string& filename,
bool isDryRun);
99 parse(
const std::string& input,
bool isDryRun,
const std::string& filename);
108 parse(std::istream& input,
bool isDryRun,
const std::string& filename);
117 parse(
const ConfigSection& config,
bool isDryRun,
const std::string& filename);
122 process(
bool isDryRun,
const std::string& filename);
125 UnknownConfigSectionHandler m_unknownSectionCallback;
127 typedef std::map<std::string, ConfigSectionHandler> SubscriptionTable;
129 SubscriptionTable m_subscriptions;
131 ConfigSection m_global;
137 #endif // NFD_CORE_CONFIG_FILE_HPP
function< void(const ConfigSection &, bool, const std::string &)> ConfigSectionHandler
callback for config file sections
Error(const std::string &what)
static void throwErrorOnUnknownSection(const std::string &filename, const std::string §ionName, const ConfigSection §ion, bool isDryRun)
Copyright (c) 2011-2015 Regents of the University of California.
void addSectionHandler(const std::string §ionName, ConfigSectionHandler subscriber)
setup notification of configuration file sections
function< void(const std::string &, const std::string &, const ConfigSection &, bool)> UnknownConfigSectionHandler
callback for config file sections without a subscribed handler
boost::property_tree::ptree ConfigSection
ConfigFile(UnknownConfigSectionHandler unknownSectionCallback=throwErrorOnUnknownSection)
static void ignoreUnknownSection(const std::string &filename, const std::string §ionName, const ConfigSection §ion, bool isDryRun)
void parse(const std::string &filename, bool isDryRun)