Module: XML Streams Package: XML Streams
RWTTransformOutputStreamImp FilteredOutputStreamImp
close() element_type epptr() flush() |
freeBuffer() make() pbase() pbump() |
pptr() RWOutputStream_type RWTTransformOutputStreamImp() setBuffer() |
setp() transform() write() ~RWTTransformOutputStreamImp() |
#include <rw/xmlstreams/RWTTransformOutputStreamImp.h>
The class RWTTransformOutputStreamImp implements a buffered char or byte output stream that includes a transformation. The size of the buffer is specified as a parameter to the static make() function that is used to create it. If the buffer as initialized is not large enough to contain the entire XML document, it grows as needed to be able to do so. It is more efficient, though, to allocate a buffer of sufficient size initially.
RWTTransformOutputStreamImp is a class template that is derived from one of its own template parameters.
The class is defined as
template <class OutputStream, class FilteredOutputStreamImp,
class Transform> class RWTTransformOutputStreamImp :
public FilteredOutputStreamImp { ...}
The write() method of this class gets called until the entire output stream has been written to the buffer. Then the flush() method gets called, either directly or when the destructor is called. The flush() method calls the transform() method of the transformation object passed into the constructor. The transform() method reads the output stream flushed from the buffer, applies the transformation defined by the method, and writes the result to the sink stream.
typedef OutputStream RWOutputStream_type; typedef typename OutputStream::element_type element_type;
In keeping with the pattern for all filtered input streams, the type of character contained by the stream is referred to as the "element_type." Characters in the stream are called "elements" (not to be confused with XML "elements").
NOTE -- Be aware that characters in the stream are called "elements," which have no connection to XML "elements."
static OutputStream make(const OutputStream& sinkStream, Transform transform);
Constructs an RWTTransformOutputStreamImp instance that uses sinkStream as its sink of elements, and returns a handle to it. The internal buffer is initialized to be of size RW_STREAM_BUFFER_SIZE, which is defined as 512 bytes. The buffer grows as needed to contain the entire XML document.
The parameter sinkStream represents the output stream that serves as the sink of elements.
The parameter transform represents the transformation object and must provide a public interface of:
transform(basic_istream<element_type,
char_traits<element_type> >,
basic_ostream<element_type>,
char_traits<element_type> >)
static OutputStream make(const OutputStream& sinkStream, Transform transform, RWSize bufSize);
Constructs an RWTTransformOutputStreamImp instance that uses sinkStream as its sink of elements, and returns a handle to it. The internal buffer is initialized to be of size bufSize. The buffer grows as needed to contain the entire XML document.
The parameter sinkStream represents the output stream that serves as the sink of elements.
The parameter transform represents the transformation object and must provide a public interface of:
transform(basic_istream<element_type,
char_traits<element_type> >,
basic_ostream<element_type>,
char_traits<element_type> >)
The parameter bufSize represents the buffer capacity in number of elements.
static OutputStream make(const OutputStream& sinkStream, Transform transform, element_type* buffer, RWSize bufSize);
Constructs an RWTTransformOutputStreamImp instance that uses sinkStream as its sink of elements, and returns a handle to it. The internal buffer is initialized using a pre-allocated element's array of size bufSize. The buffer grows as needed to contain the entire XML document.
The parameter sinkStream represents the output stream that serves as the sink of elements.
The parameter transform represents the transformation object and must provide a public interface of:
transform(basic_istream<element_type,
char_traits<element_type> >,
basic_ostream<element_type>,
char_traits<element_type> >)
The parameter buffer represents a pre-allocated buffer of size bufSize to be used internally by the constructed RWTTransformOutputStreamImp object.
virtual ~RWTTransformOutputStreamImp();
Virtual destructor. Throws no exceptions.
virtual void write(element_type value);
Writes a single element to the stream.
virtual void write(const element_type* array, RWSize numElements);
Writes an element array of size numElements to the stream. The parameter array is a pointer to the first element in the array.
virtual void close();
Calls flush() and then calls close() on the next processing stream.
virtual void flush();
Flushes the buffer by forwarding its content to the next processing stream.
RWTTransformOutputStreamImp(const OutputStream& sinkStream, Transform transform);
Initializes the reference to the output stream used as the sink of elements, and the internal buffer, whose capacity is set to RW_STREAM_BUFFER_SIZE, defined as 512 bytes.
The parameter sinkStream represents the output stream that serves as the sink of elements.
The parameter transform represents the transformation object and must provide a public interface of:
transform(basic_istream<element_type,
char_traits<element_type> >,
basic_ostream<element_type>,
char_traits<element_type> >)
RWTTransformOutputStreamImp(const OutputStream& sinkStream, Transform transform, RWSize bufSize);
Initializes the reference to the output stream used as the sink of elements, and the internal buffer capacity, which is set to bufSize.
The parameter sinkStream represents the output stream that serves as the sink of elements.
The parameter transform represents the transformation object and must provide a public interface of:
transform(basic_istream<element_type,
char_traits<element_type> >,
basic_ostream<element_type>,
char_traits<element_type> >)
The parameter bufSize represents the buffer capacity in number of elements.
RWTTransformOutputStreamImp(const OutputStream& sinkStream, Transform transform, element_type* buffer, RWSize bufSize);
Initializes the reference to the output stream used as the sink of elements, and the internal buffer, which is initialized using a pre-allocated element's array of size bufSize.
The parameter sinkStream represents the output stream that serves as the sink of elements.
The parameter transform represents the transformation object and must provide a public interface of:
transform(basic_istream<element_type,
char_traits<element_type> >,
basic_ostream<element_type>,
char_traits<element_type> >)
The parameter buffer represents a pre-allocated buffer of size bufSize to be used internally by the constructed RWTTransformOutputStreamImp object.
element_type* epptr() const;
Returns a pointer one position past the last element in the output sequence. Throws no exceptions.
void freeBuffer();
Frees the memory allocated to the internal buffer, if necessary.
element_type* pbase() const;
Returns a pointer to the first element in the output buffer array. Throws no exceptions.
void pbump(RWSize n);
Moves the output buffer array pointer n positions forward. The array position now pointed to is the one returned by pptr().
element_type* pptr() const;
Returns a pointer to the current position in the buffered output sequence. Throws no exceptions.
void setBuffer(RWSize bufsize);
Sets the buffer size to bufsize.
void setp(element_type* pbeg_arg, element_type* pend_arg);
Assigns the first parameter value to pbeg_ and pnext_, and the second parameter value to gend_. These data members represent the beginning of the buffer array, the current position in the array, and the end of the array.
virtual void transform();
Internal transform function, which gets called by flush() and which then calls the transform() function of the transform object passed in to the constructor.
© 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.