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 
234 
241  RGBColor getColor() const;
242 
243 
249  PositionVector getShape(int attr) const;
250 
251 
257  Boundary getBoundary(int attr) const;
258 
264  std::vector<std::string> getStringVector(int attr) const;
265 
273  std::string getName(int attr) const;
274 
275 
280  void serialize(std::ostream& os) const;
281 
283  SUMOSAXAttributes* clone() const;
284 
285 private:
292  const XMLCh* getAttributeValueSecure(int id) const;
293 
294 
295 private:
297  const XERCES_CPP_NAMESPACE::Attributes& myAttrs;
298 
300  typedef std::map<int, XMLCh*> AttrMap;
302  const AttrMap& myPredefinedTags;
303 
305  const std::map<int, std::string>& myPredefinedTagsMML;
306 
307 
308 private:
311 
314 
315 
316 };
317 
318 
319 #endif
320 
321 /****************************************************************************/
322 
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.
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.