43 #ifdef CHECK_MEMORY_LEAKS
45 #endif // CHECK_MEMORY_LEAKS
52 const std::map<int, std::string>& predefinedTagsMML,
53 const std::string& objectType,
58 int type = in->
peek();
77 const int type = in->
peek();
81 throw ProcessError(
"Invalid binary file, only supporting position vectors.");
91 *in >> myIntValues[attr];
94 *in >> myIntValues[attr];
96 *in >> myCharValues[attr];
117 *in >> myIntValues[attr];
120 *in >> myCharValues[attr];
123 *in >> myCharValues[attr];
126 std::ostringstream into(std::ios::binary);
132 int intsToRead = size - 1;
137 if (bitsOrEntry < 0) {
138 intsToRead = (-bitsOrEntry * (size - 1) - 1) /
sizeof(int) / 8 + 2;
140 while (intsToRead > 0) {
147 myStringValues[attr] = into.str();
170 const std::map<int, char>::const_iterator i =
myCharValues.find(
id);
174 return i->second != 0;
180 const std::map<int, int>::const_iterator i =
myIntValues.find(
id);
196 const std::map<int, std::string>::const_iterator i =
myStringValues.find(
id);
206 const std::string& str)
const {
207 const std::map<int, std::string>::const_iterator i =
myStringValues.find(
id);
217 const std::map<int, SUMOReal>::const_iterator i =
myFloatValues.find(
id);
239 const std::string& )
const {
248 const char func = i->second;
262 const char type = i->second;
278 const int val = i->second;
279 return RGBColor(val & 0xff, (val >> 8) & 0xff, (val >> 16) & 0xff, (val >> 24) & 0xff);
285 const std::map<int, PositionVector>::const_iterator i =
myPositionVectors.find(attr);
295 const std::map<int, PositionVector>::const_iterator i =
myPositionVectors.find(attr);
299 if (i->second.size() != 2) {
302 return Boundary(i->second[0].x(), i->second[0].y(), i->second[1].x(), i->second[1].y());
306 std::vector<std::string>
309 std::vector<std::string> ret;
326 for (std::set<int>::const_iterator i =
myAttrs.begin(); i !=
myAttrs.end(); ++i) {
void serialize(std::ostream &os) const
Prints all attribute names and values into the given stream.
PositionVector getShape(int attr) const
Tries to read given attribute assuming it is a PositionVector.
static StringBijection< SumoXMLNodeType > NodeTypes
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
std::map< int, char > myCharValues
Map of attribute ids to char.
RGBColor getColor() const
Returns the value of the named attribute.
SumoXMLEdgeFunc getEdgeFunc(bool &ok) const
Returns the value of the named attribute.
std::string getName(int attr) const
Converts the given attribute id into a man readable string.
int getInt(int id) const
Returns the int-value of the named (by its enum-value) attribute.
std::map< int, std::string > myStringValues
Map of attribute ids to string.
A class that stores a 2D geometrical boundary.
SUMOReal getFloat(int id) const
Returns the SUMOReal-value of the named (by its enum-value) attribute.
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.
A point in 2D or 3D with translation and scaling methods.
const std::map< int, std::string > & myAttrIds
Map of attribute ids to names.
std::vector< std::string > getStringVector(int attr) const
Tries to read given attribute assuming it is a string vector.
static std::ostream & writeInt(std::ostream &strm, int value)
Writes an integer binary.
static std::ostream & writeByte(std::ostream &strm, unsigned char value)
Writes a byte binary.
std::map< int, SUMOReal > myFloatValues
Map of attribute ids to floats.
SumoXMLNodeType getNodeType(bool &ok) const
Returns the value of the named attribute.
SUMOSAXAttributesImpl_Binary(const std::map< int, std::string > &predefinedTagsMML, const std::string &objectType, BinaryInputDevice *in)
Constructor.
std::map< int, int > myIntValues
Map of attribute ids to integers.
std::map< int, PositionVector > myPositionVectors
Map of attribute ids to string.
std::set< int > myAttrs
the attributes which are set
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
bool hasAttribute(int id) const
Returns the information whether the named (by its enum-value) attribute is within the current list...
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
virtual ~SUMOSAXAttributesImpl_Binary()
Destructor.
bool getBool(int id) const
Returns the bool-value of the named (by its enum-value) attribute.
Boundary getBoundary(int attr) const
Tries to read given attribute assuming it is a Boundary.
std::string getString(int id) const
Returns the string-value of the named (by its enum-value) attribute.
static StringBijection< SumoXMLEdgeFunc > EdgeFunctions