49 const std::map<int, std::string>& predefinedTagsMML,
50 const std::string& objectType,
54 unsigned char attrByte;
60 attr += 256 * attrByte;
62 int type = in->
peek();
81 const int type = in->
peek();
85 throw ProcessError(
"Invalid binary file, only supporting position vectors.");
95 *in >> myIntValues[attr];
98 *in >> myIntValues[attr];
100 *in >> myCharValues[attr];
121 *in >> myIntValues[attr];
124 *in >> myCharValues[attr];
127 *in >> myCharValues[attr];
130 std::ostringstream into(std::ios::binary);
136 int intsToRead = size - 1;
141 if (bitsOrEntry < 0) {
142 intsToRead = (-bitsOrEntry * (size - 1) - 1) /
sizeof(int) / 8 + 2;
144 while (intsToRead > 0) {
151 myStringValues[attr] = into.str();
155 throw ProcessError(
"Binary file is invalid, attribute type is unknown.");
174 const std::map<int, char>::const_iterator i =
myCharValues.find(
id);
178 return i->second != 0;
184 const std::map<int, int>::const_iterator i =
myIntValues.find(
id);
200 const std::map<int, std::string>::const_iterator i =
myStringValues.find(
id);
210 const std::string& str)
const {
211 const std::map<int, std::string>::const_iterator i =
myStringValues.find(
id);
221 const std::map<int, double>::const_iterator i =
myFloatValues.find(
id);
243 const std::string& )
const {
252 const char func = i->second;
266 const char type = i->second;
282 const int val = i->second;
283 return RGBColor(val & 0xff, (val >> 8) & 0xff, (val >> 16) & 0xff, (val >> 24) & 0xff);
289 const std::map<int, PositionVector>::const_iterator i =
myPositionVectors.find(attr);
299 const std::map<int, PositionVector>::const_iterator i =
myPositionVectors.find(attr);
303 if (i->second.size() != 2) {
306 return Boundary(i->second[0].x(), i->second[0].y(), i->second[1].x(), i->second[1].y());
310 std::vector<std::string>
313 std::vector<std::string> ret;
330 for (std::set<int>::const_iterator i =
myAttrs.begin(); i !=
myAttrs.end(); ++i) {
339 std::map<std::string, std::string> attrs;
341 const std::string attrName =
myAttrIds.find(it->first)->second;
342 attrs[attrName] =
toString(it->second);
345 const std::string attrName =
myAttrIds.find(it->first)->second;
346 attrs[attrName] =
toString(it->second);
349 const std::string attrName =
myAttrIds.find(it->first)->second;
350 attrs[attrName] =
toString(it->second);
353 const std::string attrName =
myAttrIds.find(it->first)->second;
354 attrs[attrName] = it->second;
357 const std::string attrName =
myAttrIds.find(it->first)->second;
358 attrs[attrName] =
toString(it->second);
std::vector< std::string > getStringVector(int attr) const
Tries to read given attribute assuming it is a string vector.
PositionVector getShape(int attr) const
Tries to read given attribute assuming it is a PositionVector.
static StringBijection< SumoXMLNodeType > NodeTypes
node types
long long int getLong(int id) const
Returns the long-value of the named (by its enum-value) attribute.
std::map< int, char > myCharValues
Map of attribute ids to char.
std::map< int, double > myFloatValues
Map of attribute ids to floats.
SumoXMLEdgeFunc getEdgeFunc(bool &ok) const
Returns the value of the named attribute.
bool hasAttribute(int id) const
Returns the information whether the named (by its enum-value) attribute is within the current list...
const std::string & getObjectType() const
return the objecttype to which these attributes belong
SUMOSAXAttributes * clone() const
return a new deep-copy attributes object
Encapsulated Xerces-SAX-attributes.
std::map< int, std::string > myStringValues
Map of attribute ids to string.
A class that stores a 2D geometrical boundary.
std::string getString(int id) const
Returns the string-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 toString(const T &t, std::streamsize accuracy=gPrecision)
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.
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.
RGBColor getColor() const
Returns the value of the named attribute.
int getInt(int id) const
Returns the int-value of the named (by its enum-value) attribute.
double getFloat(int id) const
Returns the double-value of the named (by its enum-value) attribute.
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 ...
SUMOSAXAttributesImpl_Binary(const std::map< int, std::string > &predefinedTagsMML, const std::string &objectType, BinaryInputDevice *in, const char version)
Constructor.
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...
bool getBool(int id) const
Returns the bool-value of the named (by its enum-value) attribute.
virtual ~SUMOSAXAttributesImpl_Binary()
Destructor.
std::string getName(int attr) const
Converts the given attribute id into a man readable string.
static StringBijection< SumoXMLEdgeFunc > EdgeFunctions
edge functions
Boundary getBoundary(int attr) const
Tries to read given attribute assuming it is a Boundary.
SumoXMLNodeType getNodeType(bool &ok) const
Returns the value of the named attribute.
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.