98 const std::string& rootElement =
"",
99 const std::string& schemaFile =
"");
122 static void closeAll(
bool keepErrorRetrievers =
false);
140 OutputDevice(
const int defaultIndentation = 0,
const std::string& filename =
"");
193 const std::string& schemaFile,
194 std::map<SumoXMLAttr, std::string> attrs = std::map<SumoXMLAttr, std::string>(),
195 bool includeConfig =
true);
198 template <
typename E>
236 bool closeTag(
const std::string& comment =
"");
253 template <
typename T>
260 return attributeMask.test(attr);
270 template <
typename T>
272 assert((
int)attr <= 63);
273 if (attributeMask == 0 ||
useAttribute(attr, attributeMask)) {
278 template <
typename T>
280 assert((
int)attr <= (
int)attributeMask.size());
281 if (attributeMask.none() ||
useAttribute(attr, attributeMask)) {
294 template <
typename T>
307 if (val !=
"" && val !=
"default") {
336 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
static std::string realString(const double v, const int precision=gPrecision)
Helper method for string formatting.
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.
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.
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.
int precision()
return precision set on the device
const std::string & getFilename()
get filename or suitable description of this device
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)
bool writeHeader(const SumoXMLTag &rootElement)
static OutputDevice & getDevice(const std::string &name, bool usePrefix=true)
Returns the described OutputDevice.
OutputFormatter *const myFormatter
The formatter for XML.
bool useAttribute(const SumoXMLAttr attr, SumoXMLAttrMask attributeMask) const
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.
static std::map< std::string, OutputDevice * > myOutputDevices
map from names to output devices
OutputDevice & writeOptionalAttr(const SumoXMLAttr attr, const T &val, SumoXMLAttrMask attributeMask)
virtual bool ok()
returns the information whether one can write into the device
OutputDevice & writeOptionalAttr(const SumoXMLAttr attr, const T &val, long long int attributeMask)
writes a named attribute unless filtered