Chapter 11.  XmlEventReaderToWriter

#include <DbXml.hpp>

class DbXml::XmlEventReaderToWriter {
public:
	XmlEventReaderToWriter(XmlEventReader &reader,
                               XmlEventWriter &writer,
                               bool ownsReader = true)
	XmlEventReaderToWriter(XmlEventReader &reader,
                               XmlEventWriter &writer,
                               bool ownsReader,
			       bool ownsWriter)
	...
};

The XmlEventReaderToWriter class enables events read from an XmlEventReader to be written directly to an XmlEventWriter . This is useful for processing XML document content, efficient copying, and other application integration tasks. Use XmlEventReaderToWriter::start to begin processing.

The method constructs an object from the reader and writer that will pipe events from the reader directly to the writer.

This object is not thread-safe, and can only be safely used by one thread at a time in an application.

Parameters

reader

An XmlEventReader object from which events will be read. To create the reader, use one of XmlDocument::getContentAsEventReader, XmlValue::asEventReader, or implement an application-defined class derived from XmlEventReader .

writer

An XmlEventWriter object to which events will be written. When all events are processed, XmlEventWriter::close is called on the object unless the ownsWriter parameter is false. To create the writer, use XmlContainer::putDocumentAsEventWriter, or implement an application-defined class derived from XmlEventWriter .

ownsReader

If true (the default), XmlEventReader::close will be called when all events have been processed; otherwise, the reader is left intact upon completion.

ownsWriter

If true (the default), XmlEventReader::close will be called when all events have been processed; otherwise, the writer is left intact upon completion. Setting this parameter to false allows applications to apply a number of XmlEventReader objects to the same XmlEventWriter .