|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // Encapsulated SAX-Attributes 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 #ifndef SUMOSAXAttributes_h 00020 #define SUMOSAXAttributes_h 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include <string> 00033 #include <vector> 00034 #include <utils/common/SUMOTime.h> 00035 #include <utils/common/UtilExceptions.h> 00036 00037 00038 // =========================================================================== 00039 // class definitions 00040 // =========================================================================== 00049 class SUMOSAXAttributes { 00050 public: 00051 /* @brief Constructor 00052 * @param[in] tagName The name of the parsed object type; used for error message generation 00053 */ 00054 SUMOSAXAttributes(const std::string& objectType) throw(); 00055 00056 00058 virtual ~SUMOSAXAttributes() throw() { } 00059 00060 00074 int getIntReporting(int attr, const char* objectid, bool& ok, 00075 bool report=true) const throw(); 00076 00077 00093 int getOptIntReporting(int attr, const char* objectid, bool& ok, 00094 int defaultValue, bool report=true) const throw(); 00095 00096 00097 00111 SUMOReal getSUMORealReporting(int attr, const char* objectid, bool& ok, 00112 bool report=true) const throw(); 00113 00114 00115 00131 SUMOReal getOptSUMORealReporting(int attr, const char* objectid, bool& ok, 00132 SUMOReal defaultValue, bool report=true) const throw(); 00133 00134 00135 00149 bool getBoolReporting(int attr, const char* objectid, bool& ok, 00150 bool report=true) const throw(); 00151 00152 00153 00169 bool getOptBoolReporting(int attr, const char* objectid, bool& ok, 00170 bool defaultValue, bool report=true) const throw(); 00171 00172 00173 00187 std::string getStringReporting(int attr, const char* objectid, bool& ok, 00188 bool report=true) const throw(); 00189 00190 00191 00207 std::string getOptStringReporting(int attr, const char* objectid, bool& ok, 00208 const std::string& defaultValue, bool report=true) const throw(); 00209 00210 00211 00228 SUMOTime getSUMOTimeReporting(int attr, const char* objectid, bool& ok, 00229 bool report=true) const throw(); 00230 00231 00232 00251 SUMOTime getOptSUMOTimeReporting(int attr, const char* objectid, bool& ok, 00252 SUMOTime defaultValue, bool report=true) const throw(); 00253 00254 00255 00256 00257 00258 00259 00260 00263 00269 virtual bool hasAttribute(int id) const throw() = 0; 00270 00271 00277 virtual bool hasAttribute(const std::string& id) const throw() = 0; 00278 00279 00295 virtual bool getBool(int id) const throw(EmptyData, BoolFormatException) = 0; 00296 00311 virtual bool getBoolSecure(int id, bool val) const throw(EmptyData) = 0; 00312 00313 00329 virtual int getInt(int id) const throw(EmptyData, NumberFormatException) = 0; 00330 00331 00349 virtual int getIntSecure(int id, int def) const throw(EmptyData, NumberFormatException) = 0; 00350 00351 00364 virtual std::string getString(int id) const throw(EmptyData) = 0; 00365 00366 00379 virtual std::string getStringSecure(int id, 00380 const std::string& def) const throw(EmptyData) = 0; 00381 00382 00398 virtual SUMOReal getFloat(int id) const throw(EmptyData, NumberFormatException) = 0; 00399 00417 virtual SUMOReal getFloatSecure(int id, SUMOReal def) const throw(EmptyData, NumberFormatException) = 0; 00418 00419 00435 virtual SUMOReal getFloat(const std::string& id) const throw(EmptyData, NumberFormatException) = 0; 00436 00437 00447 virtual std::string getStringSecure(const std::string& id, 00448 const std::string& def) const throw() = 0; 00449 //} 00450 00451 00457 virtual std::string getName(int attr) const throw() = 0; 00458 00459 00468 static void parseStringVector(const std::string& def, std::vector<std::string> &into) throw(); 00469 00470 00472 const std::string& getObjectType() const { 00473 return myObjectType; 00474 } 00475 00476 00477 protected: 00478 void emitUngivenError(const std::string& attrname, const char* objectid) const throw(); 00479 void emitEmptyError(const std::string& attrname, const char* objectid) const throw(); 00480 void emitFormatError(const std::string& attrname, const std::string& type, const char* objectid) const throw(); 00481 00482 private: 00484 static bool myHaveInformedAboutDeprecatedDivider; 00485 00486 private: 00488 SUMOSAXAttributes(const SUMOSAXAttributes& src); 00489 00491 SUMOSAXAttributes& operator=(const SUMOSAXAttributes& src); 00492 00494 std::string myObjectType; 00495 00496 }; 00497 00498 00499 #endif 00500 00501 /****************************************************************************/ 00502