SUMO - Simulation of Urban MObility
|
Output formatter for plain XML output. More...
#include <PlainXMLFormatter.h>
Public Member Functions | |
void | closeOpener (std::ostream &into) |
Ends the most recently opened element start. | |
bool | closeTag (std::ostream &into, bool abbreviated=false) |
Closes the most recently opened tag. | |
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 unsigned int defaultIndentation=0) | |
Constructor. | |
void | writeAttr (std::ostream &into, const std::string &attr, const std::string &val) |
writes an arbitrary attribute | |
bool | writeXMLHeader (std::ostream &into, const std::string &rootElement, const std::string xmlParams="", const std::string &attrs="", const std::string &comment="") |
Writes an XML header with optional configuration. | |
virtual | ~PlainXMLFormatter () |
Destructor. | |
Static Public Member Functions | |
template<class T > | |
static void | writeAttr (std::ostream &into, const SumoXMLAttr attr, const T &val) |
writes a named attribute | |
Private Attributes | |
unsigned int | myDefaultIndentation |
The initial indentation level. | |
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 45 of file PlainXMLFormatter.h.
PlainXMLFormatter::PlainXMLFormatter | ( | const unsigned int | defaultIndentation = 0 | ) |
Constructor.
Definition at line 43 of file PlainXMLFormatter.cpp.
virtual PlainXMLFormatter::~PlainXMLFormatter | ( | ) | [inline, virtual] |
Destructor.
Definition at line 52 of file PlainXMLFormatter.h.
void PlainXMLFormatter::closeOpener | ( | std::ostream & | into | ) | [virtual] |
Ends the most recently opened element start.
Writes more or less nothing but ">" and a line feed.
[in] | into | The output stream to use |
Implements OutputFormatter.
Definition at line 81 of file PlainXMLFormatter.cpp.
bool PlainXMLFormatter::closeTag | ( | std::ostream & | into, |
bool | abbreviated = false |
||
) | [virtual] |
Closes the most recently opened tag.
[in] | into | The output stream to use |
[in] | name | whether abbreviated closing is performed |
Implements OutputFormatter.
Definition at line 87 of file PlainXMLFormatter.cpp.
References myDefaultIndentation, and myXMLStack.
void PlainXMLFormatter::openTag | ( | std::ostream & | into, |
const std::string & | xmlElement | ||
) | [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 68 of file PlainXMLFormatter.cpp.
References myDefaultIndentation, and myXMLStack.
Referenced by openTag(), and writeXMLHeader().
void PlainXMLFormatter::openTag | ( | std::ostream & | into, |
const SumoXMLTag & | xmlElement | ||
) | [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 75 of file PlainXMLFormatter.cpp.
References openTag(), and toString().
void PlainXMLFormatter::writeAttr | ( | std::ostream & | into, |
const std::string & | attr, | ||
const std::string & | val | ||
) | [virtual] |
writes an arbitrary attribute
[in] | into | The output stream to use |
[in] | attr | The attribute (name) |
[in] | val | The attribute value |
Implements OutputFormatter.
Definition at line 103 of file PlainXMLFormatter.cpp.
static void PlainXMLFormatter::writeAttr | ( | std::ostream & | into, |
const SumoXMLAttr | attr, | ||
const T & | val | ||
) | [inline, 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 132 of file PlainXMLFormatter.h.
References toString().
bool PlainXMLFormatter::writeXMLHeader | ( | std::ostream & | into, |
const std::string & | rootElement, | ||
const std::string | xmlParams = "" , |
||
const std::string & | attrs = "" , |
||
const std::string & | comment = "" |
||
) | [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] | xmlParams | Additional parameters (such as encoding) to include in the <?xml> declaration |
[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 49 of file PlainXMLFormatter.cpp.
References OptionsCont::getOptions(), myXMLStack, openTag(), and OptionsCont::writeXMLHeader().
unsigned int PlainXMLFormatter::myDefaultIndentation [private] |
The initial indentation level.
Definition at line 142 of file PlainXMLFormatter.h.
Referenced by closeTag(), and openTag().
std::vector<std::string> PlainXMLFormatter::myXMLStack [private] |
The stack of begun xml elements.
Definition at line 139 of file PlainXMLFormatter.h.
Referenced by closeTag(), openTag(), and writeXMLHeader().