NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
nfd::ConfigFile Class Reference

configuration file parsing utility More...

#include <config-file.hpp>

Inheritance diagram for nfd::ConfigFile:
Collaboration diagram for nfd::ConfigFile:

Classes

class  Error
 

Public Member Functions

 ConfigFile (UnknownConfigSectionHandler unknownSectionCallback=throwErrorOnUnknownSection)
 
void addSectionHandler (const std::string &sectionName, 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 &sectionName, const ConfigSection &section, bool isDryRun)
 
static void ignoreUnknownSection (const std::string &filename, const std::string &sectionName, const ConfigSection &section, bool isDryRun)
 
static bool parseYesNo (const ConfigSection &node, const std::string &key, const std::string &sectionName)
 parse a config option that can be either "yes" or "no" More...
 
static bool parseYesNo (const ConfigSection::value_type &option, const std::string &sectionName)
 
template<typename T >
static T parseNumber (const ConfigSection &node, const std::string &key, const std::string &sectionName)
 parse a numeric (integral or floating point) config option More...
 
template<typename T >
static T parseNumber (const ConfigSection::value_type &option, const std::string &sectionName)
 
template<typename T >
static void checkRange (T value, T min, T max, const std::string &key, const std::string &sectionName)
 check that a value is within the inclusive range [min, max] More...
 

Detailed Description

configuration file parsing utility

Definition at line 57 of file config-file.hpp.

Constructor & Destructor Documentation

◆ ConfigFile()

nfd::ConfigFile::ConfigFile ( UnknownConfigSectionHandler  unknownSectionCallback = throwErrorOnUnknownSection)
explicit

Definition at line 35 of file config-file.cpp.

Member Function Documentation

◆ throwErrorOnUnknownSection()

void nfd::ConfigFile::throwErrorOnUnknownSection ( const std::string &  filename,
const std::string &  sectionName,
const ConfigSection section,
bool  isDryRun 
)
static

Definition at line 41 of file config-file.cpp.

References NDN_THROW.

Referenced by nfd::ignoreRibAndLogSections(), and ns3::ndn::IgnoreSections::operator()().

◆ ignoreUnknownSection()

void nfd::ConfigFile::ignoreUnknownSection ( const std::string &  filename,
const std::string &  sectionName,
const ConfigSection section,
bool  isDryRun 
)
static

◆ parseYesNo() [1/2]

bool nfd::ConfigFile::parseYesNo ( const ConfigSection node,
const std::string &  key,
const std::string &  sectionName 
)
static

parse a config option that can be either "yes" or "no"

Return values
true"yes"
false"no"
Exceptions
Errorthe 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().

◆ parseYesNo() [2/2]

static bool nfd::ConfigFile::parseYesNo ( const ConfigSection::value_type &  option,
const std::string &  sectionName 
)
inlinestatic

Definition at line 92 of file config-file.hpp.

References parseYesNo().

◆ parseNumber() [1/2]

template<typename T >
static T nfd::ConfigFile::parseNumber ( const ConfigSection node,
const std::string &  key,
const std::string &  sectionName 
)
inlinestatic

parse a numeric (integral or floating point) config option

Template Parameters
Tan arithmetic type
Returns
the numeric value of the parsed option
Exceptions
Errorthe value cannot be converted to the specified type

Definition at line 106 of file config-file.hpp.

References NDN_THROW.

◆ parseNumber() [2/2]

template<typename T >
static T nfd::ConfigFile::parseNumber ( const ConfigSection::value_type &  option,
const std::string &  sectionName 
)
inlinestatic

Definition at line 122 of file config-file.hpp.

◆ checkRange()

template<typename T >
static void nfd::ConfigFile::checkRange ( value,
min,
max,
const std::string &  key,
const std::string &  sectionName 
)
inlinestatic

check that a value is within the inclusive range [min, max]

Exceptions
Errorthe 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().

◆ addSectionHandler()

void nfd::ConfigFile::addSectionHandler ( const std::string &  sectionName,
ConfigSectionHandler  subscriber 
)

◆ parse() [1/4]

void nfd::ConfigFile::parse ( const std::string &  filename,
bool  isDryRun 
)
Parameters
filenamefile to parse
isDryRuntrue if performing a dry run of configuration, false otherwise
Exceptions
ConfigFile::Errorif file not found
ConfigFile::Errorif 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().

◆ parse() [2/4]

void nfd::ConfigFile::parse ( const std::string &  input,
bool  isDryRun,
const std::string &  filename 
)
Parameters
inputconfiguration (as a string) to parse
isDryRuntrue if performing a dry run of configuration, false otherwise
filenamelogical filename of the config file, can appear in error messages
Exceptions
ConfigFile::Errorif file not found
ConfigFile::Errorif parse error

Definition at line 95 of file config-file.cpp.

References parse().

◆ parse() [3/4]

void nfd::ConfigFile::parse ( std::istream &  input,
bool  isDryRun,
const std::string &  filename 
)
Parameters
inputstream to parse
isDryRuntrue if performing a dry run of configuration, false otherwise
filenamelogical filename of the config file, can appear in error messages
Exceptions
ConfigFile::Errorif parse error

Definition at line 102 of file config-file.cpp.

References NDN_THROW, and ndn::to_string().

◆ parse() [4/4]

void nfd::ConfigFile::parse ( const ConfigSection config,
bool  isDryRun,
const std::string &  filename 
)
Parameters
configConfigSection that needs to be processed
isDryRuntrue if performing a dry run of configuration, false otherwise
filenamelogical filename of the config file, can appear in error messages
Exceptions
ConfigFile::Errorif parse error

Definition at line 116 of file config-file.cpp.


The documentation for this class was generated from the following files: