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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // Encapsulated Xerces-SAX-attributes
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <string>
26 #include <map>
27 #include <iostream>
28 #include <xercesc/sax2/Attributes.hpp>
29 #include <utils/common/SUMOTime.h>
31 #include "SUMOSAXAttributes.h"
32 
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
44 public:
51  SUMOSAXAttributesImpl_Xerces(const XERCES_CPP_NAMESPACE::Attributes& attrs,
52  const std::vector<XMLCh*>& predefinedTags,
53  const std::vector<std::string>& predefinedTagsMML,
54  const std::string& objectType);
55 
56 
59 
60 
61 
62 
65 
71  bool hasAttribute(int id) const;
72 
73 
89  bool getBool(int id) const;
90 
91 
107  int getInt(int id) const;
108 
109 
125  long long int getLong(int id) const;
126 
127 
140  std::string getString(int id) const;
141 
154  std::string getStringSecure(int id,
155  const std::string& def) const;
156 
157 
173  double getFloat(int id) const;
174 
175 
179  bool hasAttribute(const std::string& id) const;
180 
181 
197  double getFloat(const std::string& id) const;
198 
199 
209  std::string getStringSecure(const std::string& id,
210  const std::string& def) const;
211  //}
212 
213 
220  SumoXMLEdgeFunc getEdgeFunc(bool& ok) const;
221 
222 
229  SumoXMLNodeType getNodeType(bool& ok) const;
230 
232  RightOfWay getRightOfWay(bool& ok) const;
233 
235  FringeType getFringeType(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 
268  std::string getName(int attr) const;
269 
270 
275  void serialize(std::ostream& os) const;
276 
279  std::vector<std::string> getAttributeNames() const;
280 
282  SUMOSAXAttributes* clone() const;
283 
284 private:
291  const XMLCh* getAttributeValueSecure(int id) const;
292 
293 
294 private:
296  const XERCES_CPP_NAMESPACE::Attributes& myAttrs;
297 
299  typedef std::vector<XMLCh*> AttrMap;
302 
304  const std::vector<std::string>& myPredefinedTagsMML;
305 
306 private:
309 
312 
313 
314 };
FringeType
algorithms for computing right of way
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
RightOfWay
algorithms for computing right of way
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
A list of positions.
Encapsulated SAX-Attributes.
Encapsulated Xerces-SAX-attributes.
const XMLCh * getAttributeValueSecure(int id) const
Returns Xerces-value of the named attribute.
std::vector< XMLCh * > AttrMap
Definition of a map of attribute ids to their xerces-representation.
SUMOSAXAttributesImpl_Xerces & operator=(const SUMOSAXAttributesImpl_Xerces &src)
Invalidated assignment operator.
SumoXMLEdgeFunc getEdgeFunc(bool &ok) const
Returns the value of the named attribute.
RightOfWay getRightOfWay(bool &ok) const
returns rightOfWay method
const std::vector< std::string > & myPredefinedTagsMML
Map of attribute ids to their (readable) string-representation.
std::string getName(int attr) const
Converts the given attribute id into a man readable string.
std::vector< std::string > getAttributeNames() const
Retrieves all attribute names.
SumoXMLNodeType getNodeType(bool &ok) const
Returns the value of the named attribute.
const XERCES_CPP_NAMESPACE::Attributes & myAttrs
The encapsulated attributes.
bool getBool(int id) const
Returns the bool-value of the named (by its enum-value) attribute.
RGBColor getColor() 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.
FringeType getFringeType(bool &ok) const
returns fringe type
SUMOSAXAttributesImpl_Xerces(const XERCES_CPP_NAMESPACE::Attributes &attrs, const std::vector< XMLCh * > &predefinedTags, const std::vector< std::string > &predefinedTagsMML, const std::string &objectType)
Constructor.
double getFloat(int id) const
Returns the double-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 getString(int id) const
Returns the string-value of the named (by its enum-value) attribute.
const AttrMap & myPredefinedTags
Map of attribute ids to their xerces-representation.
void serialize(std::ostream &os) const
Prints all attribute names and values into the given stream.
int getInt(int id) const
Returns the int-value of the named (by its enum-value) attribute.
std::string getStringSecure(int id, const std::string &def) const
Returns the string-value of the named (by its enum-value) attribute.
Boundary getBoundary(int attr) const
Tries to read given attribute assuming it is a Boundary.
SUMOSAXAttributesImpl_Xerces(const SUMOSAXAttributesImpl_Xerces &src)
Invalidated copy constructor.
SUMOSAXAttributes * clone() const
return a new deep-copy attributes object
bool hasAttribute(int id) const
Returns the information whether the named (by its enum-value) attribute is within the current list.