48 const std::map<int, std::string>& predefinedTagsMML,
49 const std::string& objectType,
53 unsigned char attrByte;
59 attr += 256 * attrByte;
61 int type = in->
peek();
80 const int type = in->
peek();
84 throw ProcessError(
"Invalid binary file, only supporting position vectors.");
94 *in >> myIntValues[attr];
97 *in >> myIntValues[attr];
99 *in >> myCharValues[attr];
120 *in >> myIntValues[attr];
123 *in >> myCharValues[attr];
126 *in >> myCharValues[attr];
129 std::ostringstream into(std::ios::binary);
135 int intsToRead = size - 1;
140 if (bitsOrEntry < 0) {
141 intsToRead = (-bitsOrEntry * (size - 1) - 1) /
sizeof(int) / 8 + 2;
143 while (intsToRead > 0) {
150 myStringValues[attr] = into.str();
154 throw ProcessError(
"Binary file is invalid, attribute type is unknown.");
173 const std::map<int, char>::const_iterator i =
myCharValues.find(
id);
177 return i->second != 0;
183 const std::map<int, int>::const_iterator i =
myIntValues.find(
id);
199 const std::map<int, std::string>::const_iterator i =
myStringValues.find(
id);
209 const std::string& str)
const {
210 const std::map<int, std::string>::const_iterator i =
myStringValues.find(
id);
220 const std::map<int, double>::const_iterator i =
myFloatValues.find(
id);
242 const std::string& )
const {
251 const char func = i->second;
265 const char type = i->second;
281 const int val = i->second;
282 return RGBColor(val & 0xff, (val >> 8) & 0xff, (val >> 16) & 0xff, (val >> 24) & 0xff);
288 const std::map<int, PositionVector>::const_iterator i =
myPositionVectors.find(attr);
298 const std::map<int, PositionVector>::const_iterator i =
myPositionVectors.find(attr);
302 if (i->second.size() != 2) {
305 return Boundary(i->second[0].x(), i->second[0].y(), i->second[1].x(), i->second[1].y());
309 std::vector<std::string>
312 std::vector<std::string> ret;
329 for (std::set<int>::const_iterator i =
myAttrs.begin(); i !=
myAttrs.end(); ++i) {
338 std::map<std::string, std::string> attrs;
340 const std::string attrName =
myAttrIds.find(it->first)->second;
341 attrs[attrName] =
toString(it->second);
344 const std::string attrName =
myAttrIds.find(it->first)->second;
345 attrs[attrName] =
toString(it->second);
348 const std::string attrName =
myAttrIds.find(it->first)->second;
349 attrs[attrName] =
toString(it->second);
352 const std::string attrName =
myAttrIds.find(it->first)->second;
353 attrs[attrName] = it->second;
356 const std::string attrName =
myAttrIds.find(it->first)->second;
357 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.