SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SUMOSAXAttributes Class Referenceabstract

Encapsulated SAX-Attributes. More...

#include <SUMOSAXAttributes.h>

Inheritance diagram for SUMOSAXAttributes:
SUMOSAXAttributesImpl_Binary SUMOSAXAttributesImpl_Xerces

Public Member Functions

bool getBoolReporting (int attr, const char *objectid, bool &ok, bool report=true) const
 Tries to read given attribute assuming it is a boolean. More...
 
int getIntReporting (int attr, const char *objectid, bool &ok, bool report=true) const
 Tries to read given attribute assuming it is an int. More...
 
SUMOLong getLongReporting (int attr, const char *objectid, bool &ok, bool report=true) const
 Tries to read given attribute assuming it is a long. More...
 
bool getOptBoolReporting (int attr, const char *objectid, bool &ok, bool defaultValue, bool report=true) const
 Tries to read given attribute assuming it is a boolean. More...
 
int getOptIntReporting (int attr, const char *objectid, bool &ok, int defaultValue, bool report=true) const
 Tries to read given attribute assuming it is an int. More...
 
std::string getOptStringReporting (int attr, const char *objectid, bool &ok, const std::string &defaultValue, bool report=true) const
 Tries to read given attribute assuming it is a string. More...
 
SUMOReal getOptSUMORealReporting (int attr, const char *objectid, bool &ok, SUMOReal defaultValue, bool report=true) const
 Tries to read given attribute assuming it is a SUMOReal. More...
 
SUMOTime getOptSUMOTimeReporting (int attr, const char *objectid, bool &ok, SUMOTime defaultValue, bool report=true) const
 Tries to read given attribute assuming it is a SUMOTime. More...
 
std::string getStringReporting (int attr, const char *objectid, bool &ok, bool report=true) const
 Tries to read given attribute assuming it is a string. More...
 
SUMOReal getSUMORealReporting (int attr, const char *objectid, bool &ok, bool report=true) const
 Tries to read given attribute assuming it is a SUMOReal. More...
 
SUMOTime getSUMOTimeReporting (int attr, const char *objectid, bool &ok, bool report=true) const
 Tries to read given attribute assuming it is a SUMOTime. More...
 
 SUMOSAXAttributes (const std::string &objectType)
 
virtual ~SUMOSAXAttributes ()
 Destructor. More...
 

virtual methods for retrieving attribute values

static const std::string ENCODING = " encoding=\"UTF-8\""
 The encoding of parsed strings. More...
 
static bool myHaveInformedAboutDeprecatedDivider = false
 Information whether the usage of a deprecated divider was reported. More...
 
std::string myObjectType
 the object type to use in error reporting More...
 
virtual bool hasAttribute (int id) const =0
 Returns the information whether the named (by its enum-value) attribute is within the current list. More...
 
virtual bool hasAttribute (const std::string &id) const =0
 Returns the information whether the named attribute is within the current list. More...
 
virtual bool getBool (int id) const =0 throw (EmptyData, BoolFormatException)
 Returns the bool-value of the named (by its enum-value) attribute. More...
 
virtual bool getBoolSecure (int id, bool val) const =0 throw (EmptyData)
 Returns the bool-value of the named (by its enum-value) attribute or the given value if the attribute is not known. More...
 
virtual int getInt (int id) const =0
 Returns the int-value of the named (by its enum-value) attribute. More...
 
virtual SUMOLong getLong (int id) const =0
 Returns the long-value of the named (by its enum-value) attribute. More...
 
virtual int getIntSecure (int id, int def) const =0
 Returns the int-value of the named (by its enum-value) attribute. More...
 
virtual std::string getString (int id) const =0 throw (EmptyData)
 Returns the string-value of the named (by its enum-value) attribute. More...
 
virtual std::string getStringSecure (int id, const std::string &def) const =0 throw (EmptyData)
 Returns the string-value of the named (by its enum-value) attribute. More...
 
virtual SUMOReal getFloat (int id) const =0
 Returns the SUMOReal-value of the named (by its enum-value) attribute. More...
 
virtual SUMOReal getFloatSecure (int id, SUMOReal def) const =0
 Returns the SUMOReal-value of the named (by its enum-value) attribute. More...
 
virtual SUMOReal getFloat (const std::string &id) const =0
 Returns the SUMOReal-value of the named attribute. More...
 
virtual std::string getStringSecure (const std::string &id, const std::string &def) const =0
 Returns the string-value of the named (by its enum-value) attribute. More...
 
virtual SumoXMLEdgeFunc getEdgeFunc (bool &ok) const =0
 Returns the value of the named attribute. More...
 
virtual SumoXMLNodeType getNodeType (bool &ok) const =0
 Returns the value of the named attribute. More...
 
virtual RGBColor getColorReporting (const char *objectid, bool &ok) const =0
 Returns the value of the named attribute. More...
 
virtual PositionVector getShapeReporting (int attr, const char *objectid, bool &ok, bool allowEmpty) const =0
 Tries to read given attribute assuming it is a PositionVector. More...
 
virtual Boundary getBoundaryReporting (int attr, const char *objectid, bool &ok) const =0
 Tries to read given attribute assuming it is a PositionVector. More...
 
virtual std::string getName (int attr) const =0
 Converts the given attribute id into a man readable string. More...
 
virtual void serialize (std::ostream &os) const =0
 Prints all attribute names and values into the given stream. More...
 
const std::string & getObjectType () const
 return the objecttype to which these attributes belong More...
 
static void parseStringVector (const std::string &def, std::vector< std::string > &into)
 Splits the given string. More...
 
std::ostream & operator<< (std::ostream &os, const SUMOSAXAttributes &src)
 
void emitUngivenError (const std::string &attrname, const char *objectid) const
 
void emitEmptyError (const std::string &attrname, const char *objectid) const
 
void emitFormatError (const std::string &attrname, const std::string &type, const char *objectid) const
 
 SUMOSAXAttributes (const SUMOSAXAttributes &src)
 Invalidated copy constructor. More...
 
SUMOSAXAttributesoperator= (const SUMOSAXAttributes &src)
 Invalidated assignment operator. More...
 

Detailed Description

Encapsulated SAX-Attributes.

This class is an interface for using encapsulated SAX-attributes. Encapsulation is done to allow a common acces without the need to import all the Xerces-definitions.

Definition at line 62 of file SUMOSAXAttributes.h.

Constructor & Destructor Documentation

SUMOSAXAttributes::SUMOSAXAttributes ( const std::string &  objectType)

Definition at line 55 of file SUMOSAXAttributes.cpp.

virtual SUMOSAXAttributes::~SUMOSAXAttributes ( )
inlinevirtual

Destructor.

Definition at line 71 of file SUMOSAXAttributes.h.

SUMOSAXAttributes::SUMOSAXAttributes ( const SUMOSAXAttributes src)
private

Invalidated copy constructor.

Member Function Documentation

void SUMOSAXAttributes::emitUngivenError ( const std::string &  attrname,
const char *  objectid 
) const
protected
virtual bool SUMOSAXAttributes::getBool ( int  id) const throw (EmptyData, BoolFormatException)
pure virtual

Returns the bool-value of the named (by its enum-value) attribute.

Tries to retrieve the attribute from the the attribute list. The retrieved attribute (which may be 0) is then parsed using TplConvert<XMLCh>::_2bool. If the attribute is empty or ==0, TplConvert<XMLCh>::_2bool throws an EmptyData-exception which is passed. If the value can not be parsed to a bool, TplConvert<XMLCh>::_2bool throws a BoolFormatException-exception which is passed.

Parameters
[in]idThe id of the attribute to return the value of
Returns
The attribute's value as a bool, if it could be read and parsed
Exceptions
EmptyDataIf the attribute is not known or the attribute value is an empty string
BoolFormatExceptionIf the attribute value can not be parsed to a bool

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

Referenced by getBoolReporting(), and getOptBoolReporting().

bool SUMOSAXAttributes::getBoolReporting ( int  attr,
const char *  objectid,
bool ok,
bool  report = true 
) const

Tries to read given attribute assuming it is a boolean.

If an error occurs (the attribute is not there, it is not a boolean), "ok" is set to false and an error message is written to MsgHandler::getErrorInstance.

Otherwise, "ok" is not changed.

Parameters
[in]attrThe id of the attribute to read
[in]objectidThe name of the parsed object; used for error message generation
[out]okWhether the value could be read
[in]reportWhether errors shall be written to msg handler's error instance
Returns
The read value if given and correct; false if an error occured

Definition at line 182 of file SUMOSAXAttributes.cpp.

References emitEmptyError(), emitFormatError(), emitUngivenError(), getBool(), getName(), and hasAttribute().

virtual bool SUMOSAXAttributes::getBoolSecure ( int  id,
bool  val 
) const throw (EmptyData)
pure virtual

Returns the bool-value of the named (by its enum-value) attribute or the given value if the attribute is not known.

Tries to retrieve the attribute from the the attribute list. The retrieved attribute (which may be 0) is then parsed using TplConvert<XMLCh>::_2boolSec. If the attribute is empty, TplConvert<XMLCh>::_2boolSec throws an EmptyData-exception which is passed. If the attribute==0, TplConvert<XMLCh>::_2boolSec returns the default value.

Parameters
[in]idThe id of the attribute to return the value of
[in]valThe default value to return if the attribute is not in attributes
Returns
The attribute's value as a bool, if it could be read and parsed
Exceptions
EmptyDataIf the attribute value is an empty string

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

virtual Boundary SUMOSAXAttributes::getBoundaryReporting ( int  attr,
const char *  objectid,
bool ok 
) const
pure virtual

Tries to read given attribute assuming it is a PositionVector.

If an error occurs (the attribute is not there, it's empty), "ok" is set to false and an error message is written to MsgHandler::getErrorInstance.

Otherwise, "ok" is not changed.

Parameters
[in]attrThe id of the attribute to read
[in]objectidThe name of the parsed object; used for error message generation
[out]okWhether the value could be read
[in]reportWhether errors shall be written to msg handler's error instance
Returns
The read value if given and not empty; "" if an error occured

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

Referenced by NIImporter_SUMO::loadLocation(), PCNetProjectionLoader::myStartElement(), and NLHandler::setLocation().

virtual RGBColor SUMOSAXAttributes::getColorReporting ( const char *  objectid,
bool ok 
) const
pure virtual
virtual SumoXMLEdgeFunc SUMOSAXAttributes::getEdgeFunc ( bool ok) const
pure virtual

Returns the value of the named attribute.

Tries to retrieve the attribute from the the attribute list.

Returns
The attribute's value as a string, if it could be read and parsed

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

Referenced by NIImporter_SUMO::addEdge(), and NLHandler::beginEdgeParsing().

virtual SUMOReal SUMOSAXAttributes::getFloat ( int  id) const
pure virtual

Returns the SUMOReal-value of the named (by its enum-value) attribute.

Tries to retrieve the attribute from the the attribute list. The retrieved attribute (which may be 0) is then parsed using TplConvert<XMLCh>::_2SUMOReal. If the attribute is empty or ==0, TplConvert<XMLCh>::_2SUMOReal throws an EmptyData-exception which is passed. If the value can not be parsed to a SUMOReal, TplConvert<XMLCh>::_2SUMOReal throws a NumberFormatException-exception which is passed.

Parameters
[in]idThe id of the attribute to return the value of
Returns
The attribute's value as a float, if it could be read and parsed
Exceptions
EmptyDataIf the attribute is not known or the attribute value is an empty string
NumberFormatExceptionIf the attribute value can not be parsed to an SUMOReal

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

Referenced by getOptSUMORealReporting(), getOptSUMOTimeReporting(), getSUMORealReporting(), getSUMOTimeReporting(), AGActivityGenHandler::parseBusStation(), AGActivityGenHandler::parseCityGates(), AGActivityGenHandler::parseClosingHour(), AGActivityGenHandler::parseOpeningHour(), AGActivityGenHandler::parseSchool(), AGActivityGenHandler::parseStreets(), and SAXWeightsHandler::tryParse().

virtual SUMOReal SUMOSAXAttributes::getFloat ( const std::string &  id) const
pure virtual

Returns the SUMOReal-value of the named attribute.

Tries to retrieve the attribute from the the attribute list. The retrieved attribute (which may be 0) is then parsed using TplConvert<XMLCh>::_2SUMOReal. If the attribute is empty or ==0, TplConvert<XMLCh>::_2SUMOReal throws an EmptyData-exception which is passed. If the value can not be parsed to a SUMOReal, TplConvert<XMLCh>::_2SUMOReal throws a NumberFormatException-exception which is passed.

Parameters
[in]idThe name of the attribute to return the value of
Returns
The attribute's value as a float, if it could be read and parsed
Exceptions
EmptyDataIf the attribute is not known or the attribute value is an empty string
NumberFormatExceptionIf the attribute value can not be parsed to an SUMOReal

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

virtual SUMOReal SUMOSAXAttributes::getFloatSecure ( int  id,
SUMOReal  def 
) const
pure virtual

Returns the SUMOReal-value of the named (by its enum-value) attribute.

Tries to retrieve the attribute from the the attribute list. The retrieved attribute (which may be 0) is then parsed using TplConvert<XMLCh>::_2SUMORealSec. If the attribute is empty, TplConvert<XMLCh>::_2SUMORealSec throws an EmptyData-exception which is passed. If the attribute==0, TplConvert<XMLCh>::_2SUMORealSec returns the default value. If the value can not be parsed to a SUMOReal, TplConvert<XMLCh>::_2SUMORealSec throws a NumberFormatException-exception which is passed.

Parameters
[in]idThe id of the attribute to return the value of
[in]defThe default value to return if the attribute is not in attributes
Returns
The attribute's value as a float, if it could be read and parsed
Exceptions
EmptyDataIf the attribute is not known or the attribute value is an empty string
NumberFormatExceptionIf the attribute value can not be parsed to an SUMOReal

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

Referenced by AGActivityGenHandler::parseGeneralCityInfo(), and AGActivityGenHandler::parseParameters().

virtual int SUMOSAXAttributes::getInt ( int  id) const
pure virtual

Returns the int-value of the named (by its enum-value) attribute.

Tries to retrieve the attribute from the the attribute list. The retrieved attribute (which may be 0) is then parsed using TplConvert<XMLCh>::_2int. If the attribute is empty or ==0, TplConvert<XMLCh>::_2int throws an EmptyData-exception which is passed. If the value can not be parsed to an int, TplConvert<XMLCh>::_2int throws a NumberFormatException-exception which is passed.

Parameters
[in]idThe id of the attribute to return the value of
Returns
The attribute's value as an int, if it could be read and parsed
Exceptions
EmptyDataIf the attribute is not known or the attribute value is an empty string
NumberFormatExceptionIf the attribute value can not be parsed to an int

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

Referenced by getIntReporting(), getOptIntReporting(), AGActivityGenHandler::parseBracket(), AGActivityGenHandler::parseBusLine(), AGActivityGenHandler::parseBusStation(), AGActivityGenHandler::parseClosingHour(), AGActivityGenHandler::parseFrequency(), AGActivityGenHandler::parseGeneralCityInfo(), AGActivityGenHandler::parseOpeningHour(), and AGActivityGenHandler::parseSchool().

int SUMOSAXAttributes::getIntReporting ( int  attr,
const char *  objectid,
bool ok,
bool  report = true 
) const

Tries to read given attribute assuming it is an int.

If an error occurs (the attribute is not there, it is not numeric), "ok" is set to false. If report is true an error message is written to MsgHandler::getErrorInstance.

If the value could be read, "ok" is not changed, and the value is returned.

Parameters
[in]attrThe id of the attribute to read
[in]objectidThe name of the parsed object; used for error message generation
[out]okWhether the value could be read
[in]reportWhether errors shall be written to msg handler's error instance
Returns
The read value if given and correct; -1 if an error occured

Definition at line 60 of file SUMOSAXAttributes.cpp.

References emitEmptyError(), emitFormatError(), emitUngivenError(), getInt(), getName(), and hasAttribute().

Referenced by NIImporter_SUMO::addConnection(), NLHandler::addConnection(), NIXMLEdgesHandler::addEdge(), NIXMLEdgesHandler::addLane(), NLHandler::addRequest(), MSRouteHandler::addStop(), getSUMOTimeReporting(), NIImporter_MATSim::EdgesHandler::myStartElement(), NIImporter_OpenDrive::myStartElement(), RORouteHandler::openRouteDistribution(), SUMOVehicleParserHelper::parseCommonAttributes(), RORDGenerator_ODAmounts::parseFlowAmountDef(), SUMOVehicleParserHelper::parseFlowAttributes(), NIXMLConnectionsHandler::parseLaneDefinition(), AGActivityGenHandler::parseStation(), SUMOVehicleParserHelper::parseVehicleAttributes(), NIXMLTrafficLightsHandler::removeTlConnection(), NIXMLTrafficLightsHandler::retrieveLaneIndex(), and RORDLoader_SUMOBase::startAlternative().

virtual int SUMOSAXAttributes::getIntSecure ( int  id,
int  def 
) const
pure virtual

Returns the int-value of the named (by its enum-value) attribute.

Tries to retrieve the attribute from the the attribute list. The retrieved attribute (which may be 0) is then parsed using TplConvert<XMLCh>::_2intSec. If the attribute is empty, TplConvert<XMLCh>::_2intSec throws an EmptyData-exception which is passed. If the attribute==0, TplConvert<XMLCh>::_2intSec returns the default value. If the value can not be parsed to an int, TplConvert<XMLCh>::_2intSec throws a NumberFormatException-exception which is passed.

Parameters
[in]idThe id of the attribute to return the value of
[in]defThe default value to return if the attribute is not in attributes
Returns
The attribute's value as an int, if it could be read and parsed
Exceptions
EmptyDataIf the attribute value is an empty string
NumberFormatExceptionIf the attribute value can not be parsed to an int

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

Referenced by AGActivityGenHandler::parseGeneralCityInfo().

virtual SUMOLong SUMOSAXAttributes::getLong ( int  id) const
pure virtual

Returns the long-value of the named (by its enum-value) attribute.

Tries to retrieve the attribute from the the attribute list. The retrieved attribute (which may be 0) is then parsed using TplConvert<XMLCh>::_2long. If the attribute is empty or ==0, TplConvert<XMLCh>::_2long throws an EmptyData-exception which is passed. If the value can not be parsed to a long, TplConvert<XMLCh>::_2long throws a NumberFormatException-exception which is passed.

Parameters
[in]idThe id of the attribute to return the value of
Returns
The attribute's value as an int, if it could be read and parsed
Exceptions
EmptyDataIf the attribute is not known or the attribute value is an empty string
NumberFormatExceptionIf the attribute value can not be parsed to an int

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

Referenced by getLongReporting().

SUMOLong SUMOSAXAttributes::getLongReporting ( int  attr,
const char *  objectid,
bool ok,
bool  report = true 
) const

Tries to read given attribute assuming it is a long.

If an error occurs (the attribute is not there, it is not numeric), "ok" is set to false. If report is true an error message is written to MsgHandler::getErrorInstance.

If the value could be read, "ok" is not changed, and the value is returned.

Parameters
[in]attrThe id of the attribute to read
[in]objectidThe name of the parsed object; used for error message generation
[out]okWhether the value could be read
[in]reportWhether errors shall be written to msg handler's error instance
Returns
The read value if given and correct; -1 if an error occured

Definition at line 108 of file SUMOSAXAttributes.cpp.

References emitEmptyError(), emitFormatError(), emitUngivenError(), getLong(), getName(), and hasAttribute().

Referenced by PCLoaderOSM::NodesHandler::myStartElement(), PCLoaderOSM::EdgesHandler::myStartElement(), NIImporter_OpenStreetMap::NodesHandler::myStartElement(), and NIImporter_OpenStreetMap::EdgesHandler::myStartElement().

virtual std::string SUMOSAXAttributes::getName ( int  attr) const
pure virtual
virtual SumoXMLNodeType SUMOSAXAttributes::getNodeType ( bool ok) const
pure virtual

Returns the value of the named attribute.

Tries to retrieve the attribute from the the attribute list.

Returns
The attribute's value as a string, if it could be read and parsed

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

Referenced by NIImporter_SUMO::addJunction(), and NLHandler::openJunction().

const std::string& SUMOSAXAttributes::getObjectType ( ) const
inline
bool SUMOSAXAttributes::getOptBoolReporting ( int  attr,
const char *  objectid,
bool ok,
bool  defaultValue,
bool  report = true 
) const

Tries to read given attribute assuming it is a boolean.

If the attribute is not existing in the current element, the default value is returned. If an error occurs on parsing (the attribute is empty, it is not a boolean), "ok" is set to false. If report is true an error message is written to MsgHandler::getErrorInstance.

Otherwise, "ok" is not changed.

Parameters
[in]attrThe id of the attribute to read
[in]objectidThe name of the parsed object; used for error message generation
[out]okWhether the value could be read
[in]defaultValueThe value to return if the attribute is not within the element
[in]reportWhether errors shall be written to msg handler's error instance
Returns
The read value if given and correct; the default value if the attribute does not exist; false if an error occured

Definition at line 208 of file SUMOSAXAttributes.cpp.

References emitEmptyError(), emitFormatError(), getBool(), getName(), and hasAttribute().

Referenced by NIImporter_SUMO::addConnection(), NLHandler::addE1Detector(), NLHandler::addE2Detector(), NLHandler::addE3Entry(), NLHandler::addE3Exit(), NIXMLEdgesHandler::addEdge(), NLHandler::addEdgeLaneMeanData(), NLHandler::addInstantE1Detector(), NLHandler::addPoly(), NLHandler::addRequest(), MSRouteHandler::addStop(), NLHandler::addWAUTJunction(), GUISettingsHandler::myStartElement(), PCTypeDefHandler::myStartElement(), NIXMLTypesHandler::myStartElement(), PCLoaderXML::myStartElement(), SUMOVehicleParserHelper::parseCommonAttributes(), and NIXMLConnectionsHandler::parseLaneBound().

int SUMOSAXAttributes::getOptIntReporting ( int  attr,
const char *  objectid,
bool ok,
int  defaultValue,
bool  report = true 
) const

Tries to read given attribute assuming it is an int.

If the attribute is not existing in the current element, the default value is returned. If an error occurs on parsing (the attribute is empty, it is not numeric), "ok" is set to false. If report is true an error message is written to MsgHandler::getErrorInstance.

If the value could be read, "ok" is not changed, and the value is returned.

Parameters
[in]attrThe id of the attribute to read
[in]objectidThe name of the parsed object; used for error message generation
[out]okWhether the value could be read
[in]defaultValueThe value to return if the attribute is not within the element
[in]reportWhether errors shall be written to msg handler's error instance
Returns
The read value if given and correct; the default value if the attribute does not exist; -1 if an error occured

Definition at line 86 of file SUMOSAXAttributes.cpp.

References emitEmptyError(), emitFormatError(), getInt(), getName(), and hasAttribute().

Referenced by NIImporter_SUMO::addEdge(), NIXMLTrafficLightsHandler::addTlConnection(), getOptSUMOTimeReporting(), PCTypeDefHandler::myStartElement(), and NIXMLTypesHandler::myStartElement().

std::string SUMOSAXAttributes::getOptStringReporting ( int  attr,
const char *  objectid,
bool ok,
const std::string &  defaultValue,
bool  report = true 
) const

Tries to read given attribute assuming it is a string.

If the attribute is not existing in the current element, the default value is returned. If an error occurs on parsing (the attribute is empty), "ok" is set to false. If report is true an error message is written to MsgHandler::getErrorInstance.

Otherwise, "ok" is not changed.

Parameters
[in]attrThe id of the attribute to read
[in]objectidThe name of the parsed object; used for error message generation
[out]okWhether the value could be read
[in]defaultValueThe value to return if the attribute is not within the element
[in]reportWhether errors shall be written to msg handler's error instance
Returns
The read value if given and not empty; the default value if the attribute does not exist; "" if an error occured

Definition at line 256 of file SUMOSAXAttributes.cpp.

References emitEmptyError(), getName(), getString(), and hasAttribute().

Referenced by NLDiscreteEventBuilder::addAction(), NIImporter_SUMO::addConnection(), NLHandler::addConnection(), NLHandler::addE2Detector(), NIImporter_SUMO::addEdge(), NIXMLEdgesHandler::addEdge(), NLHandler::addEdgeLaneMeanData(), NIImporter_SUMO::addLane(), NLHandler::addLane(), NIXMLEdgesHandler::addLane(), NIXMLNodesHandler::addNode(), NLHandler::addPOI(), NLHandler::addPoly(), NIImporter_SUMO::addProhibition(), NIXMLEdgesHandler::addSplit(), MSRouteHandler::addStop(), NIXMLTrafficLightsHandler::addTlConnection(), NLHandler::addWAUTJunction(), NLHandler::beginEdgeParsing(), NLDiscreteEventBuilder::buildSaveTLStateCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchesCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchStatesCommand(), SUMOSAXAttributesImpl_Xerces::getShapeReporting(), RORDLoader_TripDefs::getVehicleID(), NIImporter_SUMO::initTrafficLightLogic(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), NLHandler::initTrafficLightLogic(), GUISettingsHandler::myStartElement(), RODFDetectorHandler::myStartElement(), PCTypeDefHandler::myStartElement(), MSRouteHandler::myStartElement(), NIXMLConnectionsHandler::myStartElement(), NIXMLTypesHandler::myStartElement(), PCLoaderXML::myStartElement(), PCNetProjectionLoader::myStartElement(), NIImporter_MATSim::EdgesHandler::myStartElement(), SAXWeightsHandler::myStartElement(), NLHandler::openJunction(), MSRouteHandler::openRoute(), RORouteHandler::openRoute(), SUMOVehicleParserHelper::parseEmissionClass(), SUMOVehicleParserHelper::parseGuiShape(), RONetHandler::parseLane(), SUMOVehicleParserHelper::parseVehicleClass(), NIXMLNodesHandler::processTrafficLightDefinitions(), and NIXMLEdgesHandler::tryGetLaneSpread().

SUMOReal SUMOSAXAttributes::getOptSUMORealReporting ( int  attr,
const char *  objectid,
bool ok,
SUMOReal  defaultValue,
bool  report = true 
) const

Tries to read given attribute assuming it is a SUMOReal.

If the attribute is not existing in the current element, the default value is returned. If an error occurs on parsing (the attribute is empty, it is not numeric), "ok" is set to false. If report is true an error message is written to MsgHandler::getErrorInstance.

Otherwise, "ok" is not changed.

Parameters
[in]attrThe id of the attribute to read
[in]objectidThe name of the parsed object; used for error message generation
[out]okWhether the value could be read
[in]defaultValueThe value to return if the attribute is not within the element
[in]reportWhether errors shall be written to msg handler's error instance
Returns
The read value if given and correct; the default value if the attribute does not exist; -1 if an error occured

Definition at line 160 of file SUMOSAXAttributes.cpp.

References emitEmptyError(), emitFormatError(), getFloat(), getName(), hasAttribute(), and SUMOReal.

Referenced by NLHandler::addE2Detector(), NIImporter_SUMO::addEdge(), NIXMLEdgesHandler::addEdge(), NLHandler::addEdgeLaneMeanData(), NIImporter_SUMO::addLane(), NLHandler::addLane(), NLHandler::addPOI(), NLHandler::addPoly(), MSRouteHandler::addStop(), NLHandler::beginE3Detector(), GUISettingsHandler::myStartElement(), MSRouteHandler::myStartElement(), NIXMLTypesHandler::myStartElement(), PCLoaderXML::myStartElement(), MSLaneSpeedTrigger::myStartElement(), MSTriggeredRerouter::myStartElement(), MSRouteHandler::openRoute(), RORouteHandler::openRoute(), and RORDLoader_SUMOBase::startRoute().

SUMOTime SUMOSAXAttributes::getOptSUMOTimeReporting ( int  attr,
const char *  objectid,
bool ok,
SUMOTime  defaultValue,
bool  report = true 
) const

Tries to read given attribute assuming it is a SUMOTime.

If the attribute is not existing in the current element, the default value is returned. If an error occurs on parsing (the attribute is empty, it is not numeric), "ok" is set to false. If report is true an error message is written to MsgHandler::getErrorInstance.

Otherwise, "ok" is not changed.

In dependence to the used time representation, either getIntReporting or getSUMORealReporting is used.

Parameters
[in]attrThe id of the attribute to read
[in]objectidThe name of the parsed object; used for error message generation
[out]okWhether the value could be read
[in]defaultValueThe value to return if the attribute is not within the element
[in]reportWhether errors shall be written to msg handler's error instance
Returns
The read value if given and correct; the default value if the attribute does not exist; -1 if an error occured

Definition at line 304 of file SUMOSAXAttributes.cpp.

References emitEmptyError(), emitFormatError(), getFloat(), getName(), getOptIntReporting(), and hasAttribute().

Referenced by NLHandler::addE2Detector(), NLHandler::addEdgeLaneMeanData(), NLHandler::addPhase(), NLHandler::addRouteProbeDetector(), MSRouteHandler::addStop(), NLHandler::beginE3Detector(), NLHandler::initTrafficLightLogic(), GUISettingsHandler::myStartElement(), MSRouteHandler::myStartElement(), RORDGenerator_ODAmounts::myStartElement(), MSTriggeredRerouter::myStartElement(), NLHandler::openWAUT(), and RORDGenerator_ODAmounts::parseFlowAmountDef().

virtual PositionVector SUMOSAXAttributes::getShapeReporting ( int  attr,
const char *  objectid,
bool ok,
bool  allowEmpty 
) const
pure virtual

Tries to read given attribute assuming it is a PositionVector.

If an error occurs (the attribute is not there, it's empty), "ok" is set to false and an error message is written to MsgHandler::getErrorInstance.

Otherwise, "ok" is not changed.

Parameters
[in]attrThe id of the attribute to read
[in]objectidThe name of the parsed object; used for error message generation
[out]okWhether the value could be read
[in]reportWhether errors shall be written to msg handler's error instance
Returns
The read value if given and not empty; "" if an error occured

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

Referenced by NIImporter_SUMO::addEdge(), NIImporter_SUMO::addJunction(), NIImporter_SUMO::addLane(), NLHandler::addLane(), NLHandler::addPoly(), NIImporter_SUMO::loadLocation(), PCLoaderXML::myStartElement(), PCNetProjectionLoader::myStartElement(), NLHandler::openJunction(), NLHandler::setLocation(), and NIXMLEdgesHandler::tryGetShape().

virtual std::string SUMOSAXAttributes::getString ( int  id) const throw (EmptyData)
pure virtual

Returns the string-value of the named (by its enum-value) attribute.

Tries to retrieve the attribute from the the attribute list. The retrieved attribute (which may be 0) is then parsed using TplConvert<XMLCh>::_2str. If the attribute is ==0, TplConvert<XMLCh>::_2str throws an EmptyData-exception which is passed.

Parameters
[in]idThe id of the attribute to return the value of
Returns
The attribute's value as a string, if it could be read and parsed
Exceptions
EmptyDataIf the attribute is not known or the attribute value is an empty string

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

Referenced by NLHandler::addDistrict(), getOptStringReporting(), getStringReporting(), AGActivityGenHandler::parseBusLine(), AGActivityGenHandler::parseBusStation(), AGActivityGenHandler::parseCityGates(), RONetHandler::parseDistrict(), AGActivityGenHandler::parseSchool(), and AGActivityGenHandler::parseStreets().

std::string SUMOSAXAttributes::getStringReporting ( int  attr,
const char *  objectid,
bool ok,
bool  report = true 
) const

Tries to read given attribute assuming it is a string.

If an error occurs (the attribute is not there, it's empty), "ok" is set to false and an error message is written to MsgHandler::getErrorInstance.

Otherwise, "ok" is not changed.

Parameters
[in]attrThe id of the attribute to read
[in]objectidThe name of the parsed object; used for error message generation
[out]okWhether the value could be read
[in]reportWhether errors shall be written to msg handler's error instance
Returns
The read value if given and not empty; "" if an error occured

Definition at line 230 of file SUMOSAXAttributes.cpp.

References emitEmptyError(), emitUngivenError(), getName(), getString(), and hasAttribute().

Referenced by NIImporter_SUMO::addConnection(), NLHandler::addConnection(), NLHandler::addDistrict(), NLHandler::addDistrictEdge(), NLHandler::addE1Detector(), NLHandler::addE2Detector(), NLHandler::addE3Entry(), NLHandler::addE3Exit(), NIImporter_SUMO::addEdge(), NIXMLEdgesHandler::addEdge(), NLHandler::addEdgeLaneMeanData(), NLHandler::addInstantE1Detector(), NIXMLNodesHandler::addJoinCluster(), NIXMLNodesHandler::addJoinExclusion(), NIImporter_SUMO::addJunction(), NIImporter_SUMO::addLane(), NLHandler::addLane(), NIXMLNodesHandler::addNode(), NLHandler::addParam(), NIImporter_SUMO::addPhase(), NLHandler::addPhase(), NLHandler::addPOI(), NLHandler::addPoly(), NLHandler::addRequest(), NLHandler::addRouteProbeDetector(), ROJTRTurnDefLoader::addToEdge(), NLHandler::addVTypeProbeDetector(), NLHandler::addWAUTJunction(), NLHandler::addWAUTSwitch(), NLHandler::beginE3Detector(), NLHandler::beginEdgeParsing(), ROJTRTurnDefLoader::beginFromEdge(), SUMOVehicleParserHelper::beginVTypeParsing(), NLTriggerBuilder::buildVaporizer(), NIXMLEdgesHandler::deleteEdge(), NIXMLNodesHandler::deleteNode(), SUMOSAXAttributesImpl_Xerces::getBoundaryReporting(), RORDLoader_TripDefs::getEdge(), NLHandler::initJunctionLogic(), NIImporter_SUMO::initTrafficLightLogic(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), NLHandler::initTrafficLightLogic(), NIImporter_SUMO::loadLocation(), GUISettingsHandler::myStartElement(), RODFDetectorHandler::myStartElement(), PCTypeDefHandler::myStartElement(), NIXMLConnectionsHandler::myStartElement(), MSRouteHandler::myStartElement(), NIXMLTypesHandler::myStartElement(), RORouteHandler::myStartElement(), ROJTRTurnDefLoader::myStartElement(), PCLoaderXML::myStartElement(), NIImporter_MATSim::NodesHandler::myStartElement(), PCLoaderOSM::NodesHandler::myStartElement(), NIImporter_MATSim::EdgesHandler::myStartElement(), PCLoaderOSM::EdgesHandler::myStartElement(), NIImporter_OpenStreetMap::NodesHandler::myStartElement(), NIImporter_OpenStreetMap::EdgesHandler::myStartElement(), NIImporter_OpenDrive::myStartElement(), ODDistrictHandler::openDistrict(), NLHandler::openJunction(), MSRouteHandler::openRoute(), RORouteHandler::openRoute(), MSRouteHandler::openRouteDistribution(), RORouteHandler::openRouteDistribution(), MSRouteHandler::openVehicleTypeDistribution(), RORouteHandler::openVehicleTypeDistribution(), NLHandler::openWAUT(), SUMOVehicleParserHelper::parseCommonAttributes(), RONetHandler::parseConnection(), ODDistrictHandler::parseConnection(), NIXMLConnectionsHandler::parseDeprecatedLaneDefinition(), RONetHandler::parseDistrict(), RONetHandler::parseDistrictEdge(), RONetHandler::parseEdge(), SUMOVehicleParserHelper::parseFlowAttributes(), RONetHandler::parseJunction(), RONetHandler::parseLane(), SUMOVehicleParserHelper::parseVehicleAttributes(), NIXMLTrafficLightsHandler::removeTlConnection(), NIXMLTrafficLightsHandler::retrieveEdge(), NLHandler::setLocation(), NIXMLEdgesHandler::setNodes(), RORDLoader_SUMOBase::startAlternative(), and RORDLoader_SUMOBase::startRoute().

virtual std::string SUMOSAXAttributes::getStringSecure ( int  id,
const std::string &  def 
) const throw (EmptyData)
pure virtual

Returns the string-value of the named (by its enum-value) attribute.

Tries to retrieve the attribute from the the attribute list. The retrieved attribute (which may be 0) is then parsed using TplConvert<XMLCh>::_2strSec. If the attribute is ==0, TplConvert<XMLCh>::_2strSec returns the default value.

Parameters
[in]idThe id of the attribute to return the value of
[in]defThe default value to return if the attribute is not in attributes
Returns
The attribute's value as a string, if it could be read and parsed
Exceptions
EmptyDataIf the attribute is not known or the attribute value is an empty string

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

Referenced by NIXMLEdgesHandler::addEdge(), NLHandler::addVTypeProbeDetector(), GUISettingsHandler::myStartElement(), MSTriggeredRerouter::myStartElement(), NIImporter_OpenStreetMap::NodesHandler::myStartElement(), NIImporter_OpenStreetMap::EdgesHandler::myStartElement(), NLHandler::openJunction(), and GUISettingsHandler::parseTextSettings().

virtual std::string SUMOSAXAttributes::getStringSecure ( const std::string &  id,
const std::string &  def 
) const
pure virtual

Returns the string-value of the named (by its enum-value) attribute.

Tries to retrieve the attribute from the the attribute list. If the attribute is ==0, TplConvert<XMLCh>::_2strSec returns the default value.

Parameters
[in]idThe name of the attribute to return the value of
[in]defThe default value to return if the attribute is not in attributes
Returns
The attribute's value as a string, if it could be read and parsed

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

SUMOReal SUMOSAXAttributes::getSUMORealReporting ( int  attr,
const char *  objectid,
bool ok,
bool  report = true 
) const

Tries to read given attribute assuming it is a SUMOReal.

If an error occurs (the attribute is not there, it is not numeric), "ok" is set to false and an error message is written to MsgHandler::getErrorInstance.

Otherwise, "ok" is not changed.

Parameters
[in]attrThe id of the attribute to read
[in]objectidThe name of the parsed object; used for error message generation
[out]okWhether the value could be read
[in]reportWhether errors shall be written to msg handler's error instance
Returns
The read value if given and correct; -1 if an error occured

Definition at line 134 of file SUMOSAXAttributes.cpp.

References emitEmptyError(), emitFormatError(), emitUngivenError(), getFloat(), getName(), hasAttribute(), and SUMOReal.

Referenced by NLHandler::addE1Detector(), NLHandler::addE2Detector(), NLHandler::addE3Entry(), NLHandler::addE3Exit(), NIXMLEdgesHandler::addEdge(), NLHandler::addInstantE1Detector(), NIImporter_SUMO::addLane(), NLHandler::addLane(), NIXMLEdgesHandler::addLane(), NIXMLNodesHandler::addNode(), NIImporter_SUMO::addPhase(), NIXMLEdgesHandler::addSplit(), ROJTRTurnDefLoader::addToEdge(), SUMOVehicleParserHelper::beginVTypeParsing(), NIImporter_SUMO::initTrafficLightLogic(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), GUISettingsHandler::myStartElement(), RODFDetectorHandler::myStartElement(), PCLoaderXML::myStartElement(), NIImporter_MATSim::NodesHandler::myStartElement(), PCLoaderOSM::NodesHandler::myStartElement(), NIImporter_MATSim::EdgesHandler::myStartElement(), SAXWeightsHandler::myStartElement(), NIImporter_OpenDrive::myStartElement(), NLHandler::openJunction(), ODDistrictHandler::parseConnection(), SUMOVehicleParserHelper::parseFlowAttributes(), RONetHandler::parseJunction(), RONetHandler::parseLane(), SUMOVehicleParserHelper::parseVehicleAttributes(), SUMOVehicleParserHelper::parseVTypeEmbedded(), NIImporter_SUMO::readPosition(), and RORDLoader_SUMOBase::startRoute().

SUMOTime SUMOSAXAttributes::getSUMOTimeReporting ( int  attr,
const char *  objectid,
bool ok,
bool  report = true 
) const

Tries to read given attribute assuming it is a SUMOTime.

If an error occurs (the attribute is not there, it is not numeric), "ok" is set to false and an error message is written to MsgHandler::getErrorInstance.

Otherwise, "ok" is not changed.

In dependence to the used time representation, either getIntReporting or getSUMORealReporting is used.

Parameters
[in]attrThe id of the attribute to read
[in]objectidThe name of the parsed object; used for error message generation
[out]okWhether the value could be read
[in]reportWhether errors shall be written to msg handler's error instance
Returns
The read value if given and correct; -1 if an error occured

Definition at line 274 of file SUMOSAXAttributes.cpp.

References emitEmptyError(), emitFormatError(), emitUngivenError(), getFloat(), getIntReporting(), getName(), and hasAttribute().

Referenced by NLHandler::addE1Detector(), NLHandler::addE2Detector(), NLHandler::addPhase(), NLHandler::addRouteProbeDetector(), NLHandler::addVTypeProbeDetector(), NLHandler::addWAUTSwitch(), NLHandler::beginE3Detector(), NLTriggerBuilder::buildVaporizer(), RORDLoader_TripDefs::myStartElement(), ROJTRTurnDefLoader::myStartElement(), MSLaneSpeedTrigger::myStartElement(), SUMOVehicleParserHelper::parseFlowAttributes(), and SUMOVehicleParserHelper::parseVehicleAttributes().

virtual bool SUMOSAXAttributes::hasAttribute ( int  id) const
pure virtual

Returns the information whether the named (by its enum-value) attribute is within the current list.

Parameters
[in]idThe id of the attribute to search for
Returns
Whether the attribute is within the attributes

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

Referenced by NLHandler::addDistrict(), NIXMLEdgesHandler::addEdge(), NIImporter_SUMO::addJunction(), NIXMLEdgesHandler::addLane(), NIXMLNodesHandler::addNode(), NLHandler::addPOI(), MSRouteHandler::addStop(), SUMOVehicleParserHelper::beginVTypeParsing(), getBoolReporting(), getIntReporting(), getLongReporting(), getOptBoolReporting(), getOptIntReporting(), getOptStringReporting(), getOptSUMORealReporting(), getOptSUMOTimeReporting(), getStringReporting(), getSUMORealReporting(), getSUMOTimeReporting(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), NIXMLConnectionsHandler::myStartElement(), MSRouteHandler::myStartElement(), RORouteHandler::myStartElement(), ROJTRTurnDefLoader::myStartElement(), PCLoaderXML::myStartElement(), NIImporter_MATSim::EdgesHandler::myStartElement(), NIImporter_OpenStreetMap::NodesHandler::myStartElement(), NIImporter_OpenStreetMap::EdgesHandler::myStartElement(), NIImporter_OpenDrive::myStartElement(), NLHandler::openJunction(), MSRouteHandler::openRoute(), RORouteHandler::openRoute(), MSRouteHandler::openRouteDistribution(), RORouteHandler::openRouteDistribution(), MSRouteHandler::openVehicleTypeDistribution(), RORouteHandler::openVehicleTypeDistribution(), SUMOVehicleParserHelper::parseCommonAttributes(), RONetHandler::parseDistrict(), RONetHandler::parseEdge(), SUMOVehicleParserHelper::parseFlowAttributes(), NIXMLConnectionsHandler::parseLaneInfo(), AGActivityGenHandler::parseStreets(), SUMOVehicleParserHelper::parseVehicleAttributes(), SUMOVehicleParserHelper::parseVTypeEmbedded(), NIImporter_SUMO::readPosition(), NIXMLEdgesHandler::setNodes(), RORDLoader_SUMOBase::startRoute(), NIXMLEdgesHandler::tryGetShape(), and SAXWeightsHandler::tryParse().

virtual bool SUMOSAXAttributes::hasAttribute ( const std::string &  id) const
pure virtual

Returns the information whether the named attribute is within the current list.

Parameters
[in]idThe name of the attribute to search for
Returns
Whether the named attribute is within the attributes

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

SUMOSAXAttributes& SUMOSAXAttributes::operator= ( const SUMOSAXAttributes src)
private

Invalidated assignment operator.

void SUMOSAXAttributes::parseStringVector ( const std::string &  def,
std::vector< std::string > &  into 
)
static

Splits the given string.

Spaces, ",", and ";" are assumed to be separator characters. Though, in the case a "," or a ";" occurs, a warning is generated (once).

Parameters
[in]defThe string to split
[out]intoThe vector to fill

Definition at line 381 of file SUMOSAXAttributes.cpp.

References StringTokenizer::hasNext(), myHaveInformedAboutDeprecatedDivider, StringTokenizer::next(), and WRITE_WARNING.

Referenced by NIXMLEdgesHandler::addSplit(), NLTriggerBuilder::parseAndBuildBusStop(), NLTriggerBuilder::parseAndBuildLaneSpeedTrigger(), NLTriggerBuilder::parseAndBuildRerouter(), and NIXMLNodesHandler::processTrafficLightDefinitions().

virtual void SUMOSAXAttributes::serialize ( std::ostream &  os) const
pure virtual

Prints all attribute names and values into the given stream.

Parameters
[in]osThe stream to use

Implemented in SUMOSAXAttributesImpl_Binary, and SUMOSAXAttributesImpl_Xerces.

Referenced by operator<<().

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const SUMOSAXAttributes src 
)
friend

Definition at line 619 of file SUMOSAXAttributes.h.

Field Documentation

bool SUMOSAXAttributes::myHaveInformedAboutDeprecatedDivider = false
staticprivate

Information whether the usage of a deprecated divider was reported.

Definition at line 604 of file SUMOSAXAttributes.h.

Referenced by parseStringVector().

std::string SUMOSAXAttributes::myObjectType
private

the object type to use in error reporting

Definition at line 614 of file SUMOSAXAttributes.h.

Referenced by emitEmptyError(), emitFormatError(), emitUngivenError(), and getObjectType().


The documentation for this class was generated from the following files: