97 const std::string& rootElement =
"",
98 const std::string& schemaFile =
"");
118 static void closeAll(
bool keepErrorRetrievers =
false);
136 OutputDevice(
const int defaultIndentation = 0,
const std::string& filename =
"");
179 const std::string& schemaFile,
180 std::map<SumoXMLAttr, std::string> attrs = std::map<SumoXMLAttr, std::string>());
183 template <
typename E>
221 bool closeTag(
const std::string& comment =
"");
238 template <
typename T>
251 template <
typename T>
265 if (val !=
"" && val !=
"default") {
294 void inform(
const std::string& msg,
const char progress = 0);
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
int gPrecision
the precision for floating point outputs
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed
void lf()
writes a line feed if applicable
virtual ~OutputDevice()
Destructor.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
Writes an XML header with optional configuration.
OutputDevice(const int defaultIndentation=0, const std::string &filename="")
Constructor.
static std::string realString(const double v, const int precision=gPrecision)
Helper method for string formatting.
OutputDevice & operator<<(const T &t)
Abstract output operator.
void close()
Closes the device and removes it from the dictionary.
OutputDevice & operator=(const OutputDevice &)
Invalidated assignment operator.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
virtual void postWriteHook()
Called after every write access.
OutputDevice & writeNonEmptyAttr(const SumoXMLAttr attr, const std::string &val)
writes a string attribute only if it is not the empty string and not the string "default"
static bool createDeviceByOption(const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="")
Creates the device using the output definition stored in the named option.
OutputDevice & writeAttr(const std::string &attr, const T &val)
writes an arbitrary attribute
const std::string & getFilename()
get filename or suitable description of this device
OutputFormatter * myFormatter
The formatter for XML.
virtual std::ostream & getOStream()=0
Returns the associated ostream.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
int getPrecision()
Returns the precison of the underlying stream.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void setPrecision(int precision=gPrecision)
Sets the precison or resets it to default.
static void closeAll(bool keepErrorRetrievers=false)
OutputDevice & writePadding(const std::string &val)
writes padding (ignored for binary output)
void inform(const std::string &msg, const char progress=0)
Retrieves a message to this device.
bool writeHeader(const SumoXMLTag &rootElement)
static std::map< std::string, OutputDevice * > myOutputDevices
map from names to output devices
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
OutputDevice(const OutputDevice &)
Invalidated copy constructor.
virtual bool ok()
returns the information whether one can write into the device