![]() |
Eclipse SUMO - Simulation of Urban MObility
|
Output formatter for plain XML output. More...
#include <PlainXMLFormatter.h>
Public Member Functions | |
bool | closeTag (std::ostream &into, const std::string &comment="") |
Closes the most recently opened tag. | |
OutputFormatterType | getType () |
void | openTag (std::ostream &into, const std::string &xmlElement) |
Opens an XML tag. | |
void | openTag (std::ostream &into, const SumoXMLTag &xmlElement) |
Opens an XML tag. | |
PlainXMLFormatter (const int defaultIndentation=0) | |
Constructor. | |
virtual void | setExpectedAttributes (const SumoXMLAttrMask &expected, const int depth=2) |
template<> | |
void | writeAttr (std::ostream &into, const SumoXMLAttr attr, const double &val) |
template<> | |
void | writeAttr (std::ostream &into, const SumoXMLAttr attr, const std::string &val) |
void | writePadding (std::ostream &into, const std::string &val) |
writes arbitrary padding | |
void | writePreformattedTag (std::ostream &into, const std::string &val) |
writes a preformatted tag to the device but ensures that any pending tags are closed | |
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. | |
bool | wroteHeader () const |
virtual | ~PlainXMLFormatter () |
Destructor. | |
Static Public Member Functions | |
template<class T > | |
static void | writeAttr (std::ostream &into, const std::string &attr, const T &val) |
writes an arbitrary attribute | |
template<class T > | |
static void | writeAttr (std::ostream &into, const SumoXMLAttr attr, const T &val) |
writes a named attribute | |
Private Attributes | |
int | myDefaultIndentation |
The initial indentation level. | |
bool | myHavePendingOpener |
whether a closing ">" might be missing | |
const OutputFormatterType | myType |
std::vector< std::string > | myXMLStack |
The stack of begun xml elements. | |
Output formatter for plain XML output.
PlainXMLFormatter format XML like output into the output stream.
Definition at line 40 of file PlainXMLFormatter.h.
PlainXMLFormatter::PlainXMLFormatter | ( | const int | defaultIndentation = 0 | ) |
Constructor.
Definition at line 31 of file PlainXMLFormatter.cpp.
|
inlinevirtual |
Destructor.
Definition at line 46 of file PlainXMLFormatter.h.
|
virtual |
Closes the most recently opened tag.
[in] | into | The output stream to use |
Implements OutputFormatter.
Definition at line 71 of file PlainXMLFormatter.cpp.
References myDefaultIndentation, myHavePendingOpener, and myXMLStack.
|
inlineinherited |
Definition at line 115 of file OutputFormatter.h.
References OutputFormatter::myType.
Referenced by OutputDevice::writeAttr(), OutputDevice::writeAttr(), and OutputDevice::writeOptionalAttr().
|
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 54 of file PlainXMLFormatter.cpp.
References myDefaultIndentation, myHavePendingOpener, and myXMLStack.
Referenced by openTag(), 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 65 of file PlainXMLFormatter.cpp.
References openTag(), and toString().
|
inlinevirtualinherited |
Reimplemented in CSVFormatter.
Definition at line 119 of file OutputFormatter.h.
References UNUSED_PARAMETER.
Referenced by OutputDevice::setExpectedAttributes().
|
inlinestatic |
writes an arbitrary attribute
[in] | into | The output stream to use |
[in] | attr | The attribute (name) |
[in] | val | The attribute value |
Definition at line 109 of file PlainXMLFormatter.h.
References toString().
Referenced by OutputDevice::writeAttr(), OutputDevice::writeAttr(), OutputDevice::writeOptionalAttr(), and writeXMLHeader().
|
inline |
Definition at line 144 of file PlainXMLFormatter.h.
References toString().
|
inline |
Definition at line 154 of file PlainXMLFormatter.h.
References toString().
|
inlinestatic |
writes a named attribute
[in] | into | The output stream to use |
[in] | attr | The attribute (name) |
[in] | val | The attribute value |
Definition at line 120 of file PlainXMLFormatter.h.
References toString().
|
virtual |
writes arbitrary padding
Reimplemented from OutputFormatter.
Definition at line 98 of file PlainXMLFormatter.cpp.
|
virtual |
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 88 of file PlainXMLFormatter.cpp.
References myHavePendingOpener.
|
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 |
Implements OutputFormatter.
Definition at line 37 of file PlainXMLFormatter.cpp.
References OptionsCont::getOptions(), myHavePendingOpener, myXMLStack, openTag(), writeAttr(), and OptionsCont::writeXMLHeader().
|
inlinevirtual |
Implements OutputFormatter.
Definition at line 124 of file PlainXMLFormatter.h.
References myXMLStack.
|
private |
The initial indentation level.
Definition at line 133 of file PlainXMLFormatter.h.
Referenced by closeTag(), and openTag().
|
private |
whether a closing ">" might be missing
Definition at line 136 of file PlainXMLFormatter.h.
Referenced by closeTag(), openTag(), writePreformattedTag(), and writeXMLHeader().
|
privateinherited |
Definition at line 125 of file OutputFormatter.h.
Referenced by OutputFormatter::getType().
|
private |
The stack of begun xml elements.
Definition at line 130 of file PlainXMLFormatter.h.
Referenced by closeTag(), openTag(), writeXMLHeader(), and wroteHeader().