101 const std::string& rootElement =
"",
102 const std::string& schemaFile =
"");
125 static void closeAll(
bool keepErrorRetrievers =
false);
133 OutputDevice(
const int defaultIndentation = 0,
const std::string& filename =
"");
187 const std::string& schemaFile,
188 std::map<SumoXMLAttr, std::string> attrs = std::map<SumoXMLAttr, std::string>(),
189 bool includeConfig =
true);
221 bool closeTag(
const std::string& comment =
"");
235 template <
typename T>
259 const std::map<std::string, SumoXMLAttrMask>& special = std::map<std::string, SumoXMLAttrMask>());
268 template <
typename T>
270 assert((
int)attr <= (
int)attributeMask.size());
271 if (attributeMask.none() || attributeMask.test(attr)) {
291 template <
typename Func>
293 assert((
int)attr <= (
int)attributeMask.size());
294 if (attributeMask.none() || attributeMask.test(attr)) {
320 template <
typename T>
341 if (val !=
"" && val !=
"default") {
374 void inform(
const std::string& msg,
const bool progress =
false);
SumoXMLTag
Numbers representing SUMO-XML - element names.
std::bitset< 96 > SumoXMLAttrMask
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.
void lf()
writes a line feed if applicable
virtual std::ostream & getOStream()=0
Returns the associated ostream.
OutputDevice(const OutputDevice &)=delete
Invalidated copy constructor.
virtual ~OutputDevice()
Destructor.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
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"
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed
void inform(const std::string &msg, const bool progress=false)
Retrieves a message to this device.
OutputDevice & writePadding(const std::string &val)
writes padding (ignored for binary output)
void close()
Closes the device and removes it from the dictionary.
static const SumoXMLAttrMask parseWrittenAttributes(const std::vector< std::string > &attrList, const std::string &desc, const std::map< std::string, SumoXMLAttrMask > &special=std::map< std::string, SumoXMLAttrMask >())
Parses a list of strings for attribute names and sets the relevant bits in the returned mask.
OutputDevice & operator=(const OutputDevice &)=delete
Invalidated assignment operator.
OutputDevice & operator<<(const T &t)
Abstract output operator.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
virtual void postWriteHook()
Called after every write access.
void setExpectedAttributes(const SumoXMLAttrMask &expected, const int depth=2)
OutputDevice & writeAttr(const std::string &attr, const T &val)
writes an arbitrary attribute
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.
const std::string & getFilename()
get filename or suitable description of this device
OutputFormatter * myFormatter
The formatter for XML, CSV or Parquet.
virtual bool isNull()
returns the information whether the device will discard all output
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
int getPrecision()
Returns the precision 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 precision or resets it to default.
const std::string myFilename
static void closeAll(bool keepErrorRetrievers=false)
void setFormatter(OutputFormatter *formatter)
static OutputDevice & getDevice(const std::string &name, bool usePrefix=true)
Returns the described OutputDevice.
static int myPrevConsoleCP
old console code page to restore after ending
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >(), bool includeConfig=true)
Writes an XML header with optional configuration.
OutputDevice & writeOptionalAttr(const SumoXMLAttr attr, const T &val, const SumoXMLAttrMask &attributeMask, const bool isNull=false)
writes a named attribute unless filtered
static std::map< std::string, OutputDevice * > myOutputDevices
map from names to output devices
OutputDevice & writeFuncAttr(const SumoXMLAttr attr, const Func &valFunc, const SumoXMLAttrMask &attributeMask, const bool isNull=false)
OutputDevice & writeTime(const SumoXMLAttr attr, const SUMOTime val)
virtual bool ok()
returns the information whether one can write into the device