34 #include <xercesc/sax2/Attributes.hpp>
35 #include <xercesc/sax2/DefaultHandler.hpp>
36 #include <xercesc/util/XercesVersion.hpp>
37 #include <xercesc/util/TransService.hpp>
45 #ifdef CHECK_MEMORY_LEAKS
47 #endif // CHECK_MEMORY_LEAKS
54 const std::map<int, XMLCh*>& predefinedTags,
55 const std::map<int, std::string>& predefinedTagsMML,
56 const std::string& objectType) :
59 myPredefinedTags(predefinedTags),
60 myPredefinedTagsMML(predefinedTagsMML) { }
73 return myAttrs.getIndex((*i).second) >= 0;
98 #if _XERCES_VERSION < 30100
99 char* t = XERCES_CPP_NAMESPACE::XMLString::transcode(utf16);
100 std::string result(t);
101 XERCES_CPP_NAMESPACE::XMLString::release(&t);
104 if (XERCES_CPP_NAMESPACE::XMLString::stringLen(utf16) == 0) {
108 XERCES_CPP_NAMESPACE::TranscodeToStr utf8(utf16,
"UTF-8");
117 const std::string& str)
const {
119 #if _XERCES_VERSION < 30100
120 char* t = XERCES_CPP_NAMESPACE::XMLString::transcode(utf16);
122 XERCES_CPP_NAMESPACE::XMLString::release(&t);
125 if (XERCES_CPP_NAMESPACE::XMLString::stringLen(utf16) == 0) {
129 XERCES_CPP_NAMESPACE::TranscodeToStr utf8(utf16,
"UTF-8");
146 return myAttrs.getValue((*i).second);
152 XMLCh* t = XERCES_CPP_NAMESPACE::XMLString::transcode(
id.c_str());
154 XERCES_CPP_NAMESPACE::XMLString::release(&t);
161 XMLCh* t = XERCES_CPP_NAMESPACE::XMLString::transcode(
id.c_str());
162 bool result =
myAttrs.getIndex(t) >= 0;
163 XERCES_CPP_NAMESPACE::XMLString::release(&t);
170 const std::string& str)
const {
171 XMLCh* t = XERCES_CPP_NAMESPACE::XMLString::transcode(
id.c_str());
173 XERCES_CPP_NAMESPACE::XMLString::release(&t);
216 if (pos.size() != 2 && pos.size() != 3) {
221 if (pos.size() == 2) {
236 if (st.
size() != 4) {
243 return Boundary(xmin, ymin, xmax, ymax);
247 std::vector<std::string>
250 std::vector<std::string> ret;
267 for (
int i = 0; i < (
int)
myAttrs.getLength(); ++i) {
SumoXMLEdgeFunc getEdgeFunc(bool &ok) const
Returns the value of the named attribute.
static StringBijection< SumoXMLNodeType > NodeTypes
static RGBColor parseColor(std::string coldef)
Parses a color information.
bool hasAttribute(int id) const
Returns the information whether the named (by its enum-value) attribute is within the current list...
std::string getString(int id) const
Returns the string-value of the named (by its enum-value) attribute.
SumoXMLNodeType getNodeType(bool &ok) const
Returns the value of the named attribute.
static SUMOReal _2SUMOReal(const E *const data)
static bool _2bool(const E *const data)
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.
bool getBool(int id) const
Returns the bool-value of the named (by its enum-value) attribute.
static SUMOLong _2long(const E *const data)
A class that stores a 2D geometrical boundary.
const std::map< int, std::string > & myPredefinedTagsMML
Map of attribute ids to their (readable) string-representation.
RGBColor getColor() const
Returns the value of the named attribute.
virtual ~SUMOSAXAttributesImpl_Xerces()
Destructor.
const AttrMap & myPredefinedTags
Map of attribute ids to their xerces-representation.
static void parseStringVector(const std::string &def, std::vector< std::string > &into)
Splits the given string.
std::string getStringSecure(int id, const std::string &def) const
Returns the string-value of the named (by its enum-value) attribute.
Encapsulated SAX-Attributes.
const XERCES_CPP_NAMESPACE::Attributes & myAttrs
The encapsulated attributes.
A point in 2D or 3D with translation and scaling methods.
static std::string _2str(const E *const data)
SUMOReal getFloat(int id) const
Returns the SUMOReal-value of the named (by its enum-value) attribute.
int getInt(int id) const
Returns the int-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 getName(int attr) const
Converts the given attribute id into a man readable string.
void serialize(std::ostream &os) const
Prints all attribute names and values into the given stream.
Boundary getBoundary(int attr) const
Tries to read given attribute assuming it is a Boundary.
T get(const std::string &str)
void push_back(const PositionVector &p)
Appends all positions from the given vector.
SUMOLong getLong(int id) const
Returns the long-value of the named (by its enum-value) attribute.
static int _2int(const E *const data)
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
std::vector< std::string > getStringVector(int attr) const
Tries to read given attribute assuming it is a string vector.
static StringBijection< SumoXMLEdgeFunc > EdgeFunctions
static std::string _2strSec(const E *const data, const std::string &def)
const XMLCh * getAttributeValueSecure(int id) const
Returns Xerces-value of the named attribute.