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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // Encapsulated Xerces-SAX-attributes
18 /****************************************************************************/
19 #ifndef SUMOSAXAttributesImpl_Xerces_h
20 #define SUMOSAXAttributesImpl_Xerces_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <string>
29 #include <map>
30 #include <iostream>
31 #include <xercesc/sax2/Attributes.hpp>
32 #include <utils/common/SUMOTime.h>
34 #include "SUMOSAXAttributes.h"
35 
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
47 public:
54  SUMOSAXAttributesImpl_Xerces(const XERCES_CPP_NAMESPACE::Attributes& attrs,
55  const std::map<int, XMLCh*>& predefinedTags,
56  const std::map<int, std::string>& predefinedTagsMML,
57  const std::string& objectType);
58 
59 
62 
63 
64 
65 
68 
74  bool hasAttribute(int id) const;
75 
76 
92  bool getBool(int id) const;
93 
94 
110  int getInt(int id) const;
111 
112 
128  long long int getLong(int id) const;
129 
130 
143  std::string getString(int id) const;
144 
157  std::string getStringSecure(int id,
158  const std::string& def) const;
159 
160 
176  double getFloat(int id) const;
177 
178 
182  bool hasAttribute(const std::string& id) const;
183 
184 
200  double getFloat(const std::string& id) const;
201 
202 
212  std::string getStringSecure(const std::string& id,
213  const std::string& def) const;
214  //}
215 
216 
223  SumoXMLEdgeFunc getEdgeFunc(bool& ok) const;
224 
225 
232  SumoXMLNodeType getNodeType(bool& ok) const;
233 
235  RightOfWay getRightOfWay(bool& ok) const;
236 
243  RGBColor getColor() const;
244 
245 
251  PositionVector getShape(int attr) const;
252 
253 
259  Boundary getBoundary(int attr) const;
260 
266  std::vector<std::string> getStringVector(int attr) const;
267 
275  std::string getName(int attr) const;
276 
277 
282  void serialize(std::ostream& os) const;
283 
285  SUMOSAXAttributes* clone() const;
286 
287 private:
294  const XMLCh* getAttributeValueSecure(int id) const;
295 
296 
297 private:
299  const XERCES_CPP_NAMESPACE::Attributes& myAttrs;
300 
302  typedef std::map<int, XMLCh*> AttrMap;
304  const AttrMap& myPredefinedTags;
305 
307  const std::map<int, std::string>& myPredefinedTagsMML;
308 
309 
310 private:
313 
316 
317 
318 };
319 
320 
321 #endif
322 
323 /****************************************************************************/
324 
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.
RightOfWay getRightOfWay(bool &ok) const
returns rightOfWay method
RightOfWay
algorithms for computing right of way
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
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.