Eclipse 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-2019 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 
238  FringeType getFringeType(bool& ok) const;
239 
246  RGBColor getColor() const;
247 
248 
254  PositionVector getShape(int attr) const;
255 
256 
262  Boundary getBoundary(int attr) const;
263 
271  std::string getName(int attr) const;
272 
273 
278  void serialize(std::ostream& os) const;
279 
282  std::vector<std::string> getAttributeNames() 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;
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::hasAttribute
bool hasAttribute(int id) const
Returns the information whether the named (by its enum-value) attribute is within the current list.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:58
FringeType
FringeType
algorithms for computing right of way
Definition: SUMOXMLDefinitions.h:1105
SUMOSAXAttributesImpl_Xerces::AttrMap
std::map< int, XMLCh * > AttrMap
Definition of a map of attribute ids to their xerces-representation.
Definition: SUMOSAXAttributesImpl_Xerces.h:302
SUMOSAXAttributesImpl_Xerces::getName
std::string getName(int attr) const
Converts the given attribute id into a man readable string.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:242
SUMOTime.h
SUMOSAXAttributesImpl_Xerces::getLong
long long int getLong(int id) const
Returns the long-value of the named (by its enum-value) attribute.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:80
SUMOSAXAttributesImpl_Xerces::getColor
RGBColor getColor() const
Returns the value of the named attribute.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:199
SUMOSAXAttributesImpl_Xerces
Encapsulated Xerces-SAX-attributes.
Definition: SUMOSAXAttributesImpl_Xerces.h:46
SUMOSAXAttributesImpl_Xerces::myAttrs
const XERCES_CPP_NAMESPACE::Attributes & myAttrs
The encapsulated attributes.
Definition: SUMOSAXAttributesImpl_Xerces.h:299
SumoXMLEdgeFunc
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
Definition: SUMOXMLDefinitions.h:1074
PositionVector
A list of positions.
Definition: PositionVector.h:46
SUMOSAXAttributesImpl_Xerces::clone
SUMOSAXAttributes * clone() const
return a new deep-copy attributes object
Definition: SUMOSAXAttributesImpl_Xerces.cpp:270
SUMOSAXAttributesImpl_Xerces::~SUMOSAXAttributesImpl_Xerces
virtual ~SUMOSAXAttributesImpl_Xerces()
Destructor.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:53
SUMOSAXAttributesImpl_Xerces::getShape
PositionVector getShape(int attr) const
Tries to read given attribute assuming it is a PositionVector.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:205
SUMOSAXAttributesImpl_Xerces::getStringSecure
std::string getStringSecure(int id, const std::string &def) const
Returns the string-value of the named (by its enum-value) attribute.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:92
RGBColor
Definition: RGBColor.h:40
SUMOSAXAttributesImpl_Xerces::getEdgeFunc
SumoXMLEdgeFunc getEdgeFunc(bool &ok) const
Returns the value of the named attribute.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:150
SUMOSAXAttributesImpl_Xerces::getNodeType
SumoXMLNodeType getNodeType(bool &ok) const
Returns the value of the named attribute.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:163
SumoXMLNodeType
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
Definition: SUMOXMLDefinitions.h:1049
SUMOSAXAttributesImpl_Xerces::getBool
bool getBool(int id) const
Returns the bool-value of the named (by its enum-value) attribute.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:68
SUMOSAXAttributesImpl_Xerces::getFloat
double getFloat(int id) const
Returns the double-value of the named (by its enum-value) attribute.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:104
SUMOSAXAttributesImpl_Xerces::getBoundary
Boundary getBoundary(int attr) const
Tries to read given attribute assuming it is a Boundary.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:227
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
SUMOSAXAttributesImpl_Xerces::SUMOSAXAttributesImpl_Xerces
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.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:43
SUMOSAXAttributesImpl_Xerces::getFringeType
FringeType getFringeType(bool &ok) const
returns fringe type
Definition: SUMOSAXAttributesImpl_Xerces.cpp:187
StringUtils.h
SUMOSAXAttributesImpl_Xerces::myPredefinedTagsMML
const std::map< int, std::string > & myPredefinedTagsMML
Map of attribute ids to their (readable) string-representation.
Definition: SUMOSAXAttributesImpl_Xerces.h:307
SUMOSAXAttributesImpl_Xerces::myPredefinedTags
const AttrMap & myPredefinedTags
Map of attribute ids to their xerces-representation.
Definition: SUMOSAXAttributesImpl_Xerces.h:304
RightOfWay
RightOfWay
algorithms for computing right of way
Definition: SUMOXMLDefinitions.h:1099
SUMOSAXAttributesImpl_Xerces::getInt
int getInt(int id) const
Returns the int-value of the named (by its enum-value) attribute.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:74
SUMOSAXAttributesImpl_Xerces::getAttributeValueSecure
const XMLCh * getAttributeValueSecure(int id) const
Returns Xerces-value of the named attribute.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:110
SUMOSAXAttributes.h
config.h
SUMOSAXAttributesImpl_Xerces::getAttributeNames
std::vector< std::string > getAttributeNames() const
Retrieves all attribute names.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:260
SUMOSAXAttributesImpl_Xerces::getRightOfWay
RightOfWay getRightOfWay(bool &ok) const
returns rightOfWay method
Definition: SUMOSAXAttributesImpl_Xerces.cpp:175
SUMOSAXAttributesImpl_Xerces::getString
std::string getString(int id) const
Returns the string-value of the named (by its enum-value) attribute.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:86
SUMOSAXAttributesImpl_Xerces::operator=
SUMOSAXAttributesImpl_Xerces & operator=(const SUMOSAXAttributesImpl_Xerces &src)
Invalidated assignment operator.
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:57
SUMOSAXAttributesImpl_Xerces::serialize
void serialize(std::ostream &os) const
Prints all attribute names and values into the given stream.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:251