SUMO - Simulation of Urban MObility
|
Output formatter for plain XML output. More...
#include <BinaryFormatter.h>
Public Types | |
enum | DataType { BF_BYTE, BF_INTEGER, BF_FLOAT, BF_STRING, BF_LIST, BF_XML_TAG_START, BF_XML_TAG_END, BF_XML_ATTRIBUTE, BF_EDGE, BF_LANE, BF_POSITION_2D, BF_POSITION_3D, BF_BOUNDARY, BF_COLOR, BF_NODE_TYPE, BF_EDGE_FUNCTION, BF_ROUTE, BF_SCALED2INT, BF_SCALED2INT_POSITION_2D, BF_SCALED2INT_POSITION_3D } |
data types in binary output More... | |
Public Member Functions | |
BinaryFormatter () | |
Constructor. More... | |
bool | closeTag (std::ostream &into) |
Closes the most recently opened tag. More... | |
void | openTag (std::ostream &into, const std::string &xmlElement) |
Opens an XML tag. More... | |
void | openTag (std::ostream &into, const SumoXMLTag &xmlElement) |
Opens an XML tag. More... | |
template<> | |
void | writeAttr (std::ostream &into, const SumoXMLAttr attr, const bool &val) |
template<> | |
void | writeAttr (std::ostream &into, const SumoXMLAttr attr, const SUMOReal &val) |
template<> | |
void | writeAttr (std::ostream &into, const SumoXMLAttr attr, const int &val) |
template<> | |
void | writeAttr (std::ostream &into, const SumoXMLAttr attr, const unsigned int &val) |
template<> | |
void | writeAttr (std::ostream &into, const SumoXMLAttr attr, const SumoXMLNodeType &val) |
template<> | |
void | writeAttr (std::ostream &into, const SumoXMLAttr attr, const SumoXMLEdgeFunc &val) |
template<> | |
void | writeAttr (std::ostream &into, const SumoXMLAttr attr, const Position &val) |
template<> | |
void | writeAttr (std::ostream &into, const SumoXMLAttr attr, const PositionVector &val) |
template<> | |
void | writeAttr (std::ostream &into, const SumoXMLAttr attr, const Boundary &val) |
template<> | |
void | writeAttr (std::ostream &into, const SumoXMLAttr attr, const RGBColor &val) |
template<> | |
void | writeAttr (std::ostream &into, const SumoXMLAttr, const std::vector< int > &val) |
template<typename E > | |
bool | writeHeader (std::ostream &into, const SumoXMLTag &rootElement) |
Writes a header with optional edge list and connections. More... | |
void | writePreformattedTag (std::ostream &into, const std::string &val) |
writes a preformatted tag to the device but ensures that any pending tags are closed More... | |
bool | writeXMLHeader (std::ostream &into, const std::string &rootElement, const std::string &attrs="", const std::string &comment="") |
Writes an XML header with optional configuration. More... | |
virtual | ~BinaryFormatter () |
Destructor. More... | |
Static Public Member Functions | |
template<typename dummy , typename T > | |
static void | writeAttr (dummy &into, const SumoXMLAttr attr, const T &val) |
writes an arbitrary attribute More... | |
template<typename dummy , typename T > | |
static void | writeAttr (dummy &into, const std::string &attr, const T &val) |
writes a named attribute More... | |
template<typename dummy > | |
static void | writeAttr (dummy &into, const SumoXMLAttr attr, const std::vector< const ROEdge * > &val) |
template<typename dummy > | |
static void | writeAttr (dummy &into, const SumoXMLAttr attr, const std::vector< const MSEdge * > &val) |
Static Private Member Functions | |
static void | writeAttrHeader (std::ostream &into, const SumoXMLAttr attr, const DataType type) |
writes the header for an arbitrary attribute More... | |
static void | writePosition (std::ostream &into, const Position &val) |
writes a position More... | |
static void | writeStringList (std::ostream &into, const std::vector< std::string > &list) |
writes a list of strings More... | |
Private Attributes | |
std::vector< SumoXMLTag > | myXMLStack |
The stack of begun xml elements. More... | |
Output formatter for plain XML output.
BinaryFormatter format XML like output into the output stream.
Definition at line 66 of file BinaryFormatter.h.
data types in binary output
Definition at line 69 of file BinaryFormatter.h.
BinaryFormatter::BinaryFormatter | ( | ) |
Constructor.
Definition at line 53 of file BinaryFormatter.cpp.
|
inlinevirtual |
Destructor.
Definition at line 117 of file BinaryFormatter.h.
|
virtual |
Closes the most recently opened tag.
[in] | into | The output stream to use |
Implements OutputFormatter.
Definition at line 110 of file BinaryFormatter.cpp.
References BF_XML_TAG_END, myXMLStack, and FileHelpers::writeByte().
|
virtual |
Opens an XML tag.
An indentation, depending on the current xml-element-stack size, is written followed by the given xml element ("<" + xmlElement) The xml element is added to the stack, then.
[in] | into | The output stream to use |
[in] | xmlElement | Name of element to open |
Implements OutputFormatter.
Definition at line 94 of file BinaryFormatter.cpp.
References SUMOXMLDefinitions::Tags.
Referenced by writeHeader(), and writeXMLHeader().
|
virtual |
Opens an XML tag.
Helper method which finds the correct string before calling openTag.
[in] | into | The output stream to use |
[in] | xmlElement | Id of the element to open |
Implements OutputFormatter.
Definition at line 102 of file BinaryFormatter.cpp.
References BF_XML_TAG_START, myXMLStack, and FileHelpers::writeByte().
void BinaryFormatter::writeAttr | ( | std::ostream & | into, |
const SumoXMLAttr | attr, | ||
const bool & | val | ||
) |
Definition at line 122 of file BinaryFormatter.cpp.
References BF_BYTE, writeAttrHeader(), and FileHelpers::writeByte().
void BinaryFormatter::writeAttr | ( | std::ostream & | into, |
const SumoXMLAttr | attr, | ||
const SUMOReal & | val | ||
) |
Definition at line 129 of file BinaryFormatter.cpp.
References BF_FLOAT, BF_SCALED2INT, writeAttrHeader(), FileHelpers::writeFloat(), and FileHelpers::writeInt().
void BinaryFormatter::writeAttr | ( | std::ostream & | into, |
const SumoXMLAttr | attr, | ||
const int & | val | ||
) |
Definition at line 141 of file BinaryFormatter.cpp.
References BF_INTEGER, writeAttrHeader(), and FileHelpers::writeInt().
void BinaryFormatter::writeAttr | ( | std::ostream & | into, |
const SumoXMLAttr | attr, | ||
const unsigned int & | val | ||
) |
Definition at line 148 of file BinaryFormatter.cpp.
References BF_INTEGER, writeAttrHeader(), and FileHelpers::writeInt().
void BinaryFormatter::writeAttr | ( | std::ostream & | into, |
const SumoXMLAttr | attr, | ||
const SumoXMLNodeType & | val | ||
) |
Definition at line 155 of file BinaryFormatter.cpp.
References BF_NODE_TYPE, writeAttrHeader(), and FileHelpers::writeByte().
void BinaryFormatter::writeAttr | ( | std::ostream & | into, |
const SumoXMLAttr | attr, | ||
const SumoXMLEdgeFunc & | val | ||
) |
Definition at line 162 of file BinaryFormatter.cpp.
References BF_EDGE_FUNCTION, writeAttrHeader(), and FileHelpers::writeByte().
|
static |
writes an arbitrary attribute
[in] | into | The output stream to use |
[in] | attr | The attribute (name) |
[in] | val | The attribute value |
Definition at line 296 of file BinaryFormatter.h.
References BF_STRING, toString(), writeAttrHeader(), and FileHelpers::writeString().
Referenced by writeAttr(), and OutputDevice::writeAttr().
void BinaryFormatter::writeAttr | ( | std::ostream & | into, |
const SumoXMLAttr | attr, | ||
const Position & | val | ||
) |
Definition at line 198 of file BinaryFormatter.cpp.
References BF_XML_ATTRIBUTE, FileHelpers::writeByte(), and writePosition().
|
static |
writes a named attribute
[in] | into | The output stream to use |
[in] | attr | The attribute (name) |
[in] | val | The attribute value |
Definition at line 303 of file BinaryFormatter.h.
References SUMOXMLDefinitions::Attrs, and writeAttr().
void BinaryFormatter::writeAttr | ( | std::ostream & | into, |
const SumoXMLAttr | attr, | ||
const PositionVector & | val | ||
) |
Definition at line 206 of file BinaryFormatter.cpp.
References BF_LIST, writeAttrHeader(), FileHelpers::writeInt(), and writePosition().
|
static |
Definition at line 324 of file BinaryFormatter.h.
References BF_ROUTE, writeAttrHeader(), and FileHelpers::writeEdgeVector().
void BinaryFormatter::writeAttr | ( | std::ostream & | into, |
const SumoXMLAttr | attr, | ||
const Boundary & | val | ||
) |
Definition at line 216 of file BinaryFormatter.cpp.
References BF_BOUNDARY, writeAttrHeader(), FileHelpers::writeFloat(), Boundary::xmax(), Boundary::xmin(), Boundary::ymax(), and Boundary::ymin().
|
static |
Definition at line 331 of file BinaryFormatter.h.
References BF_ROUTE, writeAttrHeader(), and FileHelpers::writeEdgeVector().
void BinaryFormatter::writeAttr | ( | std::ostream & | into, |
const SumoXMLAttr | attr, | ||
const RGBColor & | val | ||
) |
Definition at line 226 of file BinaryFormatter.cpp.
References RGBColor::alpha(), BF_COLOR, RGBColor::blue(), RGBColor::green(), RGBColor::red(), writeAttrHeader(), and FileHelpers::writeByte().
void BinaryFormatter::writeAttr | ( | std::ostream & | into, |
const SumoXMLAttr | , | ||
const std::vector< int > & | val | ||
) |
Definition at line 236 of file BinaryFormatter.cpp.
References BF_INTEGER, BF_LIST, FileHelpers::writeByte(), and FileHelpers::writeInt().
|
inlinestaticprivate |
writes the header for an arbitrary attribute
[in] | into | The output stream to use |
[in] | attr | The attribute (name) |
[in] | type | The attribute type |
Definition at line 227 of file BinaryFormatter.h.
References BF_XML_ATTRIBUTE, and FileHelpers::writeByte().
Referenced by writeAttr().
bool BinaryFormatter::writeHeader | ( | std::ostream & | into, |
const SumoXMLTag & | rootElement | ||
) |
Writes a header with optional edge list and connections.
If something has been written (myXMLStack is not empty), nothing is written and false returned. This header is only used by the binary formatter.
[in] | into | The output stream to use |
[in] | rootElement | The root element to use |
Definition at line 259 of file BinaryFormatter.h.
References SUMOXMLDefinitions::Attrs, BF_BYTE, BF_INTEGER, BF_LIST, BF_STRING, SUMOXMLDefinitions::EdgeFunctions, myXMLStack, SUMOXMLDefinitions::NodeTypes, openTag(), SUMOXMLDefinitions::Tags, VERSION_STRING, FileHelpers::writeByte(), FileHelpers::writeInt(), FileHelpers::writeString(), and writeStringList().
|
staticprivate |
writes a position
[in] | into | The output stream to use |
[in] | val | the position to write |
Definition at line 168 of file BinaryFormatter.cpp.
References BF_POSITION_2D, BF_POSITION_3D, BF_SCALED2INT_POSITION_2D, BF_SCALED2INT_POSITION_3D, FileHelpers::writeByte(), FileHelpers::writeFloat(), FileHelpers::writeInt(), Position::x(), Position::y(), and Position::z().
Referenced by writeAttr().
|
inlinevirtual |
writes a preformatted tag to the device but ensures that any pending tags are closed
[in] | into | The output stream to use |
[in] | val | The preformatted data |
Implements OutputFormatter.
Definition at line 206 of file BinaryFormatter.h.
References FileHelpers::writeString().
|
staticprivate |
writes a list of strings
[in] | into | The output stream to use |
[in] | list | the list to write |
Definition at line 58 of file BinaryFormatter.cpp.
References BF_LIST, BF_STRING, FileHelpers::writeByte(), FileHelpers::writeInt(), and FileHelpers::writeString().
Referenced by writeHeader(), and writeXMLHeader().
|
virtual |
Writes an XML header with optional configuration.
If something has been written (myXMLStack is not empty), nothing is written and false returned.
[in] | into | The output stream to use |
[in] | rootElement | The root element to use |
[in] | attrs | Additional attributes to save within the rootElement |
[in] | comment | Additional comment (saved in front the rootElement) |
Check which parameter is used herein
Describe what is saved
Implements OutputFormatter.
Definition at line 68 of file BinaryFormatter.cpp.
References SUMOXMLDefinitions::Attrs, BF_BYTE, BF_STRING, SUMOXMLDefinitions::EdgeFunctions, myXMLStack, SUMOXMLDefinitions::NodeTypes, openTag(), SUMOXMLDefinitions::Tags, VERSION_STRING, FileHelpers::writeByte(), FileHelpers::writeString(), and writeStringList().
|
private |
The stack of begun xml elements.
Definition at line 252 of file BinaryFormatter.h.
Referenced by closeTag(), openTag(), writeHeader(), and writeXMLHeader().