Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
SUMOSAXAttributesImpl_Xerces.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2007-2023 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>
31#include "SUMOSAXAttributes.h"
32
33
34// ===========================================================================
35// class definitions
36// ===========================================================================
44public:
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
86 std::string getString(int id, bool* isPresent = nullptr) const;
87
100 std::string getStringSecure(int id, const std::string& def) const;
101
105 bool hasAttribute(const std::string& id) const;
106
122 double getFloat(const std::string& id) const;
123
133 std::string getStringSecure(const std::string& id,
134 const std::string& def) const;
135 //}
136
144 std::string getName(int attr) const;
145
146
151 void serialize(std::ostream& os) const;
152
155 std::vector<std::string> getAttributeNames() const;
156
158 SUMOSAXAttributes* clone() const;
159
160private:
167 const XMLCh* getAttributeValueSecure(int id) const;
168
169
170private:
172 const XERCES_CPP_NAMESPACE::Attributes& myAttrs;
173
175 typedef std::vector<XMLCh*> AttrMap;
178
180 const std::vector<std::string>& myPredefinedTagsMML;
181
182private:
185
188
189
190};
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.
std::string getString(int id, bool *isPresent=nullptr) const
Returns the string-value of the named (by its enum-value) attribute.
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.
SUMOSAXAttributesImpl_Xerces & operator=(const SUMOSAXAttributesImpl_Xerces &src)
Invalidated assignment operator.
const XERCES_CPP_NAMESPACE::Attributes & myAttrs
The encapsulated attributes.
double getFloat(const std::string &id) const
Returns the double-value of the named 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.
std::string getStringSecure(int id, const std::string &def) const
Returns the string-value of the named (by its enum-value) attribute.
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.