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-2017 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  double getFloat(int id) const;
184 
185 
189  bool hasAttribute(const std::string& id) const;
190 
191 
207  double 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 
290  SUMOSAXAttributes* clone() const;
291 
292 private:
299  const XMLCh* getAttributeValueSecure(int id) const;
300 
301 
302 private:
304  const XERCES_CPP_NAMESPACE::Attributes& myAttrs;
305 
307  typedef std::map<int, XMLCh*> AttrMap;
309  const AttrMap& myPredefinedTags;
310 
312  const std::map<int, std::string>& myPredefinedTagsMML;
313 
314 
315 private:
318 
321 
322 
323 };
324 
325 
326 #endif
327 
328 /****************************************************************************/
329 
SUMOSAXAttributesImpl_Xerces & operator=(const SUMOSAXAttributesImpl_Xerces &src)
Invalidated assignment operator.
int getInt(int id) const
Returns the int-value of the named (by its enum-value) attribute.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
double getFloat(int id) const
Returns the double-value of the named (by its enum-value) attribute.
const std::map< int, std::string > & myPredefinedTagsMML
Map of attribute ids to their (readable) string-representation.
SUMOSAXAttributes * clone() const
return a new deep-copy attributes object
virtual ~SUMOSAXAttributesImpl_Xerces()
Destructor.
PositionVector getShape(int attr) const
Tries to read given attribute assuming it is a PositionVector.
const AttrMap & myPredefinedTags
Map of attribute ids to their xerces-representation.
Encapsulated SAX-Attributes.
const XERCES_CPP_NAMESPACE::Attributes & myAttrs
The encapsulated attributes.
A list of positions.
SumoXMLNodeType getNodeType(bool &ok) const
Returns the value of the named attribute.
bool getBool(int id) const
Returns the bool-value of the named (by its enum-value) attribute.
bool hasAttribute(int id) const
Returns the information whether the named (by its enum-value) attribute is within the current list...
Encapsulated Xerces-SAX-attributes.
std::string getString(int id) const
Returns the string-value of the named (by its enum-value) attribute.
SumoXMLEdgeFunc getEdgeFunc(bool &ok) const
Returns the value of the named attribute.
std::string getStringSecure(int id, const std::string &def) const
Returns the string-value of the named (by its enum-value) attribute.
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
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.
long long int getLong(int id) const
Returns the long-value of the named (by its enum-value) attribute.
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...
std::string getName(int attr) const
Converts the given attribute id into a man readable string.
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.
void serialize(std::ostream &os) const
Prints all attribute names and values into the given stream.
RGBColor getColor() const
Returns the value of the named attribute.
Boundary getBoundary(int attr) const
Tries to read given attribute assuming it is a Boundary.