Module: XML Streams Package: XML Streams
RWEnhancedXmlObjectOutputStreamImp RWXmlObjectStreamCommon RWObjectOutputStreamImp RWFilteredDataOutputStreamImp
#include <rw/xmlstreams/RWEnhancedXmlObjectOutputStreamImp.h>
The class RWEnhancedXmlObjectOutputStreamImp writes objects as XML into the supplied RWDataOutputStream. Implements the body idiom from the handle/body pattern.
// Create a strstream to serve as our sink ostrstream s; // Create an XML data stream using the strstream RWObjectOutputStream in = RWXmlbjectOutputStreamImp::make(s); // Write integer value '1' to XML data stream s << 1;
RWEnhancedXmlObjectOutputStreamImp
(RW_SL_IO_STD(ostream)& ostr,
const RWCString& rootElementType, bool escape)
Constructs an RWEnhancedXmlObjectOutputStreamImp instance that takes an ostream to use as the destination.
The value rootElementType indicates the root element of the generated document. This value should be either objectTag, nestedObjectTag, sequenceTag, primitiveTag, or mapTag, depending on what sort of object is streamed into the document at the top level.
The parameter escape sets whether to escape XML reserved characters in the data being serialized. By setting this parameter to true, reserved characters in char and string values are escaped, allowing the data to include embedded XML.
The reserved characters are:
< > & " '
You get slightly better performance if the escape parameter is set to false, but before doing so be certain that your data does not contain reserved characters.
RWEnhancedXmlObjectOutputStreamImp
(RW_SL_IO_STD(ostream)& ostr,
RW_SL_IO_STD(ios)*& formatter, const
RWCString& rootElementType, bool escape)
Constructs an RWEnhancedXmlObjectOutputStreamImp instance that takes an ostream to use as the destination. This constructor is the same as the first one described above, except that it also takes a pointer reference to an std::ios formatting object.
The parameter formatter will be returned with a reference to the formatting object.
RWEnhancedXmlObjectOutputStreamImp
(const RWDataOutputStream& ostr, const RWCString&
rootElementType, bool escape)
Constructs an RWEnhancedXmlObjectOutputStreamImp instance that takes an RWDataOutputStream to use as the destination. This constructor takes the same parameters as the first one described above.
The value rootElementType indicates the root element of the generated document. This value should be either objectTag, nestedObjectTag, sequenceTag, primitiveTag, or RWEnhancedXmlObjectOutputStreamImp (const RWDataOutputStream& ostr, const RWCString& rootElementType, bool escape) mapTag, depending on what sort of object is streamed into the document at the top level.
~RWEnhancedXmlObjectOutputStreamImp()
Destructor. Delete the storeTable even if an exception is thrown.
static RWObjectOutputStream
make(RW_SL_IO_STD(ostream)& sink,
const RWCString& rootElementType=nestedObjectTag,
bool escape = true);
Constructs an RWEnhancedXmlObjectOutputStreamImp instance that passes the serialized object data to the output stream sink, and returns a handle to it. Use this method when the data output stream is a standard library ostream. Throws no exceptions.
The parameter sink is the ostream that is used as sink of bytes.
The parameter rootElementType must be one of the following:
nestedObjectTag, if serializing an object by value
objectTag, if serializing an object by pointer
sequenceTag, if serializing a sequential collection such as RWTPtrOrderedVector
mapTag, if serializing a mapping collection such as RWTPtrHashMap
primitiveTag, if serializing a built-in type such as int
The value passed indicates the root element of the generated document. The default setting is nestedObjectTag.
The parameter escape sets whether to escape XML reserved characters in the data being serialized.
static RWObjectOutputStream make(RW_SL_IO_STD(ostream)& sink, RW_SL_IO_STD(ios)*& formatter, const RWCString& rootElementType=nestedObjectTag,
bool escape = true);
This function is the same as the first one described above, except that it also takes a pointer reference to an std::ios formatting object. An empty formatting object pointer is created before the XML stream is created and is passed through this make() function to the constructor:
std::ios* formatter; // uninitialized pointer RWObjectOutputStream xostr = RWEnhancedXmlObjectOutputStreamImp::make(outfile,formatter);
The constructor, in creating the underlying character stream for the XML stream, creates a formatting object for the stream and places the address of that object in the pointer reference. The calling application can then use this formatting object to manipulate data formats in the XML stream.
formatter->precision(15); // manipulate data format
static RWObjectOutputStream
make(RWDataOutputStream& sink, const RWCString&
rootElementType=nestedObjectTag,
bool escape = true);
Constructs an RWEnhancedXmlObjectOutputStreamImp instance that passes the serialized object data to the RWDataOutputStream sink, and returns a handle to it. Throws no exceptions.
The parameter sink is the ostream that is used as sink of bytes.
The parameter rootElementType must be one of the following:
nestedObjectTag, if serializing an object by value
objectTag, if serializing an object by pointer
sequenceTag, if serializing a sequential collection such as RWTPtrOrderedVector
mapTag, if serializing a mapping collection such as RWTPtrHashMap
primitiveTag, if serializing a built-in type such as int
The value passed indicates the root element of the generated document. The default setting is nestedObjectTag.
The parameter escape sets whether to escape XML reserved characters in the data being serialized.
virtual void putBool(bool value); virtual void putChar(char value); virtual void putCharacter(char value); virtual void putDouble(double value); virtual void putFloat(float value); virtual void putInt(int value); virtual void putLongDouble(long double value); virtual void putShort(short value); virtual void putSignedChar(signed char value); virtual void putSizeT(size_t value); virtual void putString(const RWCString& value); virtual void putUnsignedChar(unsigned char value); virtual void putUnsignedInt(unsigned int value); virtual void putLong(long value); virtual void putLongLong(rwlonglong value); virtual void putUnsignedLong(unsigned long value); virtual void putUnsignedLongLong(rwulonglong value); virtual void putUnsignedShort(unsigned short value); virtual void putUCharacter(RWUChar value); virtual void putUString(const RWBasicUString& value); virtual void putWchar_t(wchar_t value); virtual void putWCharacter(wchar_t value); virtual void putWString(const RWWString& value);
Puts a value into the stream, where the type of the value is defined by the first parameter. These functions are redefined from the parent class RWObjectOutputStreamImp.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.