Module: XML Streams Package: XML Streams
RWTTransformObjectOutputStreamImp RWXmlObjectOutputStreamImp
#include <rw/xmlstreams/RWTTransformObjectOutputStreamImp.h>
This class uses RWXmlObjectOutputStreamImp and RWTTransformOutputStreamImp to construct an XML stream that applies a generic transformation to the XML document before writing it out to the sink.
// Create a strstream to serve as our sink ostrstream s; // Create a transformation object MyTransform t; // Create an XML data stream using the strstream RWObjectOutputStream out = RWTTransformObjectOutputStreamImp<MyTransform>::make(s,t); // Write integer value `1' to XML data stream out << 1;
static RWObjectOutputStream make(RW_SL_IO_STD(ostream)& sink, Transform transformer, const RWCString& rootElementType=nestedObjectTag, bool escape = true);
Constructs an RWTTransformObjectOutputStreamImp instance and returns a handle to it. The constructed instance applies a generic transformation to the serialized object data and then passes the data to the output stream sink.
The parameter transformer is a transformation object that must supply a public interface function transform(istream&,ostream&).
The parameter rootElementType must be one of the following:
nestedObjectTag, if serializing an object by value
objectTag, if serializing an object by pointer
sequence, if serializing a sequential collection such as RWTPtrOrderedVector
map, if serializing a mapping collection such as RWTPtrHashMap
primitive, 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. 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.
static RWObjectOutputStream make(RW_SL_IO_STD(ostream)& sink,
Transform transform,
RW_SL_IO_STD(ios)*& formatter,
const RWCString& rootElementType=nestedObjectTag,
bool escape = true);
This function is the same as the one 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 = RWTTransformObjectOutputStreamImp<MyTransform>
::make(outfile,script,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
RWTTransformObjectOutputStreamImp(RW_SL_IO_STD(ostream)& ostr,
Transform transformer,
const RWCString& rootElementType, bool escape);
Used by the make() function and potentially by derived classes to initialize an output stream and to insert a transformation of the serialized object data based on the transformation object transformer.
The parameter ostr is a handle to the initialized stream.
The parameter transformer is a transformation object that must supply a public interface function transform(istream&,ostream&).
The parameter rootElementType must be one of the following:
nestedObjectTag, if serializing an object by value
objectTag, if serializing an object by pointer
sequence, if serializing a sequential collection such as RWTPtrOrderedVector
map, if serializing a mapping collection such as RWTPtrHashMap
primitive, if serializing a built-in type such as int
The value passed indicates the root element of the generated document.
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.
RWTTransformObjectOutputStreamImp(RW_SL_IO_STD(ostream)& ostr, Transform transform, RW_SL_IO_STD(ios)*& formatter, const RWCString& rootElementType, bool escape);
This constructor is the same as the one 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 to this constructor through the make() function. This 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. See the corresponding make() function description above for an example.
© 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.