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 /****************************************************************************/
16 // Encapsulated Xerces-SAX-attributes
17 /****************************************************************************/
18 #ifndef SUMOSAXAttributesImpl_Xerces_h
19 #define SUMOSAXAttributesImpl_Xerces_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <string>
28 #include <map>
29 #include <iostream>
30 #include <xercesc/sax2/Attributes.hpp>
31 #include <utils/common/SUMOTime.h>
33 #include "SUMOSAXAttributes.h"
34 
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
46 public:
53  SUMOSAXAttributesImpl_Xerces(const XERCES_CPP_NAMESPACE::Attributes& attrs,
54  const std::map<int, XMLCh*>& predefinedTags,
55  const std::map<int, std::string>& predefinedTagsMML,
56  const std::string& objectType);
57 
58 
61 
62 
63 
64 
67 
73  bool hasAttribute(int id) const;
74 
75 
91  bool getBool(int id) const;
92 
93 
109  int getInt(int id) const;
110 
111 
127  long long int getLong(int id) const;
128 
129 
142  std::string getString(int id) const;
143 
156  std::string getStringSecure(int id,
157  const std::string& def) const;
158 
159 
175  double getFloat(int id) const;
176 
177 
181  bool hasAttribute(const std::string& id) const;
182 
183 
199  double getFloat(const std::string& id) const;
200 
201 
211  std::string getStringSecure(const std::string& id,
212  const std::string& def) const;
213  //}
214 
215 
222  SumoXMLEdgeFunc getEdgeFunc(bool& ok) const;
223 
224 
231  SumoXMLNodeType getNodeType(bool& ok) const;
232 
234  RightOfWay getRightOfWay(bool& ok) const;
235 
237  FringeType getFringeType(bool& ok) const;
238 
245  RGBColor getColor() const;
246 
247 
253  PositionVector getShape(int attr) const;
254 
255 
261  Boundary getBoundary(int attr) const;
262 
270  std::string getName(int attr) const;
271 
272 
277  void serialize(std::ostream& os) const;
278 
281  std::vector<std::string> getAttributeNames() const;
282 
284  SUMOSAXAttributes* clone() const;
285 
286 private:
293  const XMLCh* getAttributeValueSecure(int id) const;
294 
295 
296 private:
298  const XERCES_CPP_NAMESPACE::Attributes& myAttrs;
299 
301  typedef std::map<int, XMLCh*> AttrMap;
304 
306  const std::map<int, std::string>& myPredefinedTagsMML;
307 
308 
309 private:
312 
315 
316 
317 };
318 
319 
320 #endif
321 
322 /****************************************************************************/
323 
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:57
FringeType
FringeType
algorithms for computing right of way
Definition: SUMOXMLDefinitions.h:1110
SUMOSAXAttributesImpl_Xerces::AttrMap
std::map< int, XMLCh * > AttrMap
Definition of a map of attribute ids to their xerces-representation.
Definition: SUMOSAXAttributesImpl_Xerces.h:301
SUMOSAXAttributesImpl_Xerces::getName
std::string getName(int attr) const
Converts the given attribute id into a man readable string.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:241
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:79
SUMOSAXAttributesImpl_Xerces::getColor
RGBColor getColor() const
Returns the value of the named attribute.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:198
SUMOSAXAttributesImpl_Xerces
Encapsulated Xerces-SAX-attributes.
Definition: SUMOSAXAttributesImpl_Xerces.h:45
SUMOSAXAttributesImpl_Xerces::myAttrs
const XERCES_CPP_NAMESPACE::Attributes & myAttrs
The encapsulated attributes.
Definition: SUMOSAXAttributesImpl_Xerces.h:298
SumoXMLEdgeFunc
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
Definition: SUMOXMLDefinitions.h:1079
SUMOSAXAttributesImpl_Xerces::SUMOSAXAttributesImpl_Xerces
SUMOSAXAttributesImpl_Xerces(const SUMOSAXAttributesImpl_Xerces &src)
Invalidated copy constructor.
PositionVector
A list of positions.
Definition: PositionVector.h:45
SUMOSAXAttributesImpl_Xerces::clone
SUMOSAXAttributes * clone() const
return a new deep-copy attributes object
Definition: SUMOSAXAttributesImpl_Xerces.cpp:269
SUMOSAXAttributesImpl_Xerces::~SUMOSAXAttributesImpl_Xerces
virtual ~SUMOSAXAttributesImpl_Xerces()
Destructor.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:52
SUMOSAXAttributesImpl_Xerces::getShape
PositionVector getShape(int attr) const
Tries to read given attribute assuming it is a PositionVector.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:204
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:91
RGBColor
Definition: RGBColor.h:39
SUMOSAXAttributesImpl_Xerces::getEdgeFunc
SumoXMLEdgeFunc getEdgeFunc(bool &ok) const
Returns the value of the named attribute.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:149
SUMOSAXAttributesImpl_Xerces::getNodeType
SumoXMLNodeType getNodeType(bool &ok) const
Returns the value of the named attribute.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:162
SumoXMLNodeType
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
Definition: SUMOXMLDefinitions.h:1054
SUMOSAXAttributesImpl_Xerces::getBool
bool getBool(int id) const
Returns the bool-value of the named (by its enum-value) attribute.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:67
SUMOSAXAttributesImpl_Xerces::getFloat
double getFloat(int id) const
Returns the double-value of the named (by its enum-value) attribute.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:103
SUMOSAXAttributesImpl_Xerces::getBoundary
Boundary getBoundary(int attr) const
Tries to read given attribute assuming it is a Boundary.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:226
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
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:42
SUMOSAXAttributesImpl_Xerces::getFringeType
FringeType getFringeType(bool &ok) const
returns fringe type
Definition: SUMOSAXAttributesImpl_Xerces.cpp:186
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:306
SUMOSAXAttributesImpl_Xerces::myPredefinedTags
const AttrMap & myPredefinedTags
Map of attribute ids to their xerces-representation.
Definition: SUMOSAXAttributesImpl_Xerces.h:303
RightOfWay
RightOfWay
algorithms for computing right of way
Definition: SUMOXMLDefinitions.h:1104
SUMOSAXAttributesImpl_Xerces::getInt
int getInt(int id) const
Returns the int-value of the named (by its enum-value) attribute.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:73
SUMOSAXAttributesImpl_Xerces::getAttributeValueSecure
const XMLCh * getAttributeValueSecure(int id) const
Returns Xerces-value of the named attribute.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:109
SUMOSAXAttributes.h
config.h
SUMOSAXAttributesImpl_Xerces::getAttributeNames
std::vector< std::string > getAttributeNames() const
Retrieves all attribute names.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:259
SUMOSAXAttributesImpl_Xerces::getRightOfWay
RightOfWay getRightOfWay(bool &ok) const
returns rightOfWay method
Definition: SUMOSAXAttributesImpl_Xerces.cpp:174
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:85
SUMOSAXAttributesImpl_Xerces::operator=
SUMOSAXAttributesImpl_Xerces & operator=(const SUMOSAXAttributesImpl_Xerces &src)
Invalidated assignment operator.
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:56
SUMOSAXAttributesImpl_Xerces::serialize
void serialize(std::ostream &os) const
Prints all attribute names and values into the given stream.
Definition: SUMOSAXAttributesImpl_Xerces.cpp:250