SourcePro® API Reference Guide

 
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions
RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform > Class Template Reference

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

#include <rw/xmlstreams/RWTTransformInputStreamImp.h>

Inherits FilteredInputStreamImp.

Public Types

typedef InputStream::element_type element_type
 

Public Member Functions

virtual ~RWTTransformInputStreamImp ()
 
virtual RWSize available () const
 
virtual bool isBad () const
 
virtual bool isEof () const
 
virtual bool isFail () const
 
virtual bool isGood () const
 
virtual element_type read ()
 
virtual RWSize read (element_type *array, RWSize num)
 
virtual RWSize readUntil (element_type *array, RWSize maxSize, element_type delim)
 

Static Public Member Functions

static InputStream make (const InputStream &sourceStream, Transform transform)
 
static InputStream make (const InputStream &sourceStream, Transform transform, RWSize bufSize)
 
static InputStream make (const InputStream &sourceStream, Transform transform, element_type *buffer, RWSize bufSize)
 

Protected Member Functions

 RWTTransformInputStreamImp (const InputStream &sourceStream, Transform transform)
 
 RWTTransformInputStreamImp (const InputStream &sourceStream, Transform transform, RWSize bufSize)
 
 RWTTransformInputStreamImp (const InputStream &sourceStream, Transform transform, element_type *buffer, RWSize bufSize)
 
element_typeeback () const
 
element_typeebuf () const
 
element_typeegptr () const
 
void freeBuffer ()
 
void gbump (RWSize n)
 
element_typegptr () const
 
void setBufferEnd (element_type *gend_arg)
 
void setg (element_type *gbeg_arg, element_type *gcur_arg, element_type *gend_arg)
 
bool underflow ()
 

Detailed Description

template<class InputStream, class FilteredInputStreamImp, class Transform>
class RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >

The class RWTTransformInputStreamImp implements a buffered char or byte input character 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.

RWTTransformInputStreamImp is a class template that is derived from one of its own template parameters.

The class is defined as

template <class InputStream, class FilteredInputStreamImp,
class Transform>
public FilteredInputStreamImp { ...}

When the read() or readUntil() is first called on this class, the transform() method of the transformation object passed into the constructor gets called. The transform() method reads from the source, applies the transformation defined by the method, and stores the result in the buffer. Once the buffer contains the entire transformed document, the call to read() or readUntil() is completed by reading from the buffer.

Member Typedef Documentation

template<class InputStream , class FilteredInputStreamImp , class Transform >
typedef InputStream::element_type RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, 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."

Constructor & Destructor Documentation

template<class InputStream , class FilteredInputStreamImp , class Transform >
virtual RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::~RWTTransformInputStreamImp ( )
virtual

Virtual destructor. Throws no exceptions.

template<class InputStream , class FilteredInputStreamImp , class Transform >
RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::RWTTransformInputStreamImp ( const InputStream &  sourceStream,
Transform  transform 
)
protected

Initializes the reference to the input stream used as the source of elements, and the internal buffer, whose capacity is set equal to RW_STREAM_BUFFER_SIZE.

The parameter sourceStream represents the input stream that serves as the source 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> >&)
template<class InputStream , class FilteredInputStreamImp , class Transform >
RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::RWTTransformInputStreamImp ( const InputStream &  sourceStream,
Transform  transform,
RWSize  bufSize 
)
protected

Initializes the reference to the input stream used as the source of elements, and the internal buffer, whose capacity is set to bufSize.

The parameter sourceStream represents the input stream that serves as the source 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.

template<class InputStream , class FilteredInputStreamImp , class Transform >
RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::RWTTransformInputStreamImp ( const InputStream &  sourceStream,
Transform  transform,
element_type buffer,
RWSize  bufSize 
)
protected

Initializes the reference to the input stream used as the source of elements, and the internal buffer, which is initialized using a pre-allocated element's array of size bufSize.

The parameter sourceStream represents the input stream that serves as the source 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 RWTTransformInputStreamImp object.

Member Function Documentation

template<class InputStream , class FilteredInputStreamImp , class Transform >
virtual RWSize RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::available ( ) const
virtual

Returns the number of elements that can be read from the stream without blocking. Throws no exceptions.

template<class InputStream , class FilteredInputStreamImp , class Transform >
element_type* RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::eback ( ) const
inlineprotected

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

template<class InputStream , class FilteredInputStreamImp , class Transform >
element_type* RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::ebuf ( ) const
inlineprotected

Returns a pointer one position past the end of the input buffer array. Throws no exceptions.

template<class InputStream , class FilteredInputStreamImp , class Transform >
element_type* RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::egptr ( ) const
inlineprotected

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

template<class InputStream , class FilteredInputStreamImp , class Transform >
void RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::freeBuffer ( )
protected

Frees the memory allocated to the internal buffer, if necessary. Throws no exceptions.

template<class InputStream , class FilteredInputStreamImp , class Transform >
void RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::gbump ( RWSize  n)
inlineprotected

Moves the input buffer array pointer n positions forward. The array position now pointed to is the one returned by gptr(). Throws no exceptions.

template<class InputStream , class FilteredInputStreamImp , class Transform >
element_type* RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::gptr ( ) const
inlineprotected

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

template<class InputStream , class FilteredInputStreamImp , class Transform >
virtual bool RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::isBad ( ) const
virtual

Returns true if the stream is in a bad state, otherwise false. Throws no exceptions.

template<class InputStream , class FilteredInputStreamImp , class Transform >
virtual bool RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::isEof ( ) const
virtual

Returns true if no character can be obtained from the input sequence, otherwise false. Throws no exceptions.

template<class InputStream , class FilteredInputStreamImp , class Transform >
virtual bool RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::isFail ( ) const
virtual

Returns true if the stream is in fail state, otherwise false. Throws no exceptions.

template<class InputStream , class FilteredInputStreamImp , class Transform >
virtual bool RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::isGood ( ) const
virtual

Returns false if the stream is in fail or bad state, otherwise true. Throws no exceptions.

template<class InputStream , class FilteredInputStreamImp , class Transform >
static InputStream RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::make ( const InputStream &  sourceStream,
Transform  transform 
)
inlinestatic

Constructs an RWTTransformInputStreamImp instance that uses sourceStream as its source of elements, and returns a handle to it. The internal buffer is initialized to be of size RW_STREAM_BUFFER_SIZE. The buffer grows as needed to contain the entire XML document.

The parameter sourceStream represents the input stream that serves as the source 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> >&)
template<class InputStream , class FilteredInputStreamImp , class Transform >
static InputStream RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::make ( const InputStream &  sourceStream,
Transform  transform,
RWSize  bufSize 
)
inlinestatic

Constructs an RWTTransformInputStreamImp instance that uses sourceStream as its source 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 sourceStream represents the input stream that serves as the source 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 initial buffer capacity in number of elements.

template<class InputStream , class FilteredInputStreamImp , class Transform >
static InputStream RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::make ( const InputStream &  sourceStream,
Transform  transform,
element_type buffer,
RWSize  bufSize 
)
inlinestatic

Constructs an RWTTransformInputStreamImp instance that uses sourceStream as its source 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 sourceStream represents the input stream that serves as the source 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 RWTTransformInputStreamImp object.

template<class InputStream , class FilteredInputStreamImp , class Transform >
virtual element_type RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::read ( )
virtual

Reads a single element from the input stream.

template<class InputStream , class FilteredInputStreamImp , class Transform >
virtual RWSize RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::read ( element_type array,
RWSize  num 
)
virtual

Reads an array of elements from the input stream. Returns the actual number of elements read.

The parameter array represents a pointer to the beginning of the element array used to store the input. The array must have been pre-allocated to contain at least num elements. The parameter num represents the number of elements to be read from the stream.

template<class InputStream , class FilteredInputStreamImp , class Transform >
virtual RWSize RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::readUntil ( element_type array,
RWSize  maxSize,
element_type  delim 
)
virtual

Reads elements until the last element read is equivalent to delim, maxSize elements have been read, or the end of the input sequence is reached. The elements read are stored in array. The function returns the actual number of elements read from the stream.

The parameter array represents a pointer to the beginning of the element array holding the elements extracted from the stream.

The parameter maxSize represents the maximum number of elements to be read.

The parameter delim represents the element value used as the delimiter.

template<class InputStream , class FilteredInputStreamImp , class Transform >
void RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::setBufferEnd ( element_type gend_arg)
inlineprotected

Sets the buffer's end pointer. Assigns the parameter value bufEnd_. Throws no exceptions.

template<class InputStream , class FilteredInputStreamImp , class Transform >
void RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::setg ( element_type gbeg_arg,
element_type gcur_arg,
element_type gend_arg 
)
inlineprotected

Assigns the parameter values to gbeg_, gnext_, and gend_ respectively. These data members represent the beginning of the buffer array, the current position in the array, and the end of the array.

template<class InputStream , class FilteredInputStreamImp , class Transform >
bool RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::underflow ( )
protected

Fills the input buffer. Returns true if there are elements available, otherwise false.

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