configuration file parsing utility More...
#include <config-file.hpp>
Classes | |
class | Error |
Public Member Functions | |
ConfigFile (UnknownConfigSectionHandler unknownSectionCallback=throwErrorOnUnknownSection) | |
void | addSectionHandler (const std::string §ionName, ConfigSectionHandler subscriber) |
setup notification of configuration file sections More... | |
void | parse (const std::string &filename, bool isDryRun) |
void | parse (const std::string &input, bool isDryRun, const std::string &filename) |
void | parse (std::istream &input, bool isDryRun, const std::string &filename) |
void | parse (const ConfigSection &config, bool isDryRun, const std::string &filename) |
Static Public Member Functions | |
static void | throwErrorOnUnknownSection (const std::string &filename, const std::string §ionName, const ConfigSection §ion, bool isDryRun) |
static void | ignoreUnknownSection (const std::string &filename, const std::string §ionName, const ConfigSection §ion, bool isDryRun) |
static bool | parseYesNo (const ConfigSection &node, const std::string &key, const std::string §ionName) |
parse a config option that can be either "yes" or "no" More... | |
static bool | parseYesNo (const ConfigSection::value_type &option, const std::string §ionName) |
template<typename T > | |
static T | parseNumber (const ConfigSection &node, const std::string &key, const std::string §ionName) |
parse a numeric (integral or floating point) config option More... | |
template<typename T > | |
static T | parseNumber (const ConfigSection::value_type &option, const std::string §ionName) |
template<typename T > | |
static void | checkRange (T value, T min, T max, const std::string &key, const std::string §ionName) |
check that a value is within the inclusive range [min, max] More... | |
configuration file parsing utility
Definition at line 57 of file config-file.hpp.
|
explicit |
Definition at line 35 of file config-file.cpp.
|
static |
Definition at line 41 of file config-file.cpp.
References NDN_THROW.
Referenced by nfd::ignoreRibAndLogSections(), and ns3::ndn::IgnoreSections::operator()().
|
static |
Definition at line 51 of file config-file.cpp.
Referenced by nfd::Nfd::initialize(), nfd::Nfd::reloadConfigFile(), and nfd::rib::Service::Service().
|
static |
parse a config option that can be either "yes" or "no"
true | "yes" |
false | "no" |
Error | the value is neither "yes" nor "no" |
Definition at line 60 of file config-file.cpp.
References NDN_THROW.
Referenced by nfd::face::EthernetFactory::EthernetFactory(), nfd::rib::Service::get(), nfd::face::TcpFactory::getId(), nfd::face::WebSocketFactory::getId(), parseYesNo(), nfd::face::FaceSystem::setConfigFile(), and nfd::face::UdpFactory::UdpFactory().
|
inlinestatic |
Definition at line 92 of file config-file.hpp.
References parseYesNo().
|
inlinestatic |
parse a numeric (integral or floating point) config option
T | an arithmetic type |
Error | the value cannot be converted to the specified type |
Definition at line 106 of file config-file.hpp.
References NDN_THROW.
|
inlinestatic |
Definition at line 122 of file config-file.hpp.
|
inlinestatic |
check that a value is within the inclusive range [min, max]
Error | the value is out of the acceptable range |
Definition at line 133 of file config-file.hpp.
References addSectionHandler(), NDN_THROW, parse(), and ndn::to_string().
Referenced by nfd::face::UdpFactory::UdpFactory().
void nfd::ConfigFile::addSectionHandler | ( | const std::string & | sectionName, |
ConfigSectionHandler | subscriber | ||
) |
setup notification of configuration file sections
Definition at line 77 of file config-file.cpp.
Referenced by checkRange(), nfd::rib::Service::Service(), nfd::log::setConfigFile(), nfd::CommandAuthenticator::setConfigFile(), nfd::general::setConfigFile(), nfd::TablesConfigSection::setConfigFile(), nfd::face::FaceSystem::setConfigFile(), and nfd::Forwarder::setConfigFile().
void nfd::ConfigFile::parse | ( | const std::string & | filename, |
bool | isDryRun | ||
) |
filename | file to parse |
isDryRun | true if performing a dry run of configuration, false otherwise |
ConfigFile::Error | if file not found |
ConfigFile::Error | if parse error |
Definition at line 84 of file config-file.cpp.
References NDN_THROW.
Referenced by checkRange(), nfd::Nfd::initialize(), parse(), nfd::Nfd::reloadConfigFile(), and ns3::ndn::L3Protocol::setCsReplacementPolicy().
void nfd::ConfigFile::parse | ( | const std::string & | input, |
bool | isDryRun, | ||
const std::string & | filename | ||
) |
input | configuration (as a string) to parse |
isDryRun | true if performing a dry run of configuration, false otherwise |
filename | logical filename of the config file, can appear in error messages |
ConfigFile::Error | if file not found |
ConfigFile::Error | if parse error |
Definition at line 95 of file config-file.cpp.
References parse().
void nfd::ConfigFile::parse | ( | std::istream & | input, |
bool | isDryRun, | ||
const std::string & | filename | ||
) |
input | stream to parse |
isDryRun | true if performing a dry run of configuration, false otherwise |
filename | logical filename of the config file, can appear in error messages |
ConfigFile::Error | if parse error |
Definition at line 102 of file config-file.cpp.
References NDN_THROW, and ndn::to_string().
void nfd::ConfigFile::parse | ( | const ConfigSection & | config, |
bool | isDryRun, | ||
const std::string & | filename | ||
) |
config | ConfigSection that needs to be processed |
isDryRun | true if performing a dry run of configuration, false otherwise |
filename | logical filename of the config file, can appear in error messages |
ConfigFile::Error | if parse error |
Definition at line 116 of file config-file.cpp.