SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00009 // Encapsulated SAX-Attributes 00010 /****************************************************************************/ 00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00013 /****************************************************************************/ 00014 // 00015 // This file is part of SUMO. 00016 // SUMO is free software: you can redistribute it and/or modify 00017 // it under the terms of the GNU General Public License as published by 00018 // the Free Software Foundation, either version 3 of the License, or 00019 // (at your option) any later version. 00020 // 00021 /****************************************************************************/ 00022 #ifndef SUMOSAXAttributes_h 00023 #define SUMOSAXAttributes_h 00024 00025 00026 // =========================================================================== 00027 // included modules 00028 // =========================================================================== 00029 #ifdef _MSC_VER 00030 #include <windows_config.h> 00031 #else 00032 #include <config.h> 00033 #endif 00034 00035 #include <string> 00036 #include <vector> 00037 #include <utils/common/SUMOTime.h> 00038 #include <utils/common/UtilExceptions.h> 00039 00040 00041 // =========================================================================== 00042 // class definitions 00043 // =========================================================================== 00052 class SUMOSAXAttributes { 00053 public: 00054 /* @brief Constructor 00055 * @param[in] tagName The name of the parsed object type; used for error message generation 00056 */ 00057 SUMOSAXAttributes(const std::string& objectType) ; 00058 00059 00061 virtual ~SUMOSAXAttributes() { } 00062 00063 00077 int getIntReporting(int attr, const char* objectid, bool& ok, 00078 bool report = true) const ; 00079 00080 00096 int getOptIntReporting(int attr, const char* objectid, bool& ok, 00097 int defaultValue, bool report = true) const ; 00098 00099 00100 00114 long getLongReporting(int attr, const char* objectid, bool& ok, 00115 bool report = true) const ; 00116 00117 00118 00132 SUMOReal getSUMORealReporting(int attr, const char* objectid, bool& ok, 00133 bool report = true) const ; 00134 00135 00136 00152 SUMOReal getOptSUMORealReporting(int attr, const char* objectid, bool& ok, 00153 SUMOReal defaultValue, bool report = true) const ; 00154 00155 00156 00170 bool getBoolReporting(int attr, const char* objectid, bool& ok, 00171 bool report = true) const ; 00172 00173 00174 00190 bool getOptBoolReporting(int attr, const char* objectid, bool& ok, 00191 bool defaultValue, bool report = true) const ; 00192 00193 00194 00208 std::string getStringReporting(int attr, const char* objectid, bool& ok, 00209 bool report = true) const ; 00210 00211 00212 00228 std::string getOptStringReporting(int attr, const char* objectid, bool& ok, 00229 const std::string& defaultValue, bool report = true) const ; 00230 00231 00232 00249 SUMOTime getSUMOTimeReporting(int attr, const char* objectid, bool& ok, 00250 bool report = true) const ; 00251 00252 00253 00272 SUMOTime getOptSUMOTimeReporting(int attr, const char* objectid, bool& ok, 00273 SUMOTime defaultValue, bool report = true) const ; 00274 00275 00276 00277 00278 00279 00280 00281 00284 00290 virtual bool hasAttribute(int id) const = 0; 00291 00292 00298 virtual bool hasAttribute(const std::string& id) const = 0; 00299 00300 00316 virtual bool getBool(int id) const throw(EmptyData, BoolFormatException) = 0; 00317 00332 virtual bool getBoolSecure(int id, bool val) const throw(EmptyData) = 0; 00333 00334 00350 virtual int getInt(int id) const throw(EmptyData, NumberFormatException) = 0; 00351 00352 00368 virtual long getLong(int id) const throw(EmptyData, NumberFormatException) = 0; 00369 00370 00388 virtual int getIntSecure(int id, int def) const throw(EmptyData, NumberFormatException) = 0; 00389 00390 00403 virtual std::string getString(int id) const throw(EmptyData) = 0; 00404 00405 00418 virtual std::string getStringSecure(int id, 00419 const std::string& def) const throw(EmptyData) = 0; 00420 00421 00437 virtual SUMOReal getFloat(int id) const throw(EmptyData, NumberFormatException) = 0; 00438 00456 virtual SUMOReal getFloatSecure(int id, SUMOReal def) const throw(EmptyData, NumberFormatException) = 0; 00457 00458 00474 virtual SUMOReal getFloat(const std::string& id) const throw(EmptyData, NumberFormatException) = 0; 00475 00476 00486 virtual std::string getStringSecure(const std::string& id, 00487 const std::string& def) const = 0; 00488 //} 00489 00490 00496 virtual std::string getName(int attr) const = 0; 00497 00498 00507 static void parseStringVector(const std::string& def, std::vector<std::string> &into) ; 00508 00509 00511 const std::string& getObjectType() const { 00512 return myObjectType; 00513 } 00514 00515 00517 static const std::string ENCODING; 00518 00519 00520 protected: 00521 void emitUngivenError(const std::string& attrname, const char* objectid) const ; 00522 void emitEmptyError(const std::string& attrname, const char* objectid) const ; 00523 void emitFormatError(const std::string& attrname, const std::string& type, const char* objectid) const ; 00524 00525 private: 00527 static bool myHaveInformedAboutDeprecatedDivider; 00528 00529 private: 00531 SUMOSAXAttributes(const SUMOSAXAttributes& src); 00532 00534 SUMOSAXAttributes& operator=(const SUMOSAXAttributes& src); 00535 00537 std::string myObjectType; 00538 00539 }; 00540 00541 00542 #endif 00543 00544 /****************************************************************************/ 00545