OSFI-C++
3.9.2
OpenSF Integration Library
|
#include <ParamReader.h>
Public Member Functions | |
ParamReader (const string &xmlFile, const string &xsdFile) | |
ParamReader (const std::string &xmlFile) | |
ParamReader (const ParamReader &other) | |
ParamReader (ParamReader &&other)=default | |
bool | validateAgainst (const std::string &xsdFile) const |
bool | validateAgainstInternalSchema () const |
virtual | ~ParamReader () |
Parameter | getParameter (const string ¶mName) const |
vector< Parameter > | getParameters (const string &groupName) const |
t_params_map | getParameters () const |
bool | existParameter (const string ¶mName) const |
void | setParameter (const string ¶mName, string value) |
void | print () const |
Parameter & | getParameterRef (const string &path) |
const Parameter & | getParameterRef (const string &path) const |
This class parses the XML configuration files provided by the openSF HMI formatted with the following elements:
ParamReader::ParamReader | ( | const string & | xmlFile, |
const string & | xsdFile | ||
) |
Default class constructor. Creates an instance of the ParamReader class, parses a given configuration XML file and stores every valid parameter.
Validating agains an XSD schema is optional.
xmlFile | - Configuration XML file |
xsdFile | - Configuration XSD schema |
exception | if error while parsing |
ParamReader::ParamReader | ( | const std::string & | xmlFile | ) |
Reads OSFI-formatted parameters from the given file.
xmlFile | Configuration XML file |
std::exception | If an error arises during parsing. |
ParamReader::ParamReader | ( | const ParamReader & | other | ) |
Copy constructor, duplicates the map and document objects
|
virtual |
Class destructor.
bool ParamReader::existParameter | ( | const string & | paramName | ) | const |
Checks the existence of a parameter within a configuration file.
paramName | Parameter name (full path and name) |
Parameter ParamReader::getParameter | ( | const string & | paramName | ) | const |
Parameter& ParamReader::getParameterRef | ( | const string & | path | ) |
Returns a reference to a parameter in the set of read data. This method differs from getParameter() in that it does not copy the data, so the lifetime of the referee is limited to that of this instance. The returned reference is never otherwise invalidated.
std::invalid_argument | If the path does not correspond to a parameter. |
t_params_map ParamReader::getParameters | ( | ) | const |
Gets a map containing all stored parameters.
vector<Parameter> ParamReader::getParameters | ( | const string & | groupName | ) | const |
Gets the list of parameters under a certain group.
groupName | - full name of the group. |
void ParamReader::print | ( | ) | const |
Prints a textual representation of the list of Parameters on screen.
void ParamReader::setParameter | ( | const string & | paramName, |
string | value | ||
) |
Changes the stored value of a certain parameter. Shows an error if cannot find parameter.
paramName | - full name of the parameter |
value | - new value |
exception | if value is invalid |
bool ParamReader::validateAgainst | ( | const std::string & | xsdFile | ) | const |
Validate the XML document read against the given schema.
invalid_argument | If the schema cannot be read. |
bool ParamReader::validateAgainstInternalSchema | ( | ) | const |
Validate the XML document read against the schema referenced in the document itself.