SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform > Class Template Reference

Implements a buffered char or byte output stream that includes a transformation. More...

#include <rw/xmlstreams/RWTTransformOutputStreamImp.h>

Inherits FilteredOutputStreamImp.

Public Types

typedef OutputStream::element_type element_type
 
typedef OutputStream RWOutputStream_type
 

Public Member Functions

virtual ~RWTTransformOutputStreamImp ()
 
virtual void close ()
 
virtual void flush ()
 
virtual void write (const element_type *array, RWSize numElements)
 
virtual void write (element_type value)
 

Static Public Member Functions

static OutputStream make (const OutputStream &sinkStream, Transform transform)
 
static OutputStream make (const OutputStream &sinkStream, Transform transform, element_type *buffer, RWSize bufSize)
 
static OutputStream make (const OutputStream &sinkStream, Transform transform, RWSize bufSize)
 

Protected Member Functions

 RWTTransformOutputStreamImp (const OutputStream &sinkStream, Transform transform)
 
 RWTTransformOutputStreamImp (const OutputStream &sinkStream, Transform transform, element_type *buffer, RWSize bufSize)
 
 RWTTransformOutputStreamImp (const OutputStream &sinkStream, Transform transform, RWSize bufSize)
 
element_typeepptr () const
 
void freeBuffer ()
 
element_typepbase () const
 
void pbump (RWSize n)
 
element_typepptr () const
 
void setBuffer (RWSize bufsize)
 
void setp (element_type *pbeg_arg, element_type *pend_arg)
 
virtual void transform ()
 

Detailed Description

template<class OutputStream, class FilteredOutputStreamImp, class Transform>
class RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >

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 {
// ...
}
Implements a buffered char or byte output stream that includes a transformation.
Definition RWTTransformOutputStreamImp.h:64

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.

Member Typedef Documentation

◆ element_type

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
typedef OutputStream::element_type RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::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."

◆ RWOutputStream_type

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
typedef OutputStream RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::RWOutputStream_type

A typedef for the template parameter OutputStream which will be used as the sink for elements.

Constructor & Destructor Documentation

◆ ~RWTTransformOutputStreamImp()

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
virtual RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::~RWTTransformOutputStreamImp ( )
virtual

Virtual destructor. Throws no exceptions.

◆ RWTTransformOutputStreamImp() [1/3]

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::RWTTransformOutputStreamImp ( const OutputStream & sinkStream,
Transform transform )
protected

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> >)
OutputStream::element_type element_type
Definition RWTTransformOutputStreamImp.h:82

◆ RWTTransformOutputStreamImp() [2/3]

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::RWTTransformOutputStreamImp ( const OutputStream & sinkStream,
Transform transform,
RWSize bufSize )
protected

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() [3/3]

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::RWTTransformOutputStreamImp ( const OutputStream & sinkStream,
Transform transform,
element_type * buffer,
RWSize bufSize )
protected

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.

Member Function Documentation

◆ close()

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
virtual void RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::close ( )
virtual

Calls flush() and then calls close() on the next processing stream.

◆ epptr()

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
element_type * RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::epptr ( ) const
inlineprotected

Returns a pointer one position past the last element in the output sequence. Throws no exceptions.

◆ flush()

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
virtual void RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::flush ( )
virtual

Flushes the buffer by forwarding its content to the next processing stream.

◆ freeBuffer()

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
void RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::freeBuffer ( )
protected

Frees the memory allocated to the internal buffer, if necessary.

◆ make() [1/3]

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
static OutputStream RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::make ( const OutputStream & sinkStream,
Transform transform )
inlinestatic

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> >)

◆ make() [2/3]

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
static OutputStream RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::make ( const OutputStream & sinkStream,
Transform transform,
element_type * buffer,
RWSize bufSize )
inlinestatic

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.

◆ make() [3/3]

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
static OutputStream RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::make ( const OutputStream & sinkStream,
Transform transform,
RWSize bufSize )
inlinestatic

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.

◆ pbase()

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
element_type * RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::pbase ( ) const
inlineprotected

Returns a pointer to the first element in the output buffer array. Throws no exceptions.

◆ pbump()

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
void RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::pbump ( RWSize n)
inlineprotected

Moves the output buffer array pointer n positions forward. The array position now pointed to is the one returned by pptr().

◆ pptr()

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
element_type * RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::pptr ( ) const
inlineprotected

Returns a pointer to the current position in the buffered output sequence. Throws no exceptions.

◆ setBuffer()

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
void RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::setBuffer ( RWSize bufsize)
protected

Sets the buffer size to bufsize.

◆ setp()

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
void RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::setp ( element_type * pbeg_arg,
element_type * pend_arg )
inlineprotected

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.

◆ transform()

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
virtual void RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::transform ( )
protectedvirtual

Internal transform function, which gets called by flush() and which then calls the transform() function of the transform object passed in to the constructor.

◆ write() [1/2]

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
virtual void RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::write ( const element_type * array,
RWSize numElements )
virtual

Writes an element array of size numElements to the stream. The parameter array is a pointer to the first element in the array.

◆ write() [2/2]

template<class OutputStream , class FilteredOutputStreamImp , class Transform >
virtual void RWTTransformOutputStreamImp< OutputStream, FilteredOutputStreamImp, Transform >::write ( element_type value)
virtual

Writes a single element to the stream.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.