34 #include <xercesc/sax2/Attributes.hpp> 35 #include <xercesc/sax2/DefaultHandler.hpp> 36 #include <xercesc/util/XercesVersion.hpp> 37 #include <xercesc/util/TransService.hpp> 38 #include <xercesc/util/TranscodingException.hpp> 46 #ifdef CHECK_MEMORY_LEAKS 48 #endif // CHECK_MEMORY_LEAKS 55 const std::map<int, XMLCh*>& predefinedTags,
56 const std::map<int, std::string>& predefinedTagsMML,
57 const std::string& objectType) :
60 myPredefinedTags(predefinedTags),
61 myPredefinedTagsMML(predefinedTagsMML) { }
74 return myAttrs.getIndex((*i).second) >= 0;
99 #if _XERCES_VERSION < 30100 100 char* t = XERCES_CPP_NAMESPACE::XMLString::transcode(utf16);
101 std::string result(t);
102 XERCES_CPP_NAMESPACE::XMLString::release(&t);
105 if (XERCES_CPP_NAMESPACE::XMLString::stringLen(utf16) == 0) {
110 XERCES_CPP_NAMESPACE::TranscodeToStr utf8(utf16,
"UTF-8");
112 }
catch (XERCES_CPP_NAMESPACE::TranscodingException e) {
122 const std::string& str)
const {
124 #if _XERCES_VERSION < 30100 125 char* t = XERCES_CPP_NAMESPACE::XMLString::transcode(utf16);
127 XERCES_CPP_NAMESPACE::XMLString::release(&t);
130 if (XERCES_CPP_NAMESPACE::XMLString::stringLen(utf16) == 0) {
135 XERCES_CPP_NAMESPACE::TranscodeToStr utf8(utf16,
"UTF-8");
137 }
catch (XERCES_CPP_NAMESPACE::TranscodingException e) {
155 return myAttrs.getValue((*i).second);
161 XMLCh* t = XERCES_CPP_NAMESPACE::XMLString::transcode(
id.c_str());
163 XERCES_CPP_NAMESPACE::XMLString::release(&t);
170 XMLCh* t = XERCES_CPP_NAMESPACE::XMLString::transcode(
id.c_str());
171 bool result =
myAttrs.getIndex(t) >= 0;
172 XERCES_CPP_NAMESPACE::XMLString::release(&t);
179 const std::string& str)
const {
180 XMLCh* t = XERCES_CPP_NAMESPACE::XMLString::transcode(
id.c_str());
182 XERCES_CPP_NAMESPACE::XMLString::release(&t);
225 if (pos.size() != 2 && pos.size() != 3) {
230 if (pos.size() == 2) {
245 if (st.
size() != 4) {
252 return Boundary(xmin, ymin, xmax, ymax);
256 std::vector<std::string>
259 std::vector<std::string> ret;
276 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.
long long int getLong(int id) const
Returns the long-value of the named (by its enum-value) attribute.
static SUMOReal _2SUMOReal(const E *const data)
converts a char-type array into the SUMOReal value described by it
static bool _2bool(const E *const data)
converts a 0-terminated char-type array into the boolean value described by it
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.
static long long int _2long(const E *const data)
converts a char-type array into the long value described by it
bool getBool(int id) const
Returns the bool-value of the named (by its enum-value) attribute.
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.
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.
static int _2int(const E *const data)
converts a char-type array into the integer value described by it
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...
T get(const std::string &str) const
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 _2str(const int var)
convert int to string
static std::string _2strSec(const E *const data, const std::string &def)
converts a 0-terminated char-type array into std::string
const XMLCh * getAttributeValueSecure(int id) const
Returns Xerces-value of the named attribute.