#include <SUMOSAXAttributesImpl_Xerces.h>

Definition at line 56 of file SUMOSAXAttributesImpl_Xerces.h.
methods for retrieving attribute values | |
| const Attributes & | myAttrs |
| The encapsulated attributes. | |
| const AttrMap & | myPredefinedTags |
| Map of attribute ids to their xerces-representation. | |
| const std::map< SumoXMLAttr, std::string > & | myPredefinedTagsMML |
| Map of attribute ids to their (readable) string-representation. | |
| typedef std::map< SumoXMLAttr, XMLCh * > | AttrMap |
| Definition of a map of attribute ids to their xerces-representation. | |
| bool | getBool (SumoXMLAttr id) const throw (EmptyData, BoolFormatException) |
| Returns the bool-value of the named (by its enum-value) attribute. | |
| bool | getBoolSecure (SumoXMLAttr id, bool def) const throw (EmptyData) |
| Returns the bool-value of the named (by its enum-value) attribute or the given value if the attribute is not known. | |
| SUMOReal | getFloat (const std::string &id) const throw (EmptyData, NumberFormatException) |
| Returns the SUMOReal-value of the named attribute. | |
| SUMOReal | getFloat (SumoXMLAttr id) const throw (EmptyData, NumberFormatException) |
| Returns the SUMOReal-value of the named (by its enum-value) attribute. | |
| SUMOReal | getFloatSecure (SumoXMLAttr id, SUMOReal def) const throw (EmptyData, NumberFormatException) |
| Returns the SUMOReal-value of the named (by its enum-value) attribute. | |
| int | getInt (SumoXMLAttr id) const throw (EmptyData, NumberFormatException) |
| Returns the int-value of the named (by its enum-value) attribute. | |
| int | getIntSecure (SumoXMLAttr id, int def) const throw (EmptyData, NumberFormatException) |
| Returns the int-value of the named (by its enum-value) attribute. | |
| std::string | getName (SumoXMLAttr attr) const throw () |
| Converts the given attribute id into a man readable string. | |
| std::string | getString (SumoXMLAttr id) const throw (EmptyData) |
| Returns the string-value of the named (by its enum-value) attribute. | |
| std::string | getStringSecure (const std::string &id, const std::string &def) const throw () |
| Returns the string-value of the named (by its enum-value) attribute. | |
| std::string | getStringSecure (SumoXMLAttr id, const std::string &def) const throw (EmptyData) |
| Returns the string-value of the named (by its enum-value) attribute. | |
| bool | hasAttribute (const std::string &id) const throw () |
| Returns the information whether the named attribute is within the current list. | |
| bool | hasAttribute (SumoXMLAttr id) const throw () |
| Returns the information whether the named (by its enum-value) attribute is within the current list. | |
| const XMLCh * | getAttributeValueSecure (SumoXMLAttr id) const throw () |
| Returns Xerces-value of the named attribute. | |
| SUMOSAXAttributesImpl_Xerces & | operator= (const SUMOSAXAttributesImpl_Xerces &src) |
| Invalidated assignment operator. | |
| SUMOSAXAttributesImpl_Xerces (const SUMOSAXAttributesImpl_Xerces &src) | |
| Invalidated copy constructor. | |
virtual methods for retrieving attribute values | |
| 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 () |
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. | |
| SUMOSAXAttributesImpl_Xerces (const Attributes &attrs, const std::map< SumoXMLAttr, XMLCh * > &predefinedTags, const std::map< SumoXMLAttr, std::string > &predefinedTagsMML) throw () | |
| Constructor. | |
| virtual | ~SUMOSAXAttributesImpl_Xerces () throw () |
| Destructor. | |
typedef std::map<SumoXMLAttr, XMLCh*> SUMOSAXAttributesImpl_Xerces::AttrMap [private] |
Definition of a map of attribute ids to their xerces-representation.
Definition at line 287 of file SUMOSAXAttributesImpl_Xerces.h.
| SUMOSAXAttributesImpl_Xerces::SUMOSAXAttributesImpl_Xerces | ( | const Attributes & | attrs, | |
| const std::map< SumoXMLAttr, XMLCh * > & | predefinedTags, | |||
| const std::map< SumoXMLAttr, std::string > & | predefinedTagsMML | |||
| ) | throw () |
Constructor.
| [in] | attrs | The encapsulated xerces-attributes |
| [in] | predefinedTags | Map of attribute ids to their xerces-representation |
| [in] | predefinedTagsMML | Map of attribute ids to their (readable) string-representation |
Definition at line 45 of file SUMOSAXAttributesImpl_Xerces.cpp.
00048 : myAttrs(attrs), myPredefinedTags(predefinedTags), 00049 myPredefinedTagsMML(predefinedTagsMML) { }
| SUMOSAXAttributesImpl_Xerces::~SUMOSAXAttributesImpl_Xerces | ( | ) | throw () [virtual] |
| SUMOSAXAttributesImpl_Xerces::SUMOSAXAttributesImpl_Xerces | ( | const SUMOSAXAttributesImpl_Xerces & | src | ) | [private] |
Invalidated copy constructor.
| void SUMOSAXAttributes::emitEmptyError | ( | const std::string & | attrname, | |
| const char * | objecttype, | |||
| const char * | objectid | |||
| ) | const throw () [protected, inherited] |
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, inherited] |
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, inherited] |
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 }
| const XMLCh * SUMOSAXAttributesImpl_Xerces::getAttributeValueSecure | ( | SumoXMLAttr | id | ) | const throw () [private] |
Returns Xerces-value of the named attribute.
It is assumed that this attribute is within the stored attributes.
| [in] | id | The id of the attribute to retrieve the vale of |
Definition at line 118 of file SUMOSAXAttributesImpl_Xerces.cpp.
References myAttrs, and myPredefinedTags.
Referenced by getBool(), getBoolSecure(), getFloat(), getFloatSecure(), getInt(), getIntSecure(), getString(), and getStringSecure().
00118 { 00119 AttrMap::const_iterator i=myPredefinedTags.find(id); 00120 assert(i!=myPredefinedTags.end()); 00121 return myAttrs.getValue((*i).second); 00122 }
| bool SUMOSAXAttributesImpl_Xerces::getBool | ( | SumoXMLAttr | id | ) | const throw (EmptyData, BoolFormatException) [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 |
Implements SUMOSAXAttributes.
Definition at line 67 of file SUMOSAXAttributesImpl_Xerces.cpp.
References TplConvert< E >::_2bool(), and getAttributeValueSecure().
00067 { 00068 return TplConvert<XMLCh>::_2bool(getAttributeValueSecure(id)); 00069 }
| bool SUMOSAXAttributes::getBoolReporting | ( | SumoXMLAttr | attr, | |
| const char * | objecttype, | |||
| const char * | objectid, | |||
| bool & | ok, | |||
| bool | report = true | |||
| ) | const throw () [inherited] |
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 }
| bool SUMOSAXAttributesImpl_Xerces::getBoolSecure | ( | SumoXMLAttr | id, | |
| bool | def | |||
| ) | const throw (EmptyData) [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] | def | The default value to return if the attribute is not in attributes |
| EmptyData | If the attribute value is an empty string |
Implements SUMOSAXAttributes.
Definition at line 73 of file SUMOSAXAttributesImpl_Xerces.cpp.
References TplConvertSec< E >::_2boolSec(), and getAttributeValueSecure().
00073 { 00074 return TplConvertSec<XMLCh>::_2boolSec(getAttributeValueSecure(id), val); 00075 }
| SUMOReal SUMOSAXAttributesImpl_Xerces::getFloat | ( | const std::string & | id | ) | const throw (EmptyData, NumberFormatException) [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 |
Implements SUMOSAXAttributes.
Definition at line 126 of file SUMOSAXAttributesImpl_Xerces.cpp.
References TplConvert< E >::_2SUMOReal(), and myAttrs.
00126 { 00127 XMLCh *t = XMLString::transcode(id.c_str()); 00128 return TplConvert<XMLCh>::_2SUMOReal(myAttrs.getValue(t)); 00129 }
| SUMOReal SUMOSAXAttributesImpl_Xerces::getFloat | ( | SumoXMLAttr | id | ) | const throw (EmptyData, NumberFormatException) [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 |
Implements SUMOSAXAttributes.
Definition at line 105 of file SUMOSAXAttributesImpl_Xerces.cpp.
References TplConvert< E >::_2SUMOReal(), and getAttributeValueSecure().
00105 { 00106 return TplConvert<XMLCh>::_2SUMOReal(getAttributeValueSecure(id)); 00107 }
| SUMOReal SUMOSAXAttributesImpl_Xerces::getFloatSecure | ( | SumoXMLAttr | id, | |
| SUMOReal | def | |||
| ) | const throw (EmptyData, NumberFormatException) [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 |
Implements SUMOSAXAttributes.
Definition at line 111 of file SUMOSAXAttributesImpl_Xerces.cpp.
References TplConvertSec< E >::_2SUMORealSec(), and getAttributeValueSecure().
00112 { 00113 return TplConvertSec<XMLCh>::_2SUMORealSec(getAttributeValueSecure(id), def); 00114 }
| int SUMOSAXAttributesImpl_Xerces::getInt | ( | SumoXMLAttr | id | ) | const throw (EmptyData, NumberFormatException) [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 |
Implements SUMOSAXAttributes.
Definition at line 79 of file SUMOSAXAttributesImpl_Xerces.cpp.
References TplConvert< E >::_2int(), and getAttributeValueSecure().
00079 { 00080 return TplConvert<XMLCh>::_2int(getAttributeValueSecure(id)); 00081 }
| int SUMOSAXAttributes::getIntReporting | ( | SumoXMLAttr | attr, | |
| const char * | objecttype, | |||
| const char * | objectid, | |||
| bool & | ok, | |||
| bool | report = true | |||
| ) | const throw () [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.
| [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 }
| int SUMOSAXAttributesImpl_Xerces::getIntSecure | ( | SumoXMLAttr | id, | |
| int | def | |||
| ) | const throw (EmptyData, NumberFormatException) [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 |
Implements SUMOSAXAttributes.
Definition at line 85 of file SUMOSAXAttributesImpl_Xerces.cpp.
References TplConvertSec< E >::_2intSec(), and getAttributeValueSecure().
00086 { 00087 return TplConvertSec<XMLCh>::_2intSec(getAttributeValueSecure(id), def); 00088 }
| std::string SUMOSAXAttributesImpl_Xerces::getName | ( | SumoXMLAttr | attr | ) | const throw () [virtual] |
Converts the given attribute id into a man readable string.
Returns a "?" if the attribute is not known.
| [in] | attr | The id of the attribute to return the name of |
Implements SUMOSAXAttributes.
Definition at line 148 of file SUMOSAXAttributesImpl_Xerces.cpp.
References myPredefinedTagsMML.
00148 { 00149 if (myPredefinedTagsMML.find(attr)==myPredefinedTagsMML.end()) { 00150 return "?"; 00151 } 00152 return myPredefinedTagsMML.find(attr)->second; 00153 }
| bool SUMOSAXAttributes::getOptBoolReporting | ( | SumoXMLAttr | attr, | |
| const char * | objecttype, | |||
| const char * | objectid, | |||
| bool & | ok, | |||
| bool | defaultValue, | |||
| bool | report = true | |||
| ) | const throw () [inherited] |
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 () [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.
| [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 () [inherited] |
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 () [inherited] |
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 () [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 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 }
| std::string SUMOSAXAttributesImpl_Xerces::getString | ( | SumoXMLAttr | id | ) | const throw (EmptyData) [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 |
Implements SUMOSAXAttributes.
Definition at line 92 of file SUMOSAXAttributesImpl_Xerces.cpp.
References TplConvert< E >::_2str(), and getAttributeValueSecure().
Referenced by GenericSAXHandler::startElement().
00092 { 00093 return TplConvert<XMLCh>::_2str(getAttributeValueSecure(id)); 00094 }
| std::string SUMOSAXAttributes::getStringReporting | ( | SumoXMLAttr | attr, | |
| const char * | objecttype, | |||
| const char * | objectid, | |||
| bool & | ok, | |||
| bool | report = true | |||
| ) | const throw () [inherited] |
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 }
| std::string SUMOSAXAttributesImpl_Xerces::getStringSecure | ( | const std::string & | id, | |
| const std::string & | def | |||
| ) | const throw () [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 |
Implements SUMOSAXAttributes.
Definition at line 140 of file SUMOSAXAttributesImpl_Xerces.cpp.
References TplConvertSec< E >::_2strSec(), and myAttrs.
00141 { 00142 XMLCh *t = XMLString::transcode(id.c_str()); 00143 return TplConvertSec<XMLCh>::_2strSec(myAttrs.getValue(t), str); 00144 }
| std::string SUMOSAXAttributesImpl_Xerces::getStringSecure | ( | SumoXMLAttr | id, | |
| const std::string & | def | |||
| ) | const throw (EmptyData) [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 |
Implements SUMOSAXAttributes.
Definition at line 98 of file SUMOSAXAttributesImpl_Xerces.cpp.
References TplConvertSec< E >::_2strSec(), and getAttributeValueSecure().
00099 { 00100 return TplConvertSec<XMLCh>::_2strSec(getAttributeValueSecure(id), str); 00101 }
| SUMOReal SUMOSAXAttributes::getSUMORealReporting | ( | SumoXMLAttr | attr, | |
| const char * | objecttype, | |||
| const char * | objectid, | |||
| bool & | ok, | |||
| bool | report = true | |||
| ) | const throw () [inherited] |
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 () [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 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 }
| bool SUMOSAXAttributesImpl_Xerces::hasAttribute | ( | const std::string & | id | ) | const throw () [virtual] |
Returns the information whether the named attribute is within the current list.
Implements SUMOSAXAttributes.
Definition at line 133 of file SUMOSAXAttributesImpl_Xerces.cpp.
References myAttrs.
00133 { 00134 XMLCh *t = XMLString::transcode(id.c_str()); 00135 return myAttrs.getIndex(t)>=0; 00136 }
| bool SUMOSAXAttributesImpl_Xerces::hasAttribute | ( | SumoXMLAttr | id | ) | const throw () [virtual] |
Returns the information whether the named (by its enum-value) attribute is within the current list.
| [in] | id | The id of the searched attribute |
Implements SUMOSAXAttributes.
Definition at line 57 of file SUMOSAXAttributesImpl_Xerces.cpp.
References myAttrs, and myPredefinedTags.
00057 { 00058 AttrMap::const_iterator i=myPredefinedTags.find(id); 00059 if (i==myPredefinedTags.end()) { 00060 return false; 00061 } 00062 return myAttrs.getIndex((*i).second)>=0; 00063 }
| SUMOSAXAttributesImpl_Xerces& SUMOSAXAttributesImpl_Xerces::operator= | ( | const SUMOSAXAttributesImpl_Xerces & | src | ) | [private] |
Invalidated assignment operator.
| void SUMOSAXAttributes::parseStringVector | ( | const std::string & | def, | |
| std::vector< std::string > & | into | |||
| ) | throw () [static, inherited] |
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 () [inherited] |
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 }
const Attributes& SUMOSAXAttributesImpl_Xerces::myAttrs [private] |
The encapsulated attributes.
Definition at line 284 of file SUMOSAXAttributesImpl_Xerces.h.
Referenced by getAttributeValueSecure(), getFloat(), getStringSecure(), and hasAttribute().
const AttrMap& SUMOSAXAttributesImpl_Xerces::myPredefinedTags [private] |
Map of attribute ids to their xerces-representation.
Definition at line 289 of file SUMOSAXAttributesImpl_Xerces.h.
Referenced by getAttributeValueSecure(), and hasAttribute().
const std::map<SumoXMLAttr, std::string>& SUMOSAXAttributesImpl_Xerces::myPredefinedTagsMML [private] |
Map of attribute ids to their (readable) string-representation.
Definition at line 292 of file SUMOSAXAttributesImpl_Xerces.h.
Referenced by getName().
1.5.6