SUMO - Simulation of Urban MObility

SUMOSAXAttributes.h

Go to the documentation of this file.
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     SUMOReal getSUMORealReporting(int attr, const char* objectid, bool& ok,
00115                                   bool report = true) const ;
00116 
00117 
00118 
00134     SUMOReal getOptSUMORealReporting(int attr, const char* objectid, bool& ok,
00135                                      SUMOReal defaultValue, bool report = true) const ;
00136 
00137 
00138 
00152     bool getBoolReporting(int attr,  const char* objectid, bool& ok,
00153                           bool report = true) const ;
00154 
00155 
00156 
00172     bool getOptBoolReporting(int attr, const char* objectid, bool& ok,
00173                              bool defaultValue, bool report = true) const ;
00174 
00175 
00176 
00190     std::string getStringReporting(int attr, const char* objectid, bool& ok,
00191                                    bool report = true) const ;
00192 
00193 
00194 
00210     std::string getOptStringReporting(int attr, const char* objectid, bool& ok,
00211                                       const std::string& defaultValue, bool report = true) const ;
00212 
00213 
00214 
00231     SUMOTime getSUMOTimeReporting(int attr, const char* objectid, bool& ok,
00232                                   bool report = true) const ;
00233 
00234 
00235 
00254     SUMOTime getOptSUMOTimeReporting(int attr, const char* objectid, bool& ok,
00255                                      SUMOTime defaultValue, bool report = true) const ;
00256 
00257 
00258 
00259 
00260 
00261 
00262 
00263 
00266 
00272     virtual bool hasAttribute(int id) const = 0;
00273 
00274 
00280     virtual bool hasAttribute(const std::string& id) const = 0;
00281 
00282 
00298     virtual bool getBool(int id) const throw(EmptyData, BoolFormatException) = 0;
00299 
00314     virtual bool getBoolSecure(int id, bool val) const throw(EmptyData) = 0;
00315 
00316 
00332     virtual int getInt(int id) const throw(EmptyData, NumberFormatException) = 0;
00333 
00334 
00352     virtual int getIntSecure(int id, int def) const throw(EmptyData, NumberFormatException) = 0;
00353 
00354 
00367     virtual std::string getString(int id) const throw(EmptyData) = 0;
00368 
00369 
00382     virtual std::string getStringSecure(int id,
00383                                         const std::string& def) const throw(EmptyData) = 0;
00384 
00385 
00401     virtual SUMOReal getFloat(int id) const throw(EmptyData, NumberFormatException) = 0;
00402 
00420     virtual SUMOReal getFloatSecure(int id, SUMOReal def) const throw(EmptyData, NumberFormatException) = 0;
00421 
00422 
00438     virtual SUMOReal getFloat(const std::string& id) const throw(EmptyData, NumberFormatException) = 0;
00439 
00440 
00450     virtual std::string getStringSecure(const std::string& id,
00451                                         const std::string& def) const = 0;
00452     //}
00453 
00454 
00460     virtual std::string getName(int attr) const = 0;
00461 
00462 
00471     static void parseStringVector(const std::string& def, std::vector<std::string> &into) ;
00472 
00473 
00475     const std::string& getObjectType() const {
00476         return myObjectType;
00477     }
00478 
00479 
00481     static const std::string ENCODING;
00482 
00483 
00484 protected:
00485     void emitUngivenError(const std::string& attrname, const char* objectid) const ;
00486     void emitEmptyError(const std::string& attrname, const char* objectid) const ;
00487     void emitFormatError(const std::string& attrname, const std::string& type, const char* objectid) const ;
00488 
00489 private:
00491     static bool myHaveInformedAboutDeprecatedDivider;
00492 
00493 private:
00495     SUMOSAXAttributes(const SUMOSAXAttributes& src);
00496 
00498     SUMOSAXAttributes& operator=(const SUMOSAXAttributes& src);
00499 
00501     std::string myObjectType;
00502 
00503 };
00504 
00505 
00506 #endif
00507 
00508 /****************************************************************************/
00509 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines