Eclipse SUMO - Simulation of Urban MObility
SUMOSAXAttributesImpl_Binary Class Reference

Encapsulated Xerces-SAX-attributes. More...

#include <SUMOSAXAttributesImpl_Binary.h>

Inheritance diagram for SUMOSAXAttributesImpl_Binary:
Collaboration diagram for SUMOSAXAttributesImpl_Binary:

Public Member Functions

template<typename T >
get (int attr, const char *objectid, bool &ok, bool report=true) const
 Tries to read given attribute assuming it is an int. More...
 
template<>
std::string getInternal (const int attr) const
 
template<typename T >
getOpt (int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
 Tries to read given attribute assuming it is an int. 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...
 
SUMOTime getSUMOTimeReporting (int attr, const char *objectid, bool &ok, bool report=true) const
 Tries to read given attribute assuming it is a SUMOTime. More...
 
 SUMOSAXAttributesImpl_Binary (const std::map< int, std::string > &predefinedTagsMML, const std::string &objectType, BinaryInputDevice *in, const char version)
 Constructor. More...
 
virtual ~SUMOSAXAttributesImpl_Binary ()
 Destructor. More...
 

virtual methods for retrieving attribute values

std::string myObjectType
 the object type to use in error reporting More...
 
const std::vector< std::string > getStringVector (int attr) const
 Tries to read given attribute assuming it is a string vector. More...
 
const std::vector< std::string > getOptStringVector (int attr, const char *objectid, bool &ok, bool report=true) const
 convenience function to avoid the default argument and the template stuff at getOpt<> More...
 
const std::vector< int > getIntVector (int attr) const
 Tries to read given attribute assuming it is an int vector. More...
 
const std::vector< int > getOptIntVector (int attr, const char *objectid, bool &ok, bool report=true) const
 convenience function to avoid the default argument and the template stuff at getOpt<> More...
 
const std::string & getObjectType () const
 return the objecttype to which these attributes belong More...
 
static const std::string ENCODING = " encoding=\"UTF-8\""
 The encoding of parsed strings. More...
 
template<typename T >
getInternal (const int attr) const
 
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
 

methods for retrieving attribute values

const std::map< int, std::string > & myAttrIds
 Map of attribute ids to names. More...
 
std::set< int > myAttrs
 the attributes which are set More...
 
std::map< int, char > myCharValues
 Map of attribute ids to char. More...
 
std::map< int, int > myIntValues
 Map of attribute ids to integers. More...
 
std::map< int, double > myFloatValues
 Map of attribute ids to floats. More...
 
std::map< int, std::string > myStringValues
 Map of attribute ids to string. More...
 
std::map< int, PositionVectormyPositionVectors
 Map of attribute ids to string. More...
 
bool hasAttribute (int id) const
 Returns the information whether the named (by its enum-value) attribute is within the current list. More...
 
bool getBool (int id) const
 Returns the bool-value of the named (by its enum-value) attribute. More...
 
int getInt (int id) const
 Returns the int-value of the named (by its enum-value) attribute. More...
 
long long int getLong (int id) const
 Returns the long-value of the named (by its enum-value) attribute. More...
 
std::string getString (int id) const
 Returns the string-value of the named (by its enum-value) attribute. More...
 
std::string getStringSecure (int id, const std::string &def) const
 Returns the string-value of the named (by its enum-value) attribute. More...
 
double getFloat (int id) const
 Returns the double-value of the named (by its enum-value) attribute. More...
 
bool hasAttribute (const std::string &id) const
 Returns the information whether the named attribute is within the current list. More...
 
double getFloat (const std::string &id) const
 Returns the double-value of the named attribute. More...
 
std::string getStringSecure (const std::string &id, const std::string &def) const
 Returns the string-value of the named (by its enum-value) attribute. More...
 
SumoXMLEdgeFunc getEdgeFunc (bool &ok) const
 Returns the value of the named attribute. More...
 
SumoXMLNodeType getNodeType (bool &ok) const
 Returns the value of the named attribute. More...
 
RightOfWay getRightOfWay (bool &ok) const
 returns rightOfWay method More...
 
FringeType getFringeType (bool &ok) const
 returns fringe type More...
 
RGBColor getColor () const
 Returns the value of the named attribute. More...
 
PositionVector getShape (int attr) const
 Tries to read given attribute assuming it is a PositionVector. More...
 
Boundary getBoundary (int attr) const
 Tries to read given attribute assuming it is a Boundary. More...
 
std::string getName (int attr) const
 Converts the given attribute id into a man readable string. More...
 
void serialize (std::ostream &os) const
 Prints all attribute names and values into the given stream. More...
 
std::vector< std::string > getAttributeNames () const
 Retrieves all attribute names. More...
 
SUMOSAXAttributesclone () const
 return a new deep-copy attributes object More...
 
 SUMOSAXAttributesImpl_Binary (const SUMOSAXAttributesImpl_Binary &src)
 Invalidated copy constructor. More...
 
SUMOSAXAttributesImpl_Binaryoperator= (const SUMOSAXAttributesImpl_Binary &src)
 Invalidated assignment operator. More...
 

Detailed Description

Encapsulated Xerces-SAX-attributes.

See also
SUMOSAXAttributes

Definition at line 47 of file SUMOSAXAttributesImpl_Binary.h.

Constructor & Destructor Documentation

◆ SUMOSAXAttributesImpl_Binary() [1/2]

SUMOSAXAttributesImpl_Binary::SUMOSAXAttributesImpl_Binary ( const std::map< int, std::string > &  predefinedTagsMML,
const std::string &  objectType,
BinaryInputDevice in,
const char  version 
)

◆ ~SUMOSAXAttributesImpl_Binary()

SUMOSAXAttributesImpl_Binary::~SUMOSAXAttributesImpl_Binary ( )
virtual

Destructor.

Definition at line 154 of file SUMOSAXAttributesImpl_Binary.cpp.

◆ SUMOSAXAttributesImpl_Binary() [2/2]

SUMOSAXAttributesImpl_Binary::SUMOSAXAttributesImpl_Binary ( const SUMOSAXAttributesImpl_Binary src)
private

Invalidated copy constructor.

Member Function Documentation

◆ clone()

SUMOSAXAttributes * SUMOSAXAttributesImpl_Binary::clone ( ) const
virtual

return a new deep-copy attributes object

Implements SUMOSAXAttributes.

Definition at line 356 of file SUMOSAXAttributesImpl_Binary.cpp.

References SUMOSAXAttributes::getObjectType(), myAttrIds, myCharValues, myFloatValues, myIntValues, myPositionVectors, myStringValues, and toString().

◆ emitEmptyError()

void SUMOSAXAttributes::emitEmptyError ( const std::string &  attrname,
const char *  objectid 
) const
protectedinherited

◆ emitFormatError()

void SUMOSAXAttributes::emitFormatError ( const std::string &  attrname,
const std::string &  type,
const char *  objectid 
) const
protectedinherited

◆ emitUngivenError()

void SUMOSAXAttributes::emitUngivenError ( const std::string &  attrname,
const char *  objectid 
) const
protectedinherited

◆ get()

template<typename T >
T SUMOSAXAttributes::get ( int  attr,
const char *  objectid,
bool &  ok,
bool  report = true 
) const
inherited

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 occurred

Definition at line 492 of file SUMOSAXAttributes.h.

References SUMOSAXAttributes::emitEmptyError(), SUMOSAXAttributes::emitFormatError(), SUMOSAXAttributes::emitUngivenError(), SUMOSAXAttributes::getName(), and SUMOSAXAttributes::hasAttribute().

Referenced by NIXMLPTHandler::addAccess(), NIImporter_SUMO::addConnection(), NLHandler::addConnection(), NIXMLConnectionsHandler::addCrossing(), 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(), NIXMLEdgesHandler::addLane(), NLHandler::addLane(), NIXMLNodesHandler::addNode(), NLHandler::addParam(), RONetHandler::addParam(), SUMORouteHandler::addParam(), RORouteHandler::addPersonTrip(), NLHandler::addPhase(), NIImporter_SUMO::addPhase(), ShapeHandler::addPOI(), ShapeHandler::addPoly(), NIXMLPTHandler::addPTLine(), NIXMLPTHandler::addPTLineStop(), NIXMLPTHandler::addPTStop(), NIImporter_SUMO::addRequest(), NLHandler::addRequest(), NLHandler::addRouteProbeDetector(), NIXMLEdgesHandler::addSplit(), ROJTRTurnDefLoader::addToEdge(), NLHandler::addVTypeProbeDetector(), MSRouteHandler::addWalk(), RORouteHandler::addWalk(), NIXMLConnectionsHandler::addWalkingArea(), NLHandler::addWAUTJunction(), NLHandler::addWAUTSwitch(), NLHandler::beginE3Detector(), NLHandler::beginEdgeParsing(), ROJTRTurnDefLoader::beginFromEdge(), SUMOVehicleParserHelper::beginVTypeParsing(), NLTriggerBuilder::buildVaporizer(), NIXMLEdgesHandler::deleteEdge(), NIXMLNodesHandler::deleteNode(), NLTriggerBuilder::getLane(), NLTriggerBuilder::getPosition(), NLHandler::initJunctionLogic(), NLHandler::initTrafficLightLogic(), NIImporter_SUMO::initTrafficLightLogic(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), NIImporter_SUMO::loadLocation(), RODFDetectorHandler::myStartElement(), ROJTRTurnDefLoader::myStartElement(), MSRouteHandler::myStartElement(), MSStateHandler::myStartElement(), NIImporter_MATSim::NodesHandler::myStartElement(), NIImporter_MATSim::EdgesHandler::myStartElement(), NIImporter_OpenDrive::myStartElement(), NIImporter_SUMO::myStartElement(), NIXMLConnectionsHandler::myStartElement(), NIXMLEdgesHandler::myStartElement(), NIXMLNodesHandler::myStartElement(), NIXMLPTHandler::myStartElement(), NIXMLTrafficLightsHandler::myStartElement(), NIXMLTypesHandler::myStartElement(), NIImporter_Vissim::NIVissimXMLHandler_Streckendefinition::myStartElement(), NIImporter_Vissim::NIVissimXMLHandler_Zuflussdefinition::myStartElement(), NIImporter_Vissim::NIVissimXMLHandler_Parkplatzdefinition::myStartElement(), NIImporter_Vissim::NIVissimXMLHandler_Fahrzeugklassendefinition::myStartElement(), NIImporter_Vissim::NIVissimXMLHandler_VWunschentscheidungsdefinition::myStartElement(), NIImporter_Vissim::NIVissimXMLHandler_Geschwindigkeitsverteilungsdefinition::myStartElement(), NIImporter_Vissim::NIVissimXMLHandler_Routenentscheidungsdefinition::myStartElement(), NIImporter_Vissim::NIVissimXMLHandler_ConflictArea::myStartElement(), NLHandler::myStartElement(), ODAmitranHandler::myStartElement(), PCLoaderOSM::NodesHandler::myStartElement(), PCLoaderOSM::RelationsHandler::myStartElement(), PCLoaderOSM::EdgesHandler::myStartElement(), PCLoaderXML::myStartElement(), PCNetProjectionLoader::myStartElement(), PCTypeDefHandler::myStartElement(), RONetHandler::myStartElement(), RORouteHandler::myStartElement(), TrajectoriesHandler::myStartElement(), GUISettingsHandler::myStartElement(), ShapeHandler::myStartElement(), NIImporter_OpenStreetMap::NodesHandler::myStartElement(), NIImporter_OpenStreetMap::EdgesHandler::myStartElement(), NIImporter_OpenStreetMap::RelationHandler::myStartElement(), ODDistrictHandler::openDistrict(), NLHandler::openJunction(), MSRouteHandler::openRoute(), RORouteHandler::openRoute(), MSRouteHandler::openRouteDistribution(), RORouteHandler::openRouteDistribution(), MSRouteHandler::openVehicleTypeDistribution(), RORouteHandler::openVehicleTypeDistribution(), NLHandler::openWAUT(), RONetHandler::parseAccess(), NLTriggerBuilder::parseAndAddLotEntry(), NLTriggerBuilder::parseAndBeginParkingArea(), GNEAdditionalHandler::parseAndBuildAccess(), NLTriggerBuilder::parseAndBuildCalibrator(), GNEAdditionalHandler::parseAndBuildCalibratorFlow(), NLTriggerBuilder::parseAndBuildChargingStation(), GNEAdditionalHandler::parseAndBuildDetectorEntry(), GNEAdditionalHandler::parseAndBuildDetectorExit(), NLTriggerBuilder::parseAndBuildLaneSpeedTrigger(), GNEAdditionalHandler::parseAndBuildParkingSpace(), NLTriggerBuilder::parseAndBuildRerouter(), GNEAdditionalHandler::parseAndBuildRerouterClosingLaneReroute(), GNEAdditionalHandler::parseAndBuildRerouterClosingReroute(), GNEAdditionalHandler::parseAndBuildRerouterDestProbReroute(), GNEAdditionalHandler::parseAndBuildRerouterInterval(), GNEAdditionalHandler::parseAndBuildRerouterParkingAreaReroute(), GNEAdditionalHandler::parseAndBuildRerouterRouteProbReroute(), NLTriggerBuilder::parseAndBuildStoppingPlace(), GNEAdditionalHandler::parseAndBuildTAZ(), GNEAdditionalHandler::parseAndBuildTAZSink(), GNEAdditionalHandler::parseAndBuildTAZSource(), GNEAdditionalHandler::parseAndBuildVariableSpeedSignStep(), GNEAttributeCarrier::parseAttributeFromXML(), SUMOVehicleParserHelper::parseCommonAttributes(), RONetHandler::parseConnection(), NIXMLConnectionsHandler::parseDeprecatedLaneDefinition(), RONetHandler::parseDistrict(), RONetHandler::parseDistrictEdge(), RONetHandler::parseEdge(), SUMOVehicleParserHelper::parseFlowAttributes(), RORouteHandler::parseFromViaTo(), SUMOVehicleParserHelper::parseID(), SUMOVehicleParserHelper::parseJMParams(), RONetHandler::parseJunction(), RONetHandler::parseLane(), NIXMLConnectionsHandler::parseLaneDefinition(), SUMOVehicleParserHelper::parseLCParams(), GNEAttributeCarrier::parseMaskedPositionAttribute(), GNEAdditionalHandler::parseParameter(), AGActivityGenHandler::parseStation(), SUMORouteHandler::parseStop(), parseStopOffsets(), RONetHandler::parseStoppingPlace(), ODDistrictHandler::parseTAZ(), SUMOVehicleParserHelper::parseVehicleAttributes(), SUMOVehicleParserHelper::parseVTypeEmbedded(), MSRouteHandler::parseWalkPositions(), NIXMLNodesHandler::processNodeType(), NIImporter_SUMO::readPosition(), NIXMLTrafficLightsHandler::removeTlConnection(), NIXMLTrafficLightsHandler::retrieveEdge(), NIXMLTrafficLightsHandler::retrieveLaneIndex(), NLHandler::setLocation(), RONetHandler::setLocation(), and NIXMLEdgesHandler::setNodes().

◆ getAttributeNames()

std::vector< std::string > SUMOSAXAttributesImpl_Binary::getAttributeNames ( ) const
virtual

Retrieves all attribute names.

Implements SUMOSAXAttributes.

Definition at line 346 of file SUMOSAXAttributesImpl_Binary.cpp.

References getName(), and myAttrs.

◆ getBool()

bool SUMOSAXAttributesImpl_Binary::getBool ( int  id) const
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

Implements SUMOSAXAttributes.

Definition at line 165 of file SUMOSAXAttributesImpl_Binary.cpp.

References myCharValues.

◆ getBoundary()

Boundary SUMOSAXAttributesImpl_Binary::getBoundary ( int  attr) const
virtual

Tries to read given attribute assuming it is a Boundary.

Parameters
[in]attrThe id of the attribute to read
Returns
The read value if given and not empty; "" if an error occurred

Implements SUMOSAXAttributes.

Definition at line 316 of file SUMOSAXAttributesImpl_Binary.cpp.

References myPositionVectors.

◆ getColor()

RGBColor SUMOSAXAttributesImpl_Binary::getColor ( ) const
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 RGBColor, if it could be read and parsed

Implements SUMOSAXAttributes.

Definition at line 295 of file SUMOSAXAttributesImpl_Binary.cpp.

References myIntValues, and SUMO_ATTR_COLOR.

◆ getEdgeFunc()

SumoXMLEdgeFunc SUMOSAXAttributesImpl_Binary::getEdgeFunc ( bool &  ok) const
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

Implements SUMOSAXAttributes.

Definition at line 241 of file SUMOSAXAttributesImpl_Binary.cpp.

References EDGEFUNC_NORMAL, SUMOXMLDefinitions::EdgeFunctions, myCharValues, and SUMO_ATTR_FUNCTION.

◆ getFloat() [1/2]

double SUMOSAXAttributesImpl_Binary::getFloat ( const std::string &  id) const
virtual

Returns the double-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>::_2double. If the attribute is empty or ==0, TplConvert<XMLCh>::_2double throws an EmptyData-exception which is passed. If the value can not be parsed to a double, TplConvert<XMLCh>::_2double 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 double

Implements SUMOSAXAttributes.

Definition at line 222 of file SUMOSAXAttributesImpl_Binary.cpp.

◆ getFloat() [2/2]

double SUMOSAXAttributesImpl_Binary::getFloat ( int  id) const
virtual

Returns the double-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>::_2double. If the attribute is empty or ==0, TplConvert<XMLCh>::_2double throws an EmptyData-exception which is passed. If the value can not be parsed to a double, TplConvert<XMLCh>::_2double 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 double

Implements SUMOSAXAttributes.

Definition at line 212 of file SUMOSAXAttributesImpl_Binary.cpp.

References getString(), myFloatValues, and StringUtils::toDouble().

◆ getFringeType()

FringeType SUMOSAXAttributesImpl_Binary::getFringeType ( bool &  ok) const
virtual

◆ getInt()

int SUMOSAXAttributesImpl_Binary::getInt ( int  id) const
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

Implements SUMOSAXAttributes.

Definition at line 175 of file SUMOSAXAttributesImpl_Binary.cpp.

References myIntValues.

◆ getInternal() [1/2]

template<>
std::vector< int > SUMOSAXAttributes::getInternal ( const int  attr) const
inherited

Definition at line 53 of file SUMOSAXAttributes.cpp.

References SUMOSAXAttributes::getString().

◆ getInternal() [2/2]

template<typename T >
T SUMOSAXAttributes::getInternal ( const int  attr) const
protectedinherited

◆ getIntVector()

const std::vector< int > SUMOSAXAttributes::getIntVector ( int  attr) const
inherited

Tries to read given attribute assuming it is an int vector.

The behavior is similar to Python's string.split(), so multiple consecutive whitespace do not generate empty strings and leading and trailing whitespace is silently omitted.

Parameters
[in]attrThe id of the attribute to read
Returns
The read value if given and not empty; empty vector if an error occurred

Definition at line 128 of file SUMOSAXAttributes.cpp.

References SUMOSAXAttributes::getString(), StringTokenizer::getVector(), and StringUtils::toInt().

◆ getLong()

long long int SUMOSAXAttributesImpl_Binary::getLong ( int  id) const
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

Implements SUMOSAXAttributes.

Definition at line 185 of file SUMOSAXAttributesImpl_Binary.cpp.

References getString(), and StringUtils::toLong().

◆ getName()

std::string SUMOSAXAttributesImpl_Binary::getName ( int  attr) const
virtual

Converts the given attribute id into a man readable string.

Returns a "?" if the attribute is not known.

Parameters
[in]attrThe id of the attribute to return the name of
Returns
The name of the described attribute

Implements SUMOSAXAttributes.

Definition at line 329 of file SUMOSAXAttributesImpl_Binary.cpp.

References myAttrIds.

Referenced by getAttributeNames(), and serialize().

◆ getNodeType()

SumoXMLNodeType SUMOSAXAttributesImpl_Binary::getNodeType ( bool &  ok) const
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

Implements SUMOSAXAttributes.

Definition at line 255 of file SUMOSAXAttributesImpl_Binary.cpp.

References myCharValues, NODETYPE_UNKNOWN, SUMOXMLDefinitions::NodeTypes, and SUMO_ATTR_TYPE.

◆ getObjectType()

const std::string& SUMOSAXAttributes::getObjectType ( ) const
inlineinherited

◆ getOpt()

template<typename T >
T SUMOSAXAttributes::getOpt ( int  attr,
const char *  objectid,
bool &  ok,
defaultValue,
bool  report = true 
) const
inherited

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 occurred

Definition at line 518 of file SUMOSAXAttributes.h.

References SUMOSAXAttributes::emitEmptyError(), SUMOSAXAttributes::emitFormatError(), SUMOSAXAttributes::getName(), and SUMOSAXAttributes::hasAttribute().

Referenced by NIXMLPTHandler::addAccess(), NLTriggerBuilder::addAccess(), NLDiscreteEventBuilder::addAction(), NIImporter_SUMO::addConnection(), NLHandler::addConnection(), NIXMLConnectionsHandler::addCrossing(), NLHandler::addDistrict(), NLHandler::addE1Detector(), NLHandler::addE2Detector(), NLHandler::addE3Entry(), NLHandler::addE3Exit(), NIImporter_SUMO::addEdge(), NIXMLEdgesHandler::addEdge(), NLHandler::addEdgeLaneMeanData(), NLHandler::addInstantE1Detector(), NIXMLNodesHandler::addJoinCluster(), NIImporter_SUMO::addJunction(), NIImporter_SUMO::addLane(), NIXMLEdgesHandler::addLane(), NLHandler::addLane(), MSRouteHandler::addPersonTrip(), RORouteHandler::addPersonTrip(), NLHandler::addPhase(), NIImporter_SUMO::addPhase(), ShapeHandler::addPOI(), ShapeHandler::addPoly(), NIImporter_SUMO::addProhibition(), NIXMLPTHandler::addPTLine(), NIXMLPTHandler::addPTStop(), NLHandler::addRequest(), NLHandler::addRouteProbeDetector(), NIXMLEdgesHandler::addSplit(), MSRouteHandler::addStop(), GNERouteHandler::addStop(), RORouteHandler::addStop(), NIXMLTrafficLightsHandler::addTlConnection(), MSRouteHandler::addWalk(), RORouteHandler::addWalk(), NIXMLConnectionsHandler::addWalkingArea(), NLHandler::addWAUTJunction(), NLHandler::beginE3Detector(), NLHandler::beginEdgeParsing(), SUMOVehicleParserHelper::beginVTypeParsing(), NLDiscreteEventBuilder::buildSaveTLSProgramCommand(), NLDiscreteEventBuilder::buildSaveTLStateCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchesCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchStatesCommand(), NIXMLEdgesHandler::deleteEdge(), NLTriggerBuilder::getFileName(), NLTriggerBuilder::getPosition(), NLHandler::initTrafficLightLogic(), NIImporter_SUMO::initTrafficLightLogic(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), RODFDetectorHandler::myStartElement(), MSRouteHandler::myStartElement(), MSStateHandler::myStartElement(), MSCalibrator::myStartElement(), MSLaneSpeedTrigger::myStartElement(), MSTriggeredRerouter::myStartElement(), NIImporter_MATSim::EdgesHandler::myStartElement(), NIImporter_OpenDrive::myStartElement(), NIImporter_SUMO::myStartElement(), NIXMLConnectionsHandler::myStartElement(), NIXMLTypesHandler::myStartElement(), NLHandler::myStartElement(), PCLoaderOSM::NodesHandler::myStartElement(), PCLoaderOSM::RelationsHandler::myStartElement(), PCLoaderOSM::EdgesHandler::myStartElement(), PCLoaderXML::myStartElement(), PCTypeDefHandler::myStartElement(), RORouteHandler::myStartElement(), TrajectoriesHandler::myStartElement(), GUISettingsHandler::myStartElement(), SAXWeightsHandler::myStartElement(), NLHandler::openJunction(), MSRouteHandler::openRoute(), RORouteHandler::openRoute(), RORouteHandler::openRouteDistribution(), RONetHandler::parseAccess(), NLTriggerBuilder::parseAndAddLotEntry(), NLTriggerBuilder::parseAndBeginParkingArea(), NLTriggerBuilder::parseAndBuildCalibrator(), NLTriggerBuilder::parseAndBuildChargingStation(), GNEAdditionalHandler::parseAndBuildPoly(), GNEAdditionalHandler::parseAndBuildRerouter(), NLTriggerBuilder::parseAndBuildRerouter(), NLTriggerBuilder::parseAndBuildStoppingPlace(), SUMOVehicleParserHelper::parseCommonAttributes(), RONetHandler::parseConnection(), RONetHandler::parseEdge(), MSRouteHandler::parseFromViaTo(), RORouteHandler::parseFromViaTo(), AGActivityGenHandler::parseGeneralCityInfo(), SUMOVehicleParserHelper::parseGuiShape(), RONetHandler::parseJunction(), RONetHandler::parseLane(), NIXMLConnectionsHandler::parseLaneBound(), AGActivityGenHandler::parseParameters(), SUMORouteHandler::parseStop(), parseStopOffsets(), RONetHandler::parseStoppingPlace(), SUMOVehicleParserHelper::parseVehicleAttributes(), SUMOVehicleParserHelper::parseVehicleClass(), MSRouteHandler::parseWalkPositions(), NIXMLNodesHandler::processNodeType(), NIXMLNodesHandler::processTrafficLightDefinitions(), NIImporter_SUMO::readPosition(), NIXMLEdgesHandler::tryGetLaneSpread(), and NIXMLEdgesHandler::tryGetShape().

◆ getOptIntVector()

const std::vector< int > SUMOSAXAttributes::getOptIntVector ( int  attr,
const char *  objectid,
bool &  ok,
bool  report = true 
) const
inherited

convenience function to avoid the default argument and the template stuff at getOpt<>

Definition at line 142 of file SUMOSAXAttributes.cpp.

Referenced by NLHandler::addPhase(), and NIImporter_SUMO::addPhase().

◆ getOptStringVector()

const std::vector< std::string > SUMOSAXAttributes::getOptStringVector ( int  attr,
const char *  objectid,
bool &  ok,
bool  report = true 
) const
inherited

◆ getOptSUMOTimeReporting()

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

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 get<int> or get<double> 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 occurred

Definition at line 90 of file SUMOSAXAttributes.cpp.

References SUMOSAXAttributes::emitEmptyError(), SUMOSAXAttributes::emitFormatError(), SUMOSAXAttributes::getName(), SUMOSAXAttributes::hasAttribute(), and string2time().

Referenced by NLHandler::addE2Detector(), NLHandler::addEdgeLaneMeanData(), MSRouteHandler::addPersonTrip(), NLHandler::addPhase(), NIImporter_SUMO::addPhase(), NLHandler::addRouteProbeDetector(), MSRouteHandler::addWalk(), NLHandler::beginE3Detector(), NLHandler::initTrafficLightLogic(), MSRouteHandler::myStartElement(), MSCalibrator::myStartElement(), MSTriggeredRerouter::myStartElement(), GUISettingsHandler::myStartElement(), NLHandler::openWAUT(), NLTriggerBuilder::parseAndBuildCalibrator(), and SUMORouteHandler::parseStop().

◆ getRightOfWay()

RightOfWay SUMOSAXAttributesImpl_Binary::getRightOfWay ( bool &  ok) const
virtual

◆ getShape()

PositionVector SUMOSAXAttributesImpl_Binary::getShape ( int  attr) const
virtual

Tries to read given attribute assuming it is a PositionVector.

Parameters
[in]attrThe id of the attribute to read
Returns
The read value if given and not empty; "" if an error occurred

Implements SUMOSAXAttributes.

Definition at line 306 of file SUMOSAXAttributesImpl_Binary.cpp.

References myPositionVectors.

◆ getString()

std::string SUMOSAXAttributesImpl_Binary::getString ( int  id) const
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

Implements SUMOSAXAttributes.

Definition at line 191 of file SUMOSAXAttributesImpl_Binary.cpp.

References myStringValues.

Referenced by getFloat(), getFringeType(), getLong(), and getRightOfWay().

◆ getStringSecure() [1/2]

std::string SUMOSAXAttributesImpl_Binary::getStringSecure ( const std::string &  id,
const std::string &  def 
) const
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

Implements SUMOSAXAttributes.

Definition at line 234 of file SUMOSAXAttributesImpl_Binary.cpp.

◆ getStringSecure() [2/2]

std::string SUMOSAXAttributesImpl_Binary::getStringSecure ( int  id,
const std::string &  def 
) const
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

Implements SUMOSAXAttributes.

Definition at line 201 of file SUMOSAXAttributesImpl_Binary.cpp.

References myStringValues.

Referenced by serialize().

◆ getStringVector()

const std::vector< std::string > SUMOSAXAttributes::getStringVector ( int  attr) const
inherited

Tries to read given attribute assuming it is a string vector.

The behavior is similar to Python's string.split(), so multiple consecutive whitespace do not generate empty strings and leading and trailing whitespace is silently omitted.

Parameters
[in]attrThe id of the attribute to read
Returns
The read value if given and not empty; empty vector if an error occurred

Definition at line 113 of file SUMOSAXAttributes.cpp.

References SUMOSAXAttributes::getString(), and StringTokenizer::getVector().

Referenced by NLHandler::addDistrict(), NIImporter_SUMO::addRoundabout(), NIXMLEdgesHandler::addRoundabout(), NLHandler::addRoundabout(), NIXMLPTHandler::addRoute(), MSStateHandler::myStartElement(), ODDistrictHandler::openDistrict(), and RONetHandler::parseDistrict().

◆ getSUMOTimeReporting()

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

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 get<int> or get<double> 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 occurred

Definition at line 63 of file SUMOSAXAttributes.cpp.

References SUMOSAXAttributes::emitEmptyError(), SUMOSAXAttributes::emitFormatError(), SUMOSAXAttributes::emitUngivenError(), SUMOSAXAttributes::getName(), SUMOSAXAttributes::hasAttribute(), and string2time().

Referenced by NLHandler::addE1Detector(), NLHandler::addE2Detector(), NLHandler::addPhase(), NLHandler::addRouteProbeDetector(), NLHandler::addVTypeProbeDetector(), NLHandler::addWAUTSwitch(), NLHandler::beginE3Detector(), SUMOVehicleParserHelper::beginVTypeParsing(), NLTriggerBuilder::buildVaporizer(), GUINet::DiscoverAttributes::myStartElement(), MSCalibrator::myStartElement(), MSLaneSpeedTrigger::myStartElement(), TrajectoriesHandler::myStartElement(), GUISettingsHandler::myStartElement(), SUMORouteHandler::myStartElement(), SAXWeightsHandler::myStartElement(), and SUMOVehicleParserHelper::parseFlowAttributes().

◆ hasAttribute() [1/2]

bool SUMOSAXAttributesImpl_Binary::hasAttribute ( const std::string &  id) const
virtual

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

Implements SUMOSAXAttributes.

Definition at line 228 of file SUMOSAXAttributesImpl_Binary.cpp.

◆ hasAttribute() [2/2]

bool SUMOSAXAttributesImpl_Binary::hasAttribute ( int  id) const
virtual

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

Parameters
[in]idThe id of the searched attribute
Returns
Whether the attribute is within the attributes

Implements SUMOSAXAttributes.

Definition at line 159 of file SUMOSAXAttributesImpl_Binary.cpp.

References myAttrs.

◆ operator=()

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

Invalidated assignment operator.

◆ serialize()

void SUMOSAXAttributesImpl_Binary::serialize ( std::ostream &  os) const
virtual

Prints all attribute names and values into the given stream.

Parameters
[in]osThe stream to use

Implements SUMOSAXAttributes.

Definition at line 338 of file SUMOSAXAttributesImpl_Binary.cpp.

References getName(), getStringSecure(), and myAttrs.

Field Documentation

◆ ENCODING

const std::string SUMOSAXAttributes::ENCODING = " encoding=\"UTF-8\""
staticinherited

The encoding of parsed strings.

Definition at line 407 of file SUMOSAXAttributes.h.

Referenced by OptionsCont::writeXMLHeader().

◆ myAttrIds

const std::map<int, std::string>& SUMOSAXAttributesImpl_Binary::myAttrIds
private

Map of attribute ids to names.

Definition at line 288 of file SUMOSAXAttributesImpl_Binary.h.

Referenced by clone(), and getName().

◆ myAttrs

std::set<int> SUMOSAXAttributesImpl_Binary::myAttrs
private

the attributes which are set

Definition at line 291 of file SUMOSAXAttributesImpl_Binary.h.

Referenced by getAttributeNames(), hasAttribute(), serialize(), and SUMOSAXAttributesImpl_Binary().

◆ myCharValues

std::map<int, char> SUMOSAXAttributesImpl_Binary::myCharValues
private

Map of attribute ids to char.

Definition at line 294 of file SUMOSAXAttributesImpl_Binary.h.

Referenced by clone(), getBool(), getEdgeFunc(), getNodeType(), and SUMOSAXAttributesImpl_Binary().

◆ myFloatValues

std::map<int, double> SUMOSAXAttributesImpl_Binary::myFloatValues
private

Map of attribute ids to floats.

Definition at line 300 of file SUMOSAXAttributesImpl_Binary.h.

Referenced by clone(), getFloat(), and SUMOSAXAttributesImpl_Binary().

◆ myIntValues

std::map<int, int> SUMOSAXAttributesImpl_Binary::myIntValues
private

Map of attribute ids to integers.

Definition at line 297 of file SUMOSAXAttributesImpl_Binary.h.

Referenced by clone(), getColor(), getInt(), and SUMOSAXAttributesImpl_Binary().

◆ myObjectType

std::string SUMOSAXAttributes::myObjectType
privateinherited

◆ myPositionVectors

std::map<int, PositionVector> SUMOSAXAttributesImpl_Binary::myPositionVectors
private

Map of attribute ids to string.

Definition at line 306 of file SUMOSAXAttributesImpl_Binary.h.

Referenced by clone(), getBoundary(), getShape(), and SUMOSAXAttributesImpl_Binary().

◆ myStringValues

std::map<int, std::string> SUMOSAXAttributesImpl_Binary::myStringValues
private

Map of attribute ids to string.

Definition at line 303 of file SUMOSAXAttributesImpl_Binary.h.

Referenced by clone(), getString(), getStringSecure(), and SUMOSAXAttributesImpl_Binary().


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