SUMO - Simulation of Urban MObility
SUMOSAXAttributesImpl_Xerces.h
Go to the documentation of this file.
00001 /****************************************************************************/
00009 // Encapsulated Xerces-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 SUMOSAXAttributesImpl_Xerces_h
00023 #define SUMOSAXAttributesImpl_Xerces_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 <utils/common/SUMOTime.h>
00037 #include "SUMOSAXAttributes.h"
00038 #include <xercesc/sax2/Attributes.hpp>
00039 #include <map>
00040 
00041 
00042 // ===========================================================================
00043 // xerces 2.2 compatibility
00044 // ===========================================================================
00045 #if defined(XERCES_HAS_CPP_NAMESPACE)
00046 using namespace XERCES_CPP_NAMESPACE;
00047 #endif
00048 
00049 
00050 // ===========================================================================
00051 // class definitions
00052 // ===========================================================================
00059 class SUMOSAXAttributesImpl_Xerces : public SUMOSAXAttributes {
00060 public:
00067     SUMOSAXAttributesImpl_Xerces(const Attributes& attrs,
00068                                  const std::map<int, XMLCh*> &predefinedTags,
00069                                  const std::map<int, std::string> &predefinedTagsMML,
00070                                  const std::string& objectType) ;
00071 
00072 
00074     virtual ~SUMOSAXAttributesImpl_Xerces() ;
00075 
00076 
00077 
00078 
00081 
00087     bool hasAttribute(int id) const ;
00088 
00089 
00105     bool getBool(int id) const throw(EmptyData, BoolFormatException);
00106 
00121     bool getBoolSecure(int id, bool def) const throw(EmptyData);
00122 
00123 
00139     int getInt(int id) const throw(EmptyData, NumberFormatException);
00140 
00158     int getIntSecure(int id, int def) const throw(EmptyData, NumberFormatException);
00159 
00160 
00176     long getLong(int id) const throw(EmptyData, NumberFormatException);
00177 
00178 
00191     std::string getString(int id) const throw(EmptyData);
00192 
00205     std::string getStringSecure(int id,
00206                                 const std::string& def) const throw(EmptyData);
00207 
00208 
00224     SUMOReal getFloat(int id) const throw(EmptyData, NumberFormatException);
00225 
00243     SUMOReal getFloatSecure(int id, SUMOReal def) const throw(EmptyData, NumberFormatException);
00244 
00245 
00249     bool hasAttribute(const std::string& id) const ;
00250 
00251 
00267     SUMOReal getFloat(const std::string& id) const throw(EmptyData, NumberFormatException);
00268 
00269 
00279     std::string getStringSecure(const std::string& id,
00280                                 const std::string& def) const ;
00281     //}
00282 
00283 
00291     std::string getName(int attr) const ;
00292 
00293 
00294 private:
00301     const XMLCh* getAttributeValueSecure(int id) const ;
00302 
00303 
00304 private:
00306     const Attributes& myAttrs;
00307 
00309     typedef std::map<int, XMLCh*> AttrMap;
00311     const AttrMap& myPredefinedTags;
00312 
00314     const std::map<int, std::string> &myPredefinedTagsMML;
00315 
00316 
00317 private:
00319     SUMOSAXAttributesImpl_Xerces(const SUMOSAXAttributesImpl_Xerces& src);
00320 
00322     SUMOSAXAttributesImpl_Xerces& operator=(const SUMOSAXAttributesImpl_Xerces& src);
00323 
00324 
00325 };
00326 
00327 
00328 #endif
00329 
00330 /****************************************************************************/
00331 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines