rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform > Class Template Reference
[XML Streams]

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

#include <rw/xmlstreams/RWTTransformInputStreamImp.h>

List of all members.

Public Types

typedef InputStream::element_type element_type

Public Member Functions

virtual ~RWTTransformInputStreamImp ()
virtual bool isEof () const
virtual bool isBad () 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)
virtual RWSize available () const

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_typegptr () const
element_typeegptr () const
element_typeebuf () const
void setg (element_type *gbeg_arg, element_type *gcur_arg, element_type *gend_arg)
void setBufferEnd (element_type *gend_arg)
void gbump (RWSize n)
void freeBuffer ()
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>

 class RWTTransformInputStreamImp : 
   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 [inline, protected]

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 [inline, protected]

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 [inline, protected]

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  )  [inline, protected]

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 [inline, protected]

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,
element_type buffer,
RWSize  bufSize 
) [inline, static]

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 >
static InputStream RWTTransformInputStreamImp< InputStream, FilteredInputStreamImp, Transform >::make ( const InputStream &  sourceStream,
Transform  transform,
RWSize  bufSize 
) [inline, static]

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 
) [inline, static]

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 >
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 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 >::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  )  [inline, protected]

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 
) [inline, protected]

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.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© 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.