#include <SUMOSAXAttributes.h>

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 50 of file SUMOSAXAttributes.h.
virtual methods for retrieving attribute values | |
| static bool | myHaveInformedAboutDeprecatedDivider = false |
| Information whether the usage of a deprecated divider was reported. | |
| virtual bool | getBool (SumoXMLAttr id) const =0 throw (EmptyData, BoolFormatException) |
| Returns the bool-value of the named (by its enum-value) attribute. | |
| virtual bool | getBoolSecure (SumoXMLAttr 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. | |
| virtual SUMOReal | getFloat (const std::string &id) const =0 throw (EmptyData, NumberFormatException) |
| Returns the SUMOReal-value of the named attribute. | |
| virtual SUMOReal | getFloat (SumoXMLAttr id) const =0 throw (EmptyData, NumberFormatException) |
| Returns the SUMOReal-value of the named (by its enum-value) attribute. | |
| virtual SUMOReal | getFloatSecure (SumoXMLAttr id, SUMOReal def) const =0 throw (EmptyData, NumberFormatException) |
| Returns the SUMOReal-value of the named (by its enum-value) attribute. | |
| virtual int | getInt (SumoXMLAttr id) const =0 throw (EmptyData, NumberFormatException) |
| Returns the int-value of the named (by its enum-value) attribute. | |
| virtual int | getIntSecure (SumoXMLAttr id, int def) const =0 throw (EmptyData, NumberFormatException) |
| Returns the int-value of the named (by its enum-value) attribute. | |
| virtual std::string | getName (SumoXMLAttr attr) const =0 throw () |
| Converts the given attribute id into a man readable string. | |
| virtual std::string | getString (SumoXMLAttr id) const =0 throw (EmptyData) |
| Returns the string-value of the named (by its enum-value) attribute. | |
| virtual std::string | getStringSecure (const std::string &id, const std::string &def) const =0 throw () |
| Returns the string-value of the named (by its enum-value) attribute. | |
| virtual std::string | getStringSecure (SumoXMLAttr id, const std::string &def) const =0 throw (EmptyData) |
| Returns the string-value of the named (by its enum-value) attribute. | |
| virtual bool | hasAttribute (const std::string &id) const =0 throw () |
| Returns the information whether the named attribute is within the current list. | |
| virtual bool | hasAttribute (SumoXMLAttr id) const =0 throw () |
| Returns the information whether the named (by its enum-value) attribute is within the current list. | |
| static void | parseStringVector (const std::string &def, std::vector< std::string > &into) throw () |
| Splits the given string. | |
| void | emitEmptyError (const std::string &attrname, const char *objecttype, const char *objectid) const throw () |
| void | emitFormatError (const std::string &attrname, const std::string &type, const char *objecttype, const char *objectid) const throw () |
| void | emitUngivenError (const std::string &attrname, const char *objecttype, const char *objectid) const throw () |
| SUMOSAXAttributes & | operator= (const SUMOSAXAttributes &src) |
| Invalidated assignment operator. | |
| SUMOSAXAttributes (const SUMOSAXAttributes &src) | |
| Invalidated copy constructor. | |
Public Member Functions | |
| bool | getBoolReporting (SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok, bool report=true) const throw () |
| Tries to read given attribute assuming it is a boolean. | |
| int | getIntReporting (SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok, bool report=true) const throw () |
| Tries to read given attribute assuming it is an int. | |
| bool | getOptBoolReporting (SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok, bool defaultValue, bool report=true) const throw () |
| Tries to read given attribute assuming it is a boolean. | |
| int | getOptIntReporting (SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok, int defaultValue, bool report=true) const throw () |
| Tries to read given attribute assuming it is an int. | |
| std::string | getOptStringReporting (SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok, const std::string &defaultValue, bool report=true) const throw () |
| Tries to read given attribute assuming it is a string. | |
| SUMOReal | getOptSUMORealReporting (SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok, SUMOReal defaultValue, bool report=true) const throw () |
| Tries to read given attribute assuming it is a SUMOReal. | |
| SUMOTime | getOptSUMOTimeReporting (SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok, SUMOTime defaultValue, bool report=true) const throw () |
| Tries to read given attribute assuming it is a SUMOTime. | |
| std::string | getStringReporting (SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok, bool report=true) const throw () |
| Tries to read given attribute assuming it is a string. | |
| SUMOReal | getSUMORealReporting (SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok, bool report=true) const throw () |
| Tries to read given attribute assuming it is a SUMOReal. | |
| SUMOTime | getSUMOTimeReporting (SumoXMLAttr attr, const char *objecttype, const char *objectid, bool &ok, bool report=true) const throw () |
| Tries to read given attribute assuming it is a SUMOTime. | |
| bool | setIDFromAttributes (const char *objecttype, std::string &id, bool report=true) const throw () |
| Tries to read the id from the attributes, stores it into "id" if given. | |
| SUMOSAXAttributes () throw () | |
| Constructor. | |
| virtual | ~SUMOSAXAttributes () throw () |
| Destructor. | |
| SUMOSAXAttributes::SUMOSAXAttributes | ( | ) | throw () [inline] |
| virtual SUMOSAXAttributes::~SUMOSAXAttributes | ( | ) | throw () [inline, virtual] |
| SUMOSAXAttributes::SUMOSAXAttributes | ( | const SUMOSAXAttributes & | src | ) | [private] |
Invalidated copy constructor.
| void SUMOSAXAttributes::emitEmptyError | ( | const std::string & | attrname, | |
| const char * | objecttype, | |||
| const char * | objectid | |||
| ) | const throw () [protected] |
Definition at line 336 of file SUMOSAXAttributes.cpp.
References MsgHandler::getErrorInstance(), and MsgHandler::inform().
00336 { 00337 std::ostringstream oss; 00338 oss << "Attribute '" << attrname << "' in definition of "; 00339 if (objectid==0) { 00340 oss << "a "; 00341 } 00342 if (objecttype!=0) { 00343 oss << objecttype; 00344 } else { 00345 oss << "<unknown type>"; 00346 } 00347 if (objectid!=0) { 00348 oss << " '" << objectid << "'"; 00349 } 00350 oss << " is empty."; 00351 MsgHandler::getErrorInstance()->inform(oss.str()); 00352 }
| void SUMOSAXAttributes::emitFormatError | ( | const std::string & | attrname, | |
| const std::string & | type, | |||
| const char * | objecttype, | |||
| const char * | objectid | |||
| ) | const throw () [protected] |
Definition at line 356 of file SUMOSAXAttributes.cpp.
References MsgHandler::getErrorInstance(), and MsgHandler::inform().
00356 { 00357 std::ostringstream oss; 00358 oss << "Attribute '" << attrname << "' in definition of "; 00359 if (objectid==0) { 00360 oss << "a "; 00361 } 00362 if (objecttype!=0) { 00363 oss << objecttype; 00364 } else { 00365 oss << "<unknown type>"; 00366 } 00367 if (objectid!=0) { 00368 oss << " '" << objectid << "'"; 00369 } 00370 oss << " is not " << type << "."; 00371 MsgHandler::getErrorInstance()->inform(oss.str()); 00372 }
| void SUMOSAXAttributes::emitUngivenError | ( | const std::string & | attrname, | |
| const char * | objecttype, | |||
| const char * | objectid | |||
| ) | const throw () [protected] |
Definition at line 316 of file SUMOSAXAttributes.cpp.
References MsgHandler::getErrorInstance(), and MsgHandler::inform().
00316 { 00317 std::ostringstream oss; 00318 oss << "Attribute '" << attrname << "' is missing in definition of "; 00319 if (objectid==0) { 00320 oss << "a "; 00321 } 00322 if (objecttype!=0) { 00323 oss << objecttype; 00324 } else { 00325 oss << "<unknown type>"; 00326 } 00327 if (objectid!=0) { 00328 oss << " '" << objectid << "'"; 00329 } 00330 oss << "."; 00331 MsgHandler::getErrorInstance()->inform(oss.str()); 00332 }
| virtual bool SUMOSAXAttributes::getBool | ( | SumoXMLAttr | 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.
| [in] | id | The id of the attribute to return the value of |
| EmptyData | If the attribute is not known or the attribute value is an empty string | |
| BoolFormatException | If the attribute value can not be parsed to a bool |
Implemented in SUMOSAXAttributesImpl_Xerces.
| bool SUMOSAXAttributes::getBoolReporting | ( | SumoXMLAttr | attr, | |
| const char * | objecttype, | |||
| const char * | objectid, | |||
| bool & | ok, | |||
| bool | report = true | |||
| ) | const throw () |
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.
| [in] | attr | The id of the attribute to read |
| [in] | objecttype | The name of the parsed object type; used for error message generation |
| [in] | objectid | The name of the parsed object; used for error message generation |
| [out] | ok | Whether the value could be read |
| [in] | report | Whether errors shall be written to msg handler's error instance |
Definition at line 165 of file SUMOSAXAttributes.cpp.
Referenced by NLHandler::addLane(), and NLHandler::addSuccLane().
00166 { 00167 if (!hasAttribute(attr)) { 00168 if (report) { 00169 emitUngivenError(getName(attr), objecttype, objectid); 00170 } 00171 ok = false; 00172 return false; 00173 } 00174 try { 00175 return getBool(attr); 00176 } catch (BoolFormatException &) { 00177 if (report) { 00178 emitFormatError(getName(attr), "a boolean", objecttype, objectid); 00179 } 00180 } catch (EmptyData &) { 00181 if (report) { 00182 emitEmptyError(getName(attr), objecttype, objectid); 00183 } 00184 } 00185 ok = false; 00186 return false; 00187 }
| virtual bool SUMOSAXAttributes::getBoolSecure | ( | SumoXMLAttr | 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.
| [in] | id | The id of the attribute to return the value of |
| [in] | val | The default value to return if the attribute is not in attributes |
| EmptyData | If the attribute value is an empty string |
Implemented in SUMOSAXAttributesImpl_Xerces.
| virtual SUMOReal SUMOSAXAttributes::getFloat | ( | const std::string & | id | ) | const throw (EmptyData, NumberFormatException) [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.
| [in] | id | The name of the attribute to return the value of |
| EmptyData | If the attribute is not known or the attribute value is an empty string | |
| NumberFormatException | If the attribute value can not be parsed to an SUMOReal |
Implemented in SUMOSAXAttributesImpl_Xerces.
| virtual SUMOReal SUMOSAXAttributes::getFloat | ( | SumoXMLAttr | id | ) | const throw (EmptyData, NumberFormatException) [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.
| [in] | id | The id of the attribute to return the value of |
| EmptyData | If the attribute is not known or the attribute value is an empty string | |
| NumberFormatException | If the attribute value can not be parsed to an SUMOReal |
Implemented in SUMOSAXAttributesImpl_Xerces.
Referenced by SAXWeightsHandler::tryParse().
| virtual SUMOReal SUMOSAXAttributes::getFloatSecure | ( | SumoXMLAttr | id, | |
| SUMOReal | def | |||
| ) | const throw (EmptyData, NumberFormatException) [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.
| [in] | id | The id of the attribute to return the value of |
| [in] | def | The default value to return if the attribute is not in attributes |
| EmptyData | If the attribute is not known or the attribute value is an empty string | |
| NumberFormatException | If the attribute value can not be parsed to an SUMOReal |
Implemented in SUMOSAXAttributesImpl_Xerces.
| virtual int SUMOSAXAttributes::getInt | ( | SumoXMLAttr | id | ) | const throw (EmptyData, NumberFormatException) [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.
| [in] | id | The id of the attribute to return the value of |
| EmptyData | If the attribute is not known or the attribute value is an empty string | |
| NumberFormatException | If the attribute value can not be parsed to an int |
Implemented in SUMOSAXAttributesImpl_Xerces.
Referenced by traci::TraCIHandler::openVehicleTag().
| int SUMOSAXAttributes::getIntReporting | ( | SumoXMLAttr | attr, | |
| const char * | objecttype, | |||
| const char * | objectid, | |||
| bool & | ok, | |||
| bool | report = true | |||
| ) | const throw () |
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.
| [in] | attr | The id of the attribute to read |
| [in] | objecttype | The name of the parsed object type; used for error message generation |
| [in] | objectid | The name of the parsed object; used for error message generation |
| [out] | ok | Whether the value could be read |
| [in] | report | Whether errors shall be written to msg handler's error instance |
Definition at line 69 of file SUMOSAXAttributes.cpp.
Referenced by NLHandler::addLogicItem(), NLHandler::addSuccLane(), RORDLoader_TripDefs::getRepetitionNumber(), NLHandler::initJunctionLogic(), and RORDLoader_SUMOBase::startAlternative().
00070 { 00071 if (!hasAttribute(attr)) { 00072 if (report) { 00073 emitUngivenError(getName(attr), objecttype, objectid); 00074 } 00075 ok = false; 00076 return -1; 00077 } 00078 try { 00079 return getInt(attr); 00080 } catch (NumberFormatException &) { 00081 if (report) { 00082 emitFormatError(getName(attr), "an int", objecttype, objectid); 00083 } 00084 } catch (EmptyData &) { 00085 if (report) { 00086 emitEmptyError(getName(attr), objecttype, objectid); 00087 } 00088 } 00089 ok = false; 00090 return -1; 00091 }
| virtual int SUMOSAXAttributes::getIntSecure | ( | SumoXMLAttr | id, | |
| int | def | |||
| ) | const throw (EmptyData, NumberFormatException) [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.
| [in] | id | The id of the attribute to return the value of |
| [in] | def | The default value to return if the attribute is not in attributes |
| EmptyData | If the attribute value is an empty string | |
| NumberFormatException | If the attribute value can not be parsed to an int |
Implemented in SUMOSAXAttributesImpl_Xerces.
| virtual std::string SUMOSAXAttributes::getName | ( | SumoXMLAttr | attr | ) | const throw () [pure virtual] |
Converts the given attribute id into a man readable string.
| [in] | attr | The id of the attribute to return the name of |
Implemented in SUMOSAXAttributesImpl_Xerces.
| bool SUMOSAXAttributes::getOptBoolReporting | ( | SumoXMLAttr | attr, | |
| const char * | objecttype, | |||
| const char * | objectid, | |||
| bool & | ok, | |||
| bool | defaultValue, | |||
| bool | report = true | |||
| ) | const throw () |
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.
| [in] | attr | The id of the attribute to read |
| [in] | objecttype | The name of the parsed object type; used for error message generation |
| [in] | objectid | The name of the parsed object; used for error message generation |
| [out] | ok | Whether the value could be read |
| [in] | defaultValue | The value to return if the attribute is not within the element |
| [in] | report | Whether errors shall be written to msg handler's error instance |
Definition at line 191 of file SUMOSAXAttributes.cpp.
Referenced by NLHandler::addE1Detector(), NLHandler::addE2Detector(), NLHandler::addE3Entry(), NLHandler::addE3Exit(), NLHandler::addEdgeLaneMeanData(), NIImporter_SUMO::addLane(), NLHandler::addLogicItem(), NLHandler::addPoly(), NLHandler::addSuccLane(), and NLHandler::addWAUTJunction().
00192 { 00193 if (!hasAttribute(attr)) { 00194 return defaultValue; 00195 } 00196 try { 00197 return getBool(attr); 00198 } catch (BoolFormatException &) { 00199 if (report) { 00200 emitFormatError(getName(attr), "a boolean", objecttype, objectid); 00201 } 00202 } catch (EmptyData &) { 00203 if (report) { 00204 emitEmptyError(getName(attr), objecttype, objectid); 00205 } 00206 } 00207 ok = false; 00208 return false; 00209 }
| int SUMOSAXAttributes::getOptIntReporting | ( | SumoXMLAttr | attr, | |
| const char * | objecttype, | |||
| const char * | objectid, | |||
| bool & | ok, | |||
| int | defaultValue, | |||
| bool | report = true | |||
| ) | const throw () |
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.
| [in] | attr | The id of the attribute to read |
| [in] | objecttype | The name of the parsed object type; used for error message generation |
| [in] | objectid | The name of the parsed object; used for error message generation |
| [out] | ok | Whether the value could be read |
| [in] | defaultValue | The value to return if the attribute is not within the element |
| [in] | report | Whether errors shall be written to msg handler's error instance |
Definition at line 95 of file SUMOSAXAttributes.cpp.
Referenced by NIImporter_SUMO::addEdge(), NLHandler::addPOI(), and NLHandler::addPoly().
00096 { 00097 if (!hasAttribute(attr)) { 00098 return defaultValue; 00099 } 00100 try { 00101 return getInt(attr); 00102 } catch (NumberFormatException &) { 00103 if (report) { 00104 emitFormatError(getName(attr), "an int", objecttype, objectid); 00105 } 00106 } catch (EmptyData &) { 00107 if (report) { 00108 emitEmptyError(getName(attr), objecttype, objectid); 00109 } 00110 } 00111 ok = false; 00112 return -1; 00113 }
| std::string SUMOSAXAttributes::getOptStringReporting | ( | SumoXMLAttr | attr, | |
| const char * | objecttype, | |||
| const char * | objectid, | |||
| bool & | ok, | |||
| const std::string & | defaultValue, | |||
| bool | report = true | |||
| ) | const throw () |
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.
| [in] | attr | The id of the attribute to read |
| [in] | objecttype | The name of the parsed object type; used for error message generation |
| [in] | objectid | The name of the parsed object; used for error message generation |
| [out] | ok | Whether the value could be read |
| [in] | defaultValue | The value to return if the attribute is not within the element |
| [in] | report | Whether errors shall be written to msg handler's error instance |
Definition at line 239 of file SUMOSAXAttributes.cpp.
Referenced by NLDiscreteEventBuilder::addAction(), NLHandler::addDetector(), NLHandler::addE1Detector(), NLHandler::addE2Detector(), NIImporter_SUMO::addEdge(), NLHandler::addEdgeLaneMeanData(), NLHandler::addLane(), NLHandler::addPOI(), NLHandler::addPoly(), NIImporter_SUMO::addSuccEdge(), NLHandler::addSuccLane(), NIImporter_SUMO::addSuccLane(), NLHandler::addWAUTJunction(), NLHandler::beginE3Detector(), NLDiscreteEventBuilder::buildSaveTLStateCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchesCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchStatesCommand(), RORDLoader_TripDefs::getLane(), NLHandler::initTrafficLightLogic(), NLHandler::openJunction(), RONetHandler::parseLane(), NIXMLNodesHandler::processTrafficLightDefinitions(), and RORDLoader_SUMOBase::startRoute().
00240 { 00241 if (!hasAttribute(attr)) { 00242 return defaultValue; 00243 } 00244 try { 00245 return getString(attr); 00246 } catch (EmptyData &) { 00247 if (report) { 00248 emitEmptyError(getName(attr), objecttype, objectid); 00249 } 00250 } 00251 ok = false; 00252 return ""; 00253 }
| SUMOReal SUMOSAXAttributes::getOptSUMORealReporting | ( | SumoXMLAttr | attr, | |
| const char * | objecttype, | |||
| const char * | objectid, | |||
| bool & | ok, | |||
| SUMOReal | defaultValue, | |||
| bool | report = true | |||
| ) | const throw () |
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.
| [in] | attr | The id of the attribute to read |
| [in] | objecttype | The name of the parsed object type; used for error message generation |
| [in] | objectid | The name of the parsed object; used for error message generation |
| [out] | ok | Whether the value could be read |
| [in] | defaultValue | The value to return if the attribute is not within the element |
| [in] | report | Whether errors shall be written to msg handler's error instance |
Definition at line 143 of file SUMOSAXAttributes.cpp.
References SUMOReal.
Referenced by NLHandler::addE2Detector(), NLHandler::addEdgeLaneMeanData(), NIImporter_SUMO::addJunction(), NIImporter_SUMO::addLane(), NLHandler::addPOI(), NLHandler::addSuccLane(), NLHandler::beginE3Detector(), NLHandler::initTrafficLightLogic(), MSRouteHandler::openRoute(), and NIXMLEdgesHandler::tryGetPosition().
00144 { 00145 if (!hasAttribute(attr)) { 00146 return defaultValue; 00147 } 00148 try { 00149 return getFloat(attr); 00150 } catch (NumberFormatException &) { 00151 if (report) { 00152 emitFormatError(getName(attr), "a real number", objecttype, objectid); 00153 } 00154 } catch (EmptyData &) { 00155 if (report) { 00156 emitEmptyError(getName(attr), objecttype, objectid); 00157 } 00158 } 00159 ok = false; 00160 return (SUMOReal) -1; 00161 }
| SUMOTime SUMOSAXAttributes::getOptSUMOTimeReporting | ( | SumoXMLAttr | attr, | |
| const char * | objecttype, | |||
| const char * | objectid, | |||
| bool & | ok, | |||
| SUMOTime | defaultValue, | |||
| bool | report = true | |||
| ) | const throw () |
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.
| [in] | attr | The id of the attribute to read |
| [in] | objecttype | The name of the parsed object type; used for error message generation |
| [in] | objectid | The name of the parsed object; used for error message generation |
| [out] | ok | Whether the value could be read |
| [in] | defaultValue | The value to return if the attribute is not within the element |
| [in] | report | Whether errors shall be written to msg handler's error instance |
Definition at line 287 of file SUMOSAXAttributes.cpp.
Referenced by NLHandler::addE2Detector(), NLHandler::addEdgeLaneMeanData(), NLHandler::addPhase(), NLHandler::addRouteProbeDetector(), NLHandler::beginE3Detector(), NLHandler::initTrafficLightLogic(), NLHandler::openWAUT(), and RORDGenerator_ODAmounts::parseInterval().
00288 { 00289 #ifdef HAVE_SUBSECOND_TIMESTEPS 00290 if (!hasAttribute(attr)) { 00291 return defaultValue; 00292 } 00293 try { 00294 return (SUMOTime)(getFloat(attr)*1000.); 00295 } catch (NumberFormatException &) { 00296 if (report) { 00297 emitFormatError(getName(attr), "a real number", objecttype, objectid); 00298 } 00299 } catch (EmptyData &) { 00300 if (report) { 00301 emitEmptyError(getName(attr), objecttype, objectid); 00302 } 00303 } 00304 ok = false; 00305 return (SUMOTime) -1; 00306 #else 00307 return getOptIntReporting(attr, objecttype, objectid, ok, defaultValue, report); 00308 #endif 00309 }
| virtual std::string SUMOSAXAttributes::getString | ( | SumoXMLAttr | 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.
| [in] | id | The id of the attribute to return the value of |
| EmptyData | If the attribute is not known or the attribute value is an empty string |
Implemented in SUMOSAXAttributesImpl_Xerces.
Referenced by NLHandler::addDistrict(), MSRouteHandler::openRoute(), and RORDLoader_SUMOBase::startRoute().
| std::string SUMOSAXAttributes::getStringReporting | ( | SumoXMLAttr | attr, | |
| const char * | objecttype, | |||
| const char * | objectid, | |||
| bool & | ok, | |||
| bool | report = true | |||
| ) | const throw () |
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.
| [in] | attr | The id of the attribute to read |
| [in] | objecttype | The name of the parsed object type; used for error message generation |
| [in] | objectid | The name of the parsed object; used for error message generation |
| [out] | ok | Whether the value could be read |
| [in] | report | Whether errors shall be written to msg handler's error instance |
Definition at line 213 of file SUMOSAXAttributes.cpp.
Referenced by NLHandler::addDistrictEdge(), NLHandler::addE1Detector(), NLHandler::addE2Detector(), NLHandler::addE3Entry(), NLHandler::addE3Exit(), NLHandler::addEdgeLaneMeanData(), NLHandler::addLane(), NIImporter_SUMO::addLane(), NLHandler::addLogicItem(), NLHandler::addParam(), NLHandler::addPhase(), NLHandler::addPoly(), NLHandler::addRouteProbeDetector(), NLHandler::addSuccLane(), NLHandler::addVTypeProbeDetector(), NLHandler::addWAUTJunction(), NLHandler::addWAUTSwitch(), NLHandler::beginE3Detector(), NLHandler::beginEdgeParsing(), RORDLoader_TripDefs::getEdge(), NLHandler::initTrafficLightLogic(), NLHandler::openJunction(), MSRouteHandler::openRoute(), MSRouteHandler::openRouteDistribution(), NLHandler::openSucc(), MSRouteHandler::openVehicleTypeDistribution(), NLHandler::openWAUT(), RONetHandler::parseConnectedEdge(), RONetHandler::parseDistrictEdge(), RONetHandler::parseEdge(), NLHandler::setLocation(), and RORDLoader_SUMOBase::startRoute().
00214 { 00215 if (!hasAttribute(attr)) { 00216 if (report) { 00217 emitUngivenError(getName(attr), objecttype, objectid); 00218 } 00219 ok = false; 00220 return ""; 00221 } 00222 try { 00223 std::string ret = getString(attr); 00224 if (ret=="") { 00225 throw EmptyData(); 00226 } 00227 return ret; 00228 } catch (EmptyData &) { 00229 if (report) { 00230 emitEmptyError(getName(attr), objecttype, objectid); 00231 } 00232 } 00233 ok = false; 00234 return ""; 00235 }
| virtual std::string SUMOSAXAttributes::getStringSecure | ( | const std::string & | id, | |
| const std::string & | def | |||
| ) | const throw () [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.
| [in] | id | The name of the attribute to return the value of |
| [in] | def | The default value to return if the attribute is not in attributes |
Implemented in SUMOSAXAttributesImpl_Xerces.
| virtual std::string SUMOSAXAttributes::getStringSecure | ( | SumoXMLAttr | 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.
| [in] | id | The id of the attribute to return the value of |
| [in] | def | The default value to return if the attribute is not in attributes |
| EmptyData | If the attribute is not known or the attribute value is an empty string |
Implemented in SUMOSAXAttributesImpl_Xerces.
Referenced by NLHandler::addVTypeProbeDetector(), and NLHandler::openJunction().
| SUMOReal SUMOSAXAttributes::getSUMORealReporting | ( | SumoXMLAttr | attr, | |
| const char * | objecttype, | |||
| const char * | objectid, | |||
| bool & | ok, | |||
| bool | report = true | |||
| ) | const throw () |
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.
| [in] | attr | The id of the attribute to read |
| [in] | objecttype | The name of the parsed object type; used for error message generation |
| [in] | objectid | The name of the parsed object; used for error message generation |
| [out] | ok | Whether the value could be read |
| [in] | report | Whether errors shall be written to msg handler's error instance |
Definition at line 117 of file SUMOSAXAttributes.cpp.
References SUMOReal.
Referenced by NLHandler::addE1Detector(), NLHandler::addE2Detector(), NLHandler::addE3Entry(), NLHandler::addE3Exit(), NLHandler::addLane(), NLHandler::openJunction(), RONetHandler::parseJunction(), RONetHandler::parseLane(), and RORDLoader_SUMOBase::startRoute().
00118 { 00119 if (!hasAttribute(attr)) { 00120 if (report) { 00121 emitUngivenError(getName(attr), objecttype, objectid); 00122 } 00123 ok = false; 00124 return -1; 00125 } 00126 try { 00127 return getFloat(attr); 00128 } catch (NumberFormatException &) { 00129 if (report) { 00130 emitFormatError(getName(attr), "a real number", objecttype, objectid); 00131 } 00132 } catch (EmptyData &) { 00133 if (report) { 00134 emitEmptyError(getName(attr), objecttype, objectid); 00135 } 00136 } 00137 ok = false; 00138 return (SUMOReal) -1; 00139 }
| SUMOTime SUMOSAXAttributes::getSUMOTimeReporting | ( | SumoXMLAttr | attr, | |
| const char * | objecttype, | |||
| const char * | objectid, | |||
| bool & | ok, | |||
| bool | report = true | |||
| ) | const throw () |
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.
| [in] | attr | The id of the attribute to read |
| [in] | objecttype | The name of the parsed object type; used for error message generation |
| [in] | objectid | The name of the parsed object; used for error message generation |
| [out] | ok | Whether the value could be read |
| [in] | report | Whether errors shall be written to msg handler's error instance |
Definition at line 257 of file SUMOSAXAttributes.cpp.
Referenced by NLHandler::addE1Detector(), NLHandler::addE2Detector(), NLHandler::addPhase(), NLHandler::addRouteProbeDetector(), NLHandler::addVTypeProbeDetector(), NLHandler::addWAUTSwitch(), NLHandler::beginE3Detector(), and RORDLoader_TripDefs::getPeriod().
00258 { 00259 #ifdef HAVE_SUBSECOND_TIMESTEPS 00260 if (!hasAttribute(attr)) { 00261 if (report) { 00262 emitUngivenError(getName(attr), objecttype, objectid); 00263 } 00264 ok = false; 00265 return -1; 00266 } 00267 try { 00268 return (SUMOTime)(getFloat(attr) * 1000.); 00269 } catch (NumberFormatException &) { 00270 if (report) { 00271 emitFormatError(getName(attr), "a time value", objecttype, objectid); 00272 } 00273 } catch (EmptyData &) { 00274 if (report) { 00275 emitEmptyError(getName(attr), objecttype, objectid); 00276 } 00277 } 00278 ok = false; 00279 return (SUMOTime) -1; 00280 #else 00281 return getIntReporting(attr, objecttype, objectid, ok, report); 00282 #endif 00283 }
| virtual bool SUMOSAXAttributes::hasAttribute | ( | const std::string & | id | ) | const throw () [pure virtual] |
Returns the information whether the named attribute is within the current list.
| [in] | id | The name of the attribute to search for |
Implemented in SUMOSAXAttributesImpl_Xerces.
| virtual bool SUMOSAXAttributes::hasAttribute | ( | SumoXMLAttr | id | ) | const throw () [pure virtual] |
Returns the information whether the named (by its enum-value) attribute is within the current list.
| [in] | id | The id of the attribute to search for |
Implemented in SUMOSAXAttributesImpl_Xerces.
Referenced by NLHandler::addDistrict(), NLHandler::addLane(), NIImporter_SUMO::addLane(), NLHandler::addPhase(), NLHandler::addPoly(), RORDLoader_TripDefs::getPeriod(), RORDLoader_TripDefs::getRepetitionNumber(), NLHandler::initJunctionLogic(), NLHandler::initTrafficLightLogic(), NLHandler::openJunction(), MSRouteHandler::openRoute(), MSRouteHandler::openRouteDistribution(), MSRouteHandler::openVehicleTypeDistribution(), RORDLoader_SUMOBase::startRoute(), and SAXWeightsHandler::tryParse().
| SUMOSAXAttributes& SUMOSAXAttributes::operator= | ( | const SUMOSAXAttributes & | src | ) | [private] |
Invalidated assignment operator.
| void SUMOSAXAttributes::parseStringVector | ( | const std::string & | def, | |
| std::vector< std::string > & | into | |||
| ) | throw () [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).
| [in] | def | The string to split |
| [out] | into | The vector to fill |
Definition at line 376 of file SUMOSAXAttributes.cpp.
References MsgHandler::getWarningInstance(), StringTokenizer::hasNext(), MsgHandler::inform(), and StringTokenizer::next().
Referenced by NIXMLEdgesHandler::myStartElement(), NLTriggerBuilder::parseAndBuildBusStop(), NLTriggerBuilder::parseAndBuildLaneSpeedTrigger(), NLTriggerBuilder::parseAndBuildRerouter(), NIXMLEdgesHandler::parseSplitLanes(), and NIXMLNodesHandler::processTrafficLightDefinitions().
00376 { 00377 if (def.find(';')!=std::string::npos||def.find(',')!=std::string::npos) { 00378 if (!myHaveInformedAboutDeprecatedDivider) { 00379 MsgHandler::getWarningInstance()->inform("Please note that using ';' and ',' as XML list separators is deprecated.\n From 1.0 onwards, only ' ' will be accepted."); 00380 myHaveInformedAboutDeprecatedDivider = true; 00381 } 00382 } 00383 StringTokenizer st(def, ";, ", true); 00384 while (st.hasNext()) { 00385 into.push_back(st.next()); 00386 } 00387 }
| bool SUMOSAXAttributes::setIDFromAttributes | ( | const char * | objecttype, | |
| std::string & | id, | |||
| bool | report = true | |||
| ) | const throw () |
Tries to read the id from the attributes, stores it into "id" if given.
If there is no attribute named "id" or it is empty, false is returned. An error is reported to error message handler if "report" is true. Otherwise, the id is stored in the variable "id" and true is returned.
| [in] | objecttype | The name of the parsed object type; used for error message generation |
| [out] | id | The read id is stored herein (or "" if no id is given) |
| [in] | report | Whether missing id shall be reported to MsgHandler::getErrorInstance |
Definition at line 52 of file SUMOSAXAttributes.cpp.
References MsgHandler::getErrorInstance(), MsgHandler::inform(), and SUMO_ATTR_ID.
Referenced by NLHandler::addDetector(), NLHandler::addDistrict(), NLHandler::addE1Detector(), NLHandler::addE2Detector(), NIImporter_SUMO::addEdge(), NLHandler::addEdgeLaneMeanData(), NIImporter_SUMO::addJunction(), NLHandler::addLane(), NLHandler::addPOI(), NLHandler::addPoly(), NLHandler::addRouteProbeDetector(), NLHandler::addSource(), NLHandler::addTrigger(), NLHandler::addVTypeProbeDetector(), NLHandler::beginE3Detector(), NLHandler::beginEdgeParsing(), RORDLoader_TripDefs::getVehicleID(), NLHandler::initJunctionLogic(), NLHandler::openJunction(), MSRouteHandler::openRouteDistribution(), MSRouteHandler::openVehicleTypeDistribution(), NLHandler::openWAUT(), RONetHandler::parseEdge(), RONetHandler::parseJunction(), RONetHandler::parseLane(), and RORDLoader_SUMOBase::startAlternative().
00053 { 00054 id = ""; 00055 if (hasAttribute(SUMO_ATTR_ID)) { 00056 id = getString(SUMO_ATTR_ID); 00057 } 00058 if (id=="") { 00059 if (report) { 00060 MsgHandler::getErrorInstance()->inform("Missing id of a '" + std::string(objecttype) + "'-object."); 00061 } 00062 return false; 00063 } 00064 return true; 00065 }
bool SUMOSAXAttributes::myHaveInformedAboutDeprecatedDivider = false [static, private] |
Information whether the usage of a deprecated divider was reported.
Definition at line 502 of file SUMOSAXAttributes.h.
1.5.6