Eclipse SUMO - Simulation of Urban MObility
|
A SAX-Handler for loading options. More...
#include <OptionsLoader.h>
Public Member Functions | |
bool | errorOccurred () const |
Returns the information whether an error occurred. | |
const std::string & | getItem () const |
Returns the last item read. | |
OptionsLoader (OptionsCont &customOptions, const bool routeOnly=false) | |
Constructor for default option container. | |
~OptionsLoader () | |
destructor | |
Handlers for the SAX DocumentHandler interface | |
virtual void | startElement (const XMLCh *const name, XERCES_CPP_NAMESPACE::AttributeList &attributes) |
Called on the occurrence of the beginning of a tag. | |
void | characters (const XMLCh *const chars, const XERCES3_SIZE_t length) |
Called on the occurrence of character data. | |
void | endElement (const XMLCh *const name) |
Called on the end of an element. | |
Handlers for the SAX ErrorHandler interface | |
void | warning (const XERCES_CPP_NAMESPACE::SAXParseException &exception) |
Called on an XML-warning. | |
void | error (const XERCES_CPP_NAMESPACE::SAXParseException &exception) |
Called on an XML-error. | |
void | fatalError (const XERCES_CPP_NAMESPACE::SAXParseException &exception) |
Called on an XML-fatal error. | |
Private Member Functions | |
OptionsLoader & | operator= (const OptionsLoader &s)=delete |
invalid assignment operator | |
OptionsLoader (const OptionsLoader &s)=delete | |
invalid copy constructor | |
bool | setSecure (OptionsCont &options, const std::string &name, const std::string &value) const |
Tries to set the named option to the given value. | |
void | setValue (const std::string &key, const std::string &value) |
Tries to set the named option to the given value. | |
Private Attributes | |
bool | myError = false |
The information whether an error occurred. | |
std::string | myItem |
The name of the currently parsed option. | |
OptionsCont & | myOptions |
The options to fill. | |
const bool | myRootOnly |
The information whether only the root element should be parsed. | |
std::string | myValue |
The currently read characters string. | |
A SAX-Handler for loading options.
Definition at line 44 of file OptionsLoader.h.
OptionsLoader::OptionsLoader | ( | OptionsCont & | customOptions, |
const bool | routeOnly = false |
||
) |
Constructor for default option container.
Definition at line 46 of file OptionsLoader.cpp.
OptionsLoader::~OptionsLoader | ( | ) |
destructor
Definition at line 53 of file OptionsLoader.cpp.
|
privatedelete |
invalid copy constructor
void OptionsLoader::characters | ( | const XMLCh *const | chars, |
const XERCES3_SIZE_t | length | ||
) |
Called on the occurrence of character data.
If this occurs inside a single tag it sets the option named by the tag to the value given by the character data. This is considered deprecated in favor of attributes.
Definition at line 88 of file OptionsLoader.cpp.
References myValue, and StringUtils::transcode().
void OptionsLoader::endElement | ( | const XMLCh *const | name | ) |
Called on the end of an element.
Resets the element name
Definition at line 104 of file OptionsLoader.cpp.
References myItem, myValue, and setValue().
void OptionsLoader::error | ( | const XERCES_CPP_NAMESPACE::SAXParseException & | exception | ) |
Called on an XML-error.
The warning is reported to the error-instance of MsgHandler
Definition at line 128 of file OptionsLoader.cpp.
References myError, toString(), StringUtils::transcode(), and WRITE_ERROR.
bool OptionsLoader::errorOccurred | ( | ) | const |
Returns the information whether an error occurred.
Definition at line 148 of file OptionsLoader.cpp.
References myError.
Referenced by OptionsIO::getRoot(), OptionsIO::loadConfiguration(), GNEOptionsDialog::loadConfiguration(), GNEPythonTool::loadConfiguration(), GNEApplicationWindowHelper::GNENeteditConfigHandler::loadNeteditConfig(), and GNEApplicationWindowHelper::GNESumoConfigHandler::loadSumoConfig().
void OptionsLoader::fatalError | ( | const XERCES_CPP_NAMESPACE::SAXParseException & | exception | ) |
Called on an XML-fatal error.
The warning is reported to the error-instance of MsgHandler
Definition at line 138 of file OptionsLoader.cpp.
References myError, toString(), StringUtils::transcode(), and WRITE_ERROR.
|
inline |
Returns the last item read.
Definition at line 106 of file OptionsLoader.h.
References myItem.
Referenced by OptionsIO::getRoot().
|
privatedelete |
invalid assignment operator
|
private |
Tries to set the named option to the given value.
Checks the item whether it was default before setting it. Returns the information whether the item was set before (was not a default value)
[in] | name | The name of the option to set |
[in] | value | The new value for the option |
Definition at line 94 of file OptionsLoader.cpp.
References OptionsCont::isWriteable(), and OptionsCont::set().
Referenced by setValue().
|
private |
Tries to set the named option to the given value.
Also evaluates whether it is a boolean or a filename option and does the relevant checks / modifications.
[in] | key | The name of the option to set |
[in] | value | The new value for the option |
Definition at line 72 of file OptionsLoader.cpp.
References myError, myOptions, setSecure(), TL, WRITE_ERROR, and WRITE_ERRORF.
Referenced by endElement(), and startElement().
|
virtual |
Called on the occurrence of the beginning of a tag.
Sets the name of the last item
Definition at line 56 of file OptionsLoader.cpp.
References myItem, myRootOnly, myValue, setValue(), and StringUtils::transcode().
void OptionsLoader::warning | ( | const XERCES_CPP_NAMESPACE::SAXParseException & | exception | ) |
Called on an XML-warning.
The warning is reported to the warning-instance of MsgHandler
Definition at line 118 of file OptionsLoader.cpp.
References myError, toString(), StringUtils::transcode(), and WRITE_WARNING.
|
private |
The information whether an error occurred.
Definition at line 115 of file OptionsLoader.h.
Referenced by error(), errorOccurred(), fatalError(), setValue(), and warning().
|
private |
The name of the currently parsed option.
Definition at line 121 of file OptionsLoader.h.
Referenced by endElement(), getItem(), and startElement().
|
private |
|
private |
The information whether only the root element should be parsed.
Definition at line 112 of file OptionsLoader.h.
Referenced by startElement().
|
private |
The currently read characters string.
Definition at line 124 of file OptionsLoader.h.
Referenced by characters(), endElement(), and startElement().