SUMO - Simulation of Urban MObility
OptionsLoader Class Reference

A SAX-Handler for loading options. More...

#include <OptionsLoader.h>

Inheritance diagram for OptionsLoader:
HandlerBase

Public Member Functions

bool errorOccured () const
 Returns the information whether an error occured.
 OptionsLoader ()
 Constructor.
 ~OptionsLoader ()
Handlers for the SAX DocumentHandler interface
virtual void startElement (const XMLCh *const name, AttributeList &attributes)
 Called on the occurence of the beginning of a tag.
void characters (const XMLCh *const chars, const XERCES3_SIZE_t length)
 Called on the occurence 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 SAXParseException &exception)
 Called on an XML-warning.
void error (const SAXParseException &exception)
 Called on an XML-error.
void fatalError (const SAXParseException &exception)
 Called on an XML-fatal error.

Private Member Functions

OptionsLoaderoperator= (const OptionsLoader &s)
 OptionsLoader (const OptionsLoader &s)
bool setSecure (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, std::string &value)
 Tries to set the named option to the given value.

Private Attributes

bool myError
 The information whether an error occured.
std::string myItem
 The name of the currently parsed option.
OptionsContmyOptions
 The options to fill.
std::string myValue
 The currently read characters string.

Detailed Description

A SAX-Handler for loading options.

Definition at line 62 of file OptionsLoader.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 53 of file OptionsLoader.cpp.

destructor

Definition at line 57 of file OptionsLoader.cpp.

OptionsLoader::OptionsLoader ( const OptionsLoader s) [private]

invalid copy constructor


Member Function Documentation

void OptionsLoader::characters ( const XMLCh *const  chars,
const XERCES3_SIZE_t  length 
)

Called on the occurence 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.

Todo:
Describe better

Definition at line 91 of file OptionsLoader.cpp.

References myValue.

void OptionsLoader::endElement ( const XMLCh *const  name)

Called on the end of an element.

Resets the element name

Definition at line 109 of file OptionsLoader.cpp.

References myItem, myValue, and setValue().

void OptionsLoader::error ( const SAXParseException &  exception)

Called on an XML-error.

The warning is reported to the the error-instance of MsgHandler

Definition at line 133 of file OptionsLoader.cpp.

References myError, toString(), and WRITE_ERROR.

Returns the information whether an error occured.

Definition at line 157 of file OptionsLoader.cpp.

References myError.

Referenced by OptionsIO::loadConfiguration().

void OptionsLoader::fatalError ( const SAXParseException &  exception)

Called on an XML-fatal error.

The warning is reported to the the error-instance of MsgHandler

Definition at line 145 of file OptionsLoader.cpp.

References myError, toString(), and WRITE_ERROR.

OptionsLoader& OptionsLoader::operator= ( const OptionsLoader s) [private]

invalid assignment operator

bool OptionsLoader::setSecure ( const std::string &  name,
const std::string &  value 
) const [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)

Parameters:
[in]nameThe name of the option to set
[in]valueThe new value for the option
Returns:
Whether the option could be set

Definition at line 98 of file OptionsLoader.cpp.

References OptionsCont::isWriteable(), myOptions, and OptionsCont::set().

Referenced by setValue().

void OptionsLoader::setValue ( const std::string &  key,
std::string &  value 
) [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.

Parameters:
[in]keyThe name of the option to set
[in]valueThe new value for the option

Definition at line 75 of file OptionsLoader.cpp.

References myError, setSecure(), and WRITE_ERROR.

Referenced by endElement(), and startElement().

void OptionsLoader::startElement ( const XMLCh *const  name,
AttributeList &  attributes 
) [virtual]

Called on the occurence of the beginning of a tag.

Sets the name of the last item

Definition at line 60 of file OptionsLoader.cpp.

References myItem, myValue, and setValue().

void OptionsLoader::warning ( const SAXParseException &  exception)

Called on an XML-warning.

The warning is reported to the the warning-instance of MsgHandler

Definition at line 123 of file OptionsLoader.cpp.

References myError, toString(), and WRITE_WARNING.


Field Documentation

The information whether an error occured.

Definition at line 171 of file OptionsLoader.h.

Referenced by error(), errorOccured(), fatalError(), setValue(), and warning().

std::string OptionsLoader::myItem [private]

The name of the currently parsed option.

Definition at line 177 of file OptionsLoader.h.

Referenced by endElement(), and startElement().

The options to fill.

Definition at line 174 of file OptionsLoader.h.

Referenced by setSecure().

std::string OptionsLoader::myValue [private]

The currently read characters string.

Definition at line 180 of file OptionsLoader.h.

Referenced by characters(), endElement(), and startElement().


The documentation for this class was generated from the following files:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines