![]() |
Eclipse SUMO - Simulation of Urban MObility
|
Abstract base class for output formatters. More...
#include <OutputFormatter.h>
Public Member Functions | |
virtual bool | closeTag (std::ostream &into, const std::string &comment="")=0 |
Closes the most recently opened tag and optinally add a comment. | |
OutputFormatterType | getType () |
Returns the type of formatter being used. | |
virtual void | openTag (std::ostream &into, const std::string &xmlElement)=0 |
Opens an XML tag. | |
virtual void | openTag (std::ostream &into, const SumoXMLTag &xmlElement)=0 |
Opens an XML tag. | |
OutputFormatter (OutputFormatterType t) | |
Constructor. | |
virtual void | setExpectedAttributes (const SumoXMLAttrMask &expected, const int depth=2) |
Set the expected attributes to write. This is used for tracking which attributes are expected in table like outputs. This should be not necessary but at least in the initial phase of implementing CSV and Parquet it helps a lot to track errors. | |
virtual void | writePadding (std::ostream &into, const std::string &val) |
Writes some whitespace to format the output. This method is only implemented for XML output. | |
virtual void | writePreformattedTag (std::ostream &into, const std::string &val) |
Writes a preformatted tag to the device but ensures that any pending tags are closed. This method is only implemented for XML output. | |
virtual void | writeTime (std::ostream &into, const SumoXMLAttr attr, const SUMOTime val)=0 |
virtual bool | writeXMLHeader (std::ostream &into, const std::string &rootElement, const std::map< SumoXMLAttr, std::string > &attrs, bool includeConfig=true) |
Writes an XML header with optional configuration. | |
virtual bool | wroteHeader () const =0 |
Returns whether a header has been written. Useful to detect whether a file is being used by multiple sources. | |
virtual | ~OutputFormatter () |
Destructor. | |
Private Attributes | |
const OutputFormatterType | myType |
the type of formatter being used (XML, CSV, Parquet, etc.) | |
Abstract base class for output formatters.
OutputFormatter format XML like output into the output stream. There are only two implementation at the moment, "normal" XML and binary XML.
Definition at line 57 of file OutputFormatter.h.
|
inline |
Constructor.
Definition at line 60 of file OutputFormatter.h.
|
inlinevirtual |
Destructor.
Definition at line 63 of file OutputFormatter.h.
|
pure virtual |
Closes the most recently opened tag and optinally add a comment.
[in] | into | The output stream to use |
Implemented in CSVFormatter, ParquetFormatter, and PlainXMLFormatter.
Referenced by OutputDevice::closeTag().
|
inline |
Returns the type of formatter being used.
Definition at line 149 of file OutputFormatter.h.
References myType.
Referenced by OutputDevice::writeAttr(), OutputDevice::writeAttr(), OutputDevice::writeFuncAttr(), and OutputDevice::writeOptionalAttr().
|
pure 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 |
Implemented in CSVFormatter, ParquetFormatter, and PlainXMLFormatter.
Referenced by OutputDevice::openTag(), and OutputDevice::openTag().
|
pure 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 |
Implemented in CSVFormatter, ParquetFormatter, and PlainXMLFormatter.
|
inlinevirtual |
Set the expected attributes to write. This is used for tracking which attributes are expected in table like outputs. This should be not necessary but at least in the initial phase of implementing CSV and Parquet it helps a lot to track errors.
[in] | expected | which attributes are to be written (at the deepest XML level) |
[in] | depth | the maximum XML hierarchy depth (excluding the root) |
Reimplemented in CSVFormatter, and ParquetFormatter.
Definition at line 160 of file OutputFormatter.h.
References UNUSED_PARAMETER.
Referenced by OutputDevice::setExpectedAttributes().
|
inlinevirtual |
Writes some whitespace to format the output. This method is only implemented for XML output.
[in] | into | The output stream to use |
[in] | val | The whitespace |
Reimplemented in PlainXMLFormatter.
Definition at line 135 of file OutputFormatter.h.
References UNUSED_PARAMETER.
Referenced by OutputDevice::writePadding().
|
inlinevirtual |
Writes a preformatted tag to the device but ensures that any pending tags are closed. This method is only implemented for XML output.
[in] | into | The output stream to use |
[in] | val | The preformatted data |
Reimplemented in PlainXMLFormatter.
Definition at line 124 of file OutputFormatter.h.
References UNUSED_PARAMETER.
Referenced by OutputDevice::writePreformattedTag().
|
pure virtual |
Implemented in CSVFormatter, ParquetFormatter, and PlainXMLFormatter.
Referenced by OutputDevice::writeTime().
|
inlinevirtual |
Writes an XML header with optional configuration.
If something has been written (myXMLStack is not empty), nothing is written and false returned. The default implementation does nothing and returns false.
[in] | into | The output stream to use |
[in] | rootElement | The root element to use |
[in] | attrs | Additional attributes to save within the rootElement |
[in] | includeConfig | whether the current config should be included as XML comment |
Reimplemented in PlainXMLFormatter.
Definition at line 77 of file OutputFormatter.h.
References UNUSED_PARAMETER.
Referenced by OutputDevice::writeXMLHeader().
|
pure virtual |
Returns whether a header has been written. Useful to detect whether a file is being used by multiple sources.
Implemented in CSVFormatter, ParquetFormatter, and PlainXMLFormatter.
Referenced by OutputDevice::wroteHeader().
|
private |
the type of formatter being used (XML, CSV, Parquet, etc.)
Definition at line 167 of file OutputFormatter.h.
Referenced by getType().