DUNE: Uniform Navigational Environment
2019.02.1
|
Microsoft Windows INI configuration file parser.
The configuration file format consists of sections, led by a "[section]" header and followed by "option = value" entries, with continuations in the style of RFC 822. Note that leading and trailing whitespaces are removed from values. Character case in "option" identifiers is discarded. Lines beginning with "#" or ";" are ignored and may be used to provide comments.
Public Member Functions | |
Config (void) | |
Config (const char *fname) | |
void | parseFile (const char *fname) |
void | set (const std::string §ion, const std::string &option, const std::string &value) |
std::string | get (const std::string §ion, const std::string &option) |
void | setSection (const std::string §ion, const std::map< std::string, std::string > &map) |
std::map< std::string, std::string > | getSection (const std::string §ion) |
template<typename Type > | |
void | get (const std::string &sec, const std::string &opt, const std::string &def, Type &var) |
template<typename T > | |
bool | getList (const std::string §ion, const std::string &option, T *dest, unsigned int size) |
void | writeToFile (const char *file) |
std::vector< std::string > | files (void) |
std::vector< std::string > | sections (void) |
std::vector< std::string > | options (const std::string §ion) |
Friends | |
DUNE_DLL_SYM std::ostream & | operator<< (std::ostream &os, const Config &cfg) |
|
inline |
DUNE::Parsers::Config::Config | ( | const char * | fname | ) |
Create the parser and parse a configuration file.
fname | name of the configuration file to parse. |
References parseFile().
|
inline |
Retrieve the file option of the parsed configuration file.
References Config(), operator<<, options(), and sections().
|
inline |
Retrieve the value of an option in a given section.
section | section. |
option | option. |
Referenced by DUNE::Control::BasicAutopilot::BasicAutopilot(), DUNE::Power::Model::computeIMUEnergy(), DUNE::Daemon::consume(), DUNE::Daemon::Daemon(), DUNE::Tasks::Task::loadConfig(), DUNE::Tasks::Manager::Manager(), DUNE::Power::Model::Model(), Simulators::Environment::Task::onResourceInitialization(), DUNE::Parsers::PlanConfigParser::parse(), DUNE::Parsers::PlanConfigParser::parseActions(), DUNE::Parsers::PlanConfigParser::parseAngle(), DUNE::Parsers::PlanConfigParser::parseCoordinate(), DUNE::Parsers::PlanConfigParser::parseDuration(), DUNE::Parsers::PlanConfigParser::parseSpeed(), DUNE::Parsers::PlanConfigParser::parseTimeout(), DUNE::Parsers::PlanConfigParser::parseZ(), DUNE::Parsers::PlanConfigParser::parseZUnits(), DUNE::Control::PathController::PathController(), DUNE::Math::Matrix::readFromConfig(), and DUNE::Plans::SpeedModel::SpeedModel().
|
inline |
Retrieve the value of an option in a given section and perform type conversion.
sec | section. |
opt | option. |
def | default value. |
var | destination variable. |
References DUNE::castLexical(), and DUNE::Utils::String.
|
inline |
Retrieve the list of strings separated by commas of an option in a given section, performing type conversion.
section | section. |
option | option. |
dest | destination array. |
size | expected number of strings. |
References writeToFile().
|
inline |
Retrieve the option map of a given section.
[in] | section | section name. |
Referenced by DUNE::Tasks::Task::loadConfig().
std::vector< std::string > DUNE::Parsers::Config::options | ( | const std::string & | section | ) |
Retrieve all the options under the given section.
section | section of interest. |
Referenced by DUNE::Daemon::Daemon(), files(), and DUNE::Parsers::PlanConfigParser::parseActions().
void DUNE::Parsers::Config::parseFile | ( | const char * | fname | ) |
Parse a configuration file.
fname | name of the configuration file to parse. |
References DUNE::System::Error::getLastMessage().
Referenced by Config(), and DUNE::Daemon::Daemon().
std::vector< std::string > DUNE::Parsers::Config::sections | ( | void | ) |
Retrieve all the available sections.
Referenced by files(), DUNE::Tasks::Manager::Manager(), and DUNE::Parsers::operator<<().
|
inline |
Set a configuration parameter.
section | section. |
option | option. |
value | value for option. |
Referenced by DUNE::Daemon::consume(), and DUNE::Tasks::Task::onSetEntityParameters().
|
inline |
Set the option map of a given section.
[in] | section | section name. |
[in] | map | map of <option, value>. |
void DUNE::Parsers::Config::writeToFile | ( | const char * | file | ) |
Writes the current configuration to a file.
file | output file option. |
Referenced by DUNE::Daemon::consume(), and getList().
|
friend |