SUMO - Simulation of Urban MObility
SUMOSAXAttributesImpl_Xerces.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2007-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // Encapsulated Xerces-SAX-attributes
20 /****************************************************************************/
21 #ifndef SUMOSAXAttributesImpl_Xerces_h
22 #define SUMOSAXAttributesImpl_Xerces_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <string>
35 #include <map>
36 #include <iostream>
37 #include <xercesc/sax2/Attributes.hpp>
38 #include <utils/common/SUMOTime.h>
40 #include "SUMOSAXAttributes.h"
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
53 public:
60  SUMOSAXAttributesImpl_Xerces(const XERCES_CPP_NAMESPACE::Attributes& attrs,
61  const std::map<int, XMLCh*>& predefinedTags,
62  const std::map<int, std::string>& predefinedTagsMML,
63  const std::string& objectType);
64 
65 
68 
69 
70 
71 
74 
80  bool hasAttribute(int id) const;
81 
82 
98  bool getBool(int id) const;
99 
100 
116  int getInt(int id) const;
117 
118 
134  long long int getLong(int id) const;
135 
136 
149  std::string getString(int id) const;
150 
163  std::string getStringSecure(int id,
164  const std::string& def) const;
165 
166 
182  double getFloat(int id) const;
183 
184 
188  bool hasAttribute(const std::string& id) const;
189 
190 
206  double getFloat(const std::string& id) const;
207 
208 
218  std::string getStringSecure(const std::string& id,
219  const std::string& def) const;
220  //}
221 
222 
229  SumoXMLEdgeFunc getEdgeFunc(bool& ok) const;
230 
231 
238  SumoXMLNodeType getNodeType(bool& ok) const;
239 
240 
247  RGBColor getColor() const;
248 
249 
255  PositionVector getShape(int attr) const;
256 
257 
263  Boundary getBoundary(int attr) const;
264 
270  std::vector<std::string> getStringVector(int attr) const;
271 
279  std::string getName(int attr) const;
280 
281 
286  void serialize(std::ostream& os) const;
287 
289  SUMOSAXAttributes* clone() const;
290 
291 private:
298  const XMLCh* getAttributeValueSecure(int id) const;
299 
300 
301 private:
303  const XERCES_CPP_NAMESPACE::Attributes& myAttrs;
304 
306  typedef std::map<int, XMLCh*> AttrMap;
308  const AttrMap& myPredefinedTags;
309 
311  const std::map<int, std::string>& myPredefinedTagsMML;
312 
313 
314 private:
317 
320 
321 
322 };
323 
324 
325 #endif
326 
327 /****************************************************************************/
328 
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:47
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.
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 ...
SUMOSAXAttributes * clone() const
return a new deep-copy attributes object
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::vector< std::string > getStringVector(int attr) const
Tries to read given attribute assuming it is a string vector.
double getFloat(int id) const
Returns the double-value of the named (by its enum-value) attribute.
const XMLCh * getAttributeValueSecure(int id) const
Returns Xerces-value of the named attribute.