SourcePro® API Reference Guide

 
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions
RWTOutputStreamBufferImp< OutputStream, FilteredOutputStreamImp > Class Template Reference

Implements a buffer that can be used with any kind of output stream. More...

#include <rw/stream/RWTOutputStreamBufferImp.h>

Inherits FilteredOutputStreamImp.

Public Types

typedef OutputStream::element_type element_type
 
typedef OutputStream RWOutputStream_type
 

Public Member Functions

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

Static Public Member Functions

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

Protected Member Functions

 RWTOutputStreamBufferImp (const OutputStream &sinkStream)
 
 RWTOutputStreamBufferImp (const OutputStream &sinkStream, RWSize bufSize)
 
 RWTOutputStreamBufferImp (const OutputStream &sinkStream, element_type *buffer, RWSize bufSize)
 
element_typeepptr () const
 
void freeBuffer ()
 
element_typepbase () const
 
void pbump (RWSize n)
 
element_typepptr () const
 
void setp (element_type *pbeg_arg, element_type *pend_arg)
 

Detailed Description

template<class OutputStream, class FilteredOutputStreamImp>
class RWTOutputStreamBufferImp< OutputStream, FilteredOutputStreamImp >

The class RWTOutputStreamBufferImp implements a buffer that can be used with any kind of output stream. The size of the buffer is specified in its static member make() function, which is used to create it. The buffer's role is to store elements up to its maximum capacity, and then to forward them to its associated sink stream. The buffer flushes itself upon destruction.

Member Typedef Documentation

template<class OutputStream , class FilteredOutputStreamImp >
typedef OutputStream::element_type RWTOutputStreamBufferImp< OutputStream, FilteredOutputStreamImp >::element_type

A typedef for the type of element to be written to RWOutputStream_type.

template<class OutputStream , class FilteredOutputStreamImp >
typedef OutputStream RWTOutputStreamBufferImp< OutputStream, FilteredOutputStreamImp >::RWOutputStream_type

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

Constructor & Destructor Documentation

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

Destructor.

template<class OutputStream , class FilteredOutputStreamImp >
RWTOutputStreamBufferImp< OutputStream, FilteredOutputStreamImp >::RWTOutputStreamBufferImp ( const OutputStream &  sinkStream)
protected

Initializes the reference to the output stream that will be used as the sink of elements, as well as the internal buffer capacity, which will be equal to RW_STREAM_BUFFER_SIZE.

Parameters
sinkStreamThe output stream that will serve as the sink of elements.
template<class OutputStream , class FilteredOutputStreamImp >
RWTOutputStreamBufferImp< OutputStream, FilteredOutputStreamImp >::RWTOutputStreamBufferImp ( const OutputStream &  sinkStream,
RWSize  bufSize 
)
protected

Initializes the reference to the output stream that will be used as the sink of elements, as well as the buffer capacity.

Parameters
sinkStreamThe output stream that will serve as the sink of elements.
bufSizeThe buffer capacity in number of elements.
template<class OutputStream , class FilteredOutputStreamImp >
RWTOutputStreamBufferImp< OutputStream, FilteredOutputStreamImp >::RWTOutputStreamBufferImp ( const OutputStream &  sinkStream,
element_type buffer,
RWSize  bufSize 
)
protected

Initializes the reference to the output stream that will be used as the sink of elements, as well as the internal buffer.

Parameters
sinkStreamThe output stream that will serve as the sink of elements.
bufferA pre-allocated buffer of size bufSize used internally by the constructed RWTOutputStreamBufferImp object.
bufSizeThe buffer capacity in number of elements.

Member Function Documentation

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

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

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

Returns a pointer one position past the buffer's last element. Throws no exceptions.

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

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

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

Frees the memory associated with the internal buffer if necessary. Throws no exceptions.

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

Constructs an RWTOutputStreamBufferImp instance that uses sinkStream as its sink of elements, and returns a handle to it. The internal buffer is dynamically allocated to be of size RW_STREAM_BUFFER_SIZE.

Parameters
sinkStreamThe output stream that will serve as the sink of elements.
template<class OutputStream , class FilteredOutputStreamImp >
static OutputStream RWTOutputStreamBufferImp< OutputStream, FilteredOutputStreamImp >::make ( const OutputStream &  sinkStream,
RWSize  bufSize 
)
inlinestatic

Constructs an RWTOutputStreamBufferImp instance that uses sinkStream as its sink of elements, and returns a handle to it. The internal buffer is dynamically allocated to be of size bufSize.

Parameters
sinkStreamThe output stream that will serve as the sink of elements.
bufSizeThe buffer capacity in number of elements.
template<class OutputStream , class FilteredOutputStreamImp >
static OutputStream RWTOutputStreamBufferImp< OutputStream, FilteredOutputStreamImp >::make ( const OutputStream &  sinkStream,
element_type buffer,
RWSize  bufSize 
)
inlinestatic

Constructs an RWTOutputStreamBufferImp instance that uses sinkStream as its sink of elements, and returns a handle to it. The internal buffer is initialized using the pre-allocated element's array of size bufSize.

Parameters
sinkStreamThe output stream that will serve as the sink of elements.
bufferA pre-allocated buffer of size bufSize to be used internally by the constructed RWTOutputStreamBufferImp object.
bufSizeThe buffer capacity in number of elements.
template<class OutputStream , class FilteredOutputStreamImp >
element_type* RWTOutputStreamBufferImp< OutputStream, FilteredOutputStreamImp >::pbase ( ) const
inlineprotected

Returns a pointer to the buffer's first element. Throws no exceptions.

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

Moves the current put pointer n position forward. Throws no exceptions.

Parameters
nThe number of elements the current put pointer should be advanced.
template<class OutputStream , class FilteredOutputStreamImp >
element_type* RWTOutputStreamBufferImp< OutputStream, FilteredOutputStreamImp >::pptr ( ) const
inlineprotected

Returns a pointer to the buffer's current position. Throws no exceptions.

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

Sets the buffer's pointers. Throws no exceptions.

Parameters
pbeg_argThe value to be set in pbeg_ and pnext_.
pend_argThe value to be set in pend_.
template<class OutputStream , class FilteredOutputStreamImp >
virtual void RWTOutputStreamBufferImp< OutputStream, FilteredOutputStreamImp >::write ( element_type  value)
virtual

Writes a single element to the stream.

Parameters
valueThe element to be written to the stream.
template<class OutputStream , class FilteredOutputStreamImp >
virtual void RWTOutputStreamBufferImp< OutputStream, FilteredOutputStreamImp >::write ( const element_type array,
RWSize  numElements 
)
virtual

Writes an array of elements to the stream.

Parameters
arrayA pointer to the first element of the array.
numElementsThe number of elements to be written to the stream.

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