SUMO - Simulation of Urban MObility
SUMOSAXAttributesImpl_Xerces.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Encapsulated Xerces-SAX-attributes
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2007-2015 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef SUMOSAXAttributesImpl_Xerces_h
23 #define SUMOSAXAttributesImpl_Xerces_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <map>
37 #include <iostream>
38 #include <xercesc/sax2/Attributes.hpp>
39 #include <utils/common/SUMOTime.h>
41 #include "SUMOSAXAttributes.h"
42 
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
54 public:
61  SUMOSAXAttributesImpl_Xerces(const XERCES_CPP_NAMESPACE::Attributes& attrs,
62  const std::map<int, XMLCh*>& predefinedTags,
63  const std::map<int, std::string>& predefinedTagsMML,
64  const std::string& objectType);
65 
66 
69 
70 
71 
72 
75 
81  bool hasAttribute(int id) const;
82 
83 
99  bool getBool(int id) const;
100 
101 
117  int getInt(int id) const;
118 
119 
135  long long int getLong(int id) const;
136 
137 
150  std::string getString(int id) const;
151 
164  std::string getStringSecure(int id,
165  const std::string& def) const;
166 
167 
183  SUMOReal getFloat(int id) const;
184 
185 
189  bool hasAttribute(const std::string& id) const;
190 
191 
207  SUMOReal getFloat(const std::string& id) const;
208 
209 
219  std::string getStringSecure(const std::string& id,
220  const std::string& def) const;
221  //}
222 
223 
230  SumoXMLEdgeFunc getEdgeFunc(bool& ok) const;
231 
232 
239  SumoXMLNodeType getNodeType(bool& ok) const;
240 
241 
248  RGBColor getColor() const;
249 
250 
256  PositionVector getShape(int attr) const;
257 
258 
264  Boundary getBoundary(int attr) const;
265 
271  std::vector<std::string> getStringVector(int attr) const;
272 
280  std::string getName(int attr) const;
281 
282 
287  void serialize(std::ostream& os) const;
288 
289 
290 private:
297  const XMLCh* getAttributeValueSecure(int id) const;
298 
299 
300 private:
302  const XERCES_CPP_NAMESPACE::Attributes& myAttrs;
303 
305  typedef std::map<int, XMLCh*> AttrMap;
307  const AttrMap& myPredefinedTags;
308 
310  const std::map<int, std::string>& myPredefinedTagsMML;
311 
312 
313 private:
316 
319 
320 
321 };
322 
323 
324 #endif
325 
326 /****************************************************************************/
327 
SumoXMLEdgeFunc getEdgeFunc(bool &ok) const
Returns the value of the named attribute.
SUMOSAXAttributesImpl_Xerces & operator=(const SUMOSAXAttributesImpl_Xerces &src)
Invalidated assignment operator.
bool hasAttribute(int id) const
Returns the information whether the named (by its enum-value) attribute is within the current list...
std::string getString(int id) const
Returns the string-value of the named (by its enum-value) attribute.
SumoXMLNodeType getNodeType(bool &ok) const
Returns the value of the named attribute.
long long int getLong(int id) const
Returns the long-value of the named (by its enum-value) attribute.
SUMOSAXAttributesImpl_Xerces(const XERCES_CPP_NAMESPACE::Attributes &attrs, const std::map< int, XMLCh * > &predefinedTags, const std::map< int, std::string > &predefinedTagsMML, const std::string &objectType)
Constructor.
bool getBool(int id) const
Returns the bool-value of the named (by its enum-value) attribute.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
const std::map< int, std::string > & myPredefinedTagsMML
Map of attribute ids to their (readable) string-representation.
RGBColor getColor() const
Returns the value of the named attribute.
virtual ~SUMOSAXAttributesImpl_Xerces()
Destructor.
const AttrMap & myPredefinedTags
Map of attribute ids to their xerces-representation.
std::string getStringSecure(int id, const std::string &def) const
Returns the string-value of the named (by its enum-value) attribute.
Encapsulated SAX-Attributes.
const XERCES_CPP_NAMESPACE::Attributes & myAttrs
The encapsulated attributes.
A list of positions.
SUMOReal getFloat(int id) const
Returns the SUMOReal-value of the named (by its enum-value) attribute.
int getInt(int id) const
Returns the int-value of the named (by its enum-value) attribute.
PositionVector getShape(int attr) const
Tries to read given attribute assuming it is a PositionVector.
std::string getName(int attr) const
Converts the given attribute id into a man readable string.
Encapsulated Xerces-SAX-attributes.
void serialize(std::ostream &os) const
Prints all attribute names and values into the given stream.
Boundary getBoundary(int attr) const
Tries to read given attribute assuming it is a Boundary.
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
std::map< int, XMLCh * > AttrMap
Definition of a map of attribute ids to their xerces-representation.
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
#define SUMOReal
Definition: config.h:214
std::vector< std::string > getStringVector(int attr) const
Tries to read given attribute assuming it is a string vector.
const XMLCh * getAttributeValueSecure(int id) const
Returns Xerces-value of the named attribute.