SUMO - Simulation of Urban MObility
|
Output formatter for plain XML output. More...
#include <PlainXMLFormatter.h>
Public Member Functions | |
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... | |
PlainXMLFormatter (const unsigned int defaultIndentation=0) | |
Constructor. More... | |
bool | writeHeader (std::ostream &into, const SumoXMLTag &rootElement) |
Writes an XML header with optional configuration. 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 | ~PlainXMLFormatter () |
Destructor. More... | |
Static Public Member Functions | |
template<class T > | |
static void | writeAttr (std::ostream &into, const std::string &attr, const T &val) |
writes an arbitrary attribute More... | |
template<class T > | |
static void | writeAttr (std::ostream &into, const SumoXMLAttr attr, const T &val) |
writes a named attribute More... | |
Private Attributes | |
unsigned int | myDefaultIndentation |
The initial indentation level. More... | |
bool | myHavePendingOpener |
whether a closing ">" might be missing More... | |
std::vector< std::string > | myXMLStack |
The stack of begun xml elements. More... | |
Output formatter for plain XML output.
PlainXMLFormatter format XML like output into the output stream.
Definition at line 45 of file PlainXMLFormatter.h.
PlainXMLFormatter::PlainXMLFormatter | ( | const unsigned int | defaultIndentation = 0 ) |
Constructor.
Definition at line 43 of file PlainXMLFormatter.cpp.
|
inlinevirtual |
Destructor.
Definition at line 52 of file PlainXMLFormatter.h.
|
virtual |
Closes the most recently opened tag.
[in] | into | The output stream to use |
Implements OutputFormatter.
Definition at line 97 of file PlainXMLFormatter.cpp.
References myDefaultIndentation, myHavePendingOpener, and myXMLStack.
|
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 80 of file PlainXMLFormatter.cpp.
References myDefaultIndentation, myHavePendingOpener, and myXMLStack.
Referenced by openTag(), 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 91 of file PlainXMLFormatter.cpp.
References openTag(), and toString().
|
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 122 of file PlainXMLFormatter.h.
References toString().
Referenced by OutputDevice::writeAttr().
|
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 134 of file PlainXMLFormatter.h.
References toString().
bool PlainXMLFormatter::writeHeader | ( | std::ostream & | into, |
const SumoXMLTag & | rootElement | ||
) |
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 |
Definition at line 49 of file PlainXMLFormatter.cpp.
References OptionsCont::getOptions(), myXMLStack, openTag(), and OptionsCont::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 60 of file PlainXMLFormatter.cpp.
References OptionsCont::getOptions(), myHavePendingOpener, myXMLStack, openTag(), and OptionsCont::writeXMLHeader().
|
private |
The initial indentation level.
Definition at line 144 of file PlainXMLFormatter.h.
Referenced by closeTag(), and openTag().
|
private |
whether a closing ">" might be missing
Definition at line 147 of file PlainXMLFormatter.h.
Referenced by closeTag(), openTag(), and writeXMLHeader().
|
private |
The stack of begun xml elements.
Definition at line 141 of file PlainXMLFormatter.h.
Referenced by closeTag(), openTag(), writeHeader(), and writeXMLHeader().