Configuration file parsing utility.
More...
#include <daemon/common/config-file.hpp>
|
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...
|
|
static void | ignoreUnknownSection (const std::string &filename, const std::string §ionName, const ConfigSection §ion, bool isDryRun) |
|
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) |
|
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) |
|
static void | throwErrorOnUnknownSection (const std::string &filename, const std::string §ionName, const ConfigSection §ion, bool isDryRun) |
|
Configuration file parsing utility.
Definition at line 65 of file config-file.hpp.
◆ ConfigFile()
◆ addSectionHandler()
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.
◆ checkRange()
template<typename T >
static void nfd::ConfigFile::checkRange |
( |
T |
value, |
|
|
T |
min, |
|
|
T |
max, |
|
|
const std::string & |
key, |
|
|
const std::string & |
sectionName |
|
) |
| |
|
inlinestatic |
Check that a value is within the inclusive range [min, max].
- Exceptions
-
Error | the value is out of the acceptable range |
Definition at line 141 of file config-file.hpp.
◆ ignoreUnknownSection()
void nfd::ConfigFile::ignoreUnknownSection |
( |
const std::string & |
filename, |
|
|
const std::string & |
sectionName, |
|
|
const ConfigSection & |
section, |
|
|
bool |
isDryRun |
|
) |
| |
|
static |
◆ parse() [1/4]
void nfd::ConfigFile::parse |
( |
const ConfigSection & |
config, |
|
|
bool |
isDryRun, |
|
|
const std::string & |
filename |
|
) |
| |
- Parameters
-
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 |
- Exceptions
-
Definition at line 116 of file config-file.cpp.
◆ parse() [2/4]
void nfd::ConfigFile::parse |
( |
const std::string & |
filename, |
|
|
bool |
isDryRun |
|
) |
| |
- Parameters
-
filename | file to parse |
isDryRun | true if performing a dry run of configuration, false otherwise |
- Exceptions
-
Definition at line 84 of file config-file.cpp.
◆ parse() [3/4]
void nfd::ConfigFile::parse |
( |
const std::string & |
input, |
|
|
bool |
isDryRun, |
|
|
const std::string & |
filename |
|
) |
| |
- Parameters
-
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 |
- Exceptions
-
Definition at line 95 of file config-file.cpp.
◆ parse() [4/4]
void nfd::ConfigFile::parse |
( |
std::istream & |
input, |
|
|
bool |
isDryRun, |
|
|
const std::string & |
filename |
|
) |
| |
- Parameters
-
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 |
- Exceptions
-
Definition at line 102 of file config-file.cpp.
◆ 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
-
- Returns
- the numeric value of the parsed option
- Exceptions
-
Error | the value cannot be converted to the specified type |
Definition at line 114 of file config-file.hpp.
◆ parseNumber() [2/2]
template<typename T >
static T nfd::ConfigFile::parseNumber |
( |
const ConfigSection::value_type & |
option, |
|
|
const std::string & |
sectionName |
|
) |
| |
|
inlinestatic |
◆ 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
-
- Exceptions
-
Error | the value is neither "yes" nor "no" |
Definition at line 60 of file config-file.cpp.
◆ parseYesNo() [2/2]
static bool nfd::ConfigFile::parseYesNo |
( |
const ConfigSection::value_type & |
option, |
|
|
const std::string & |
sectionName |
|
) |
| |
|
inlinestatic |
◆ throwErrorOnUnknownSection()
void nfd::ConfigFile::throwErrorOnUnknownSection |
( |
const std::string & |
filename, |
|
|
const std::string & |
sectionName, |
|
|
const ConfigSection & |
section, |
|
|
bool |
isDryRun |
|
) |
| |
|
static |