33 #include <xercesc/sax2/Attributes.hpp> 34 #include <xercesc/sax2/DefaultHandler.hpp> 35 #include <xercesc/util/XercesVersion.hpp> 36 #include <xercesc/util/TransService.hpp> 37 #include <xercesc/util/TranscodingException.hpp> 51 const std::map<int, XMLCh*>& predefinedTags,
52 const std::map<int, std::string>& predefinedTagsMML,
53 const std::string& objectType) :
56 myPredefinedTags(predefinedTags),
57 myPredefinedTagsMML(predefinedTagsMML) { }
70 return myAttrs.getIndex((*i).second) >= 0;
95 #if _XERCES_VERSION < 30100 96 char* t = XERCES_CPP_NAMESPACE::XMLString::transcode(utf16);
97 std::string result(t);
98 XERCES_CPP_NAMESPACE::XMLString::release(&t);
101 if (XERCES_CPP_NAMESPACE::XMLString::stringLen(utf16) == 0) {
106 XERCES_CPP_NAMESPACE::TranscodeToStr utf8(utf16,
"UTF-8");
108 }
catch (XERCES_CPP_NAMESPACE::TranscodingException e) {
118 const std::string& str)
const {
120 #if _XERCES_VERSION < 30100 121 char* t = XERCES_CPP_NAMESPACE::XMLString::transcode(utf16);
123 XERCES_CPP_NAMESPACE::XMLString::release(&t);
126 if (XERCES_CPP_NAMESPACE::XMLString::stringLen(utf16) == 0) {
131 XERCES_CPP_NAMESPACE::TranscodeToStr utf8(utf16,
"UTF-8");
133 }
catch (XERCES_CPP_NAMESPACE::TranscodingException e) {
151 return myAttrs.getValue((*i).second);
157 XMLCh* t = XERCES_CPP_NAMESPACE::XMLString::transcode(
id.c_str());
159 XERCES_CPP_NAMESPACE::XMLString::release(&t);
166 XMLCh* t = XERCES_CPP_NAMESPACE::XMLString::transcode(
id.c_str());
167 bool result =
myAttrs.getIndex(t) >= 0;
168 XERCES_CPP_NAMESPACE::XMLString::release(&t);
175 const std::string& str)
const {
176 XMLCh* t = XERCES_CPP_NAMESPACE::XMLString::transcode(
id.c_str());
178 XERCES_CPP_NAMESPACE::XMLString::release(&t);
221 if (pos.size() != 2 && pos.size() != 3) {
226 if (pos.size() == 2) {
241 if (st.
size() != 4) {
248 return Boundary(xmin, ymin, xmax, ymax);
252 std::vector<std::string>
255 std::vector<std::string> ret;
272 for (
int i = 0; i < (int)
myAttrs.getLength(); ++i) {
281 std::map<std::string, std::string> attrs;
282 for (
int i = 0; i < (int)
myAttrs.getLength(); ++i) {
static StringBijection< SumoXMLNodeType > NodeTypes
node types
static RGBColor parseColor(std::string coldef)
Parses a color information.
static bool _2bool(const E *const data)
converts a 0-terminated char-type array into the boolean value described by it
int getInt(int id) const
Returns the int-value of the named (by its enum-value) attribute.
static long long int _2long(const E *const data)
converts a char-type array into the long value described by it
const std::string & getObjectType() const
return the objecttype to which these attributes belong
Encapsulated Xerces-SAX-attributes.
A class that stores a 2D geometrical boundary.
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.
static void parseStringVector(const std::string &def, std::vector< std::string > &into)
Splits the given string.
Encapsulated SAX-Attributes.
const XERCES_CPP_NAMESPACE::Attributes & myAttrs
The encapsulated attributes.
A point in 2D or 3D with translation and scaling methods.
T get(const std::string &str) const
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...
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.
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 ...
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.
static double _2double(const E *const data)
converts a char-type array into the double value described by it
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.
static StringBijection< SumoXMLEdgeFunc > EdgeFunctions
edge functions
RGBColor getColor() const
Returns the value of the named attribute.
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
Boundary getBoundary(int attr) const
Tries to read given attribute assuming it is a Boundary.