SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWTInputStreamBufferImp< InputStream, FilteredInputStreamImp > Class Template Reference

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

#include <rw/stream/RWTInputStreamBufferImp.h>

Inherits FilteredInputStreamImp.

Public Types

typedef InputStream::element_type element_type
 
typedef InputStream RWInputStream_type
 

Public Member Functions

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

Static Public Member Functions

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

Protected Member Functions

 RWTInputStreamBufferImp (const InputStream &sourceStream)
 
 RWTInputStreamBufferImp (const InputStream &sourceStream, element_type *buffer, RWSize bufSize)
 
 RWTInputStreamBufferImp (const InputStream &sourceStream, 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 ()
 

Friends

class RWBufferedCharInputStreamImp
 

Detailed Description

template<class InputStream, class FilteredInputStreamImp>
class RWTInputStreamBufferImp< InputStream, FilteredInputStreamImp >

The class RWTInputStreamBufferImp implements a buffer that can be used with any kind of input stream. The size of the buffer is specified in its static member make() function, which is used to create it.

Member Typedef Documentation

◆ element_type

template<class InputStream , class FilteredInputStreamImp >
typedef InputStream::element_type RWTInputStreamBufferImp< InputStream, FilteredInputStreamImp >::element_type

A typedef for the type of element to be read from RWInputStream_type.

◆ RWInputStream_type

template<class InputStream , class FilteredInputStreamImp >
typedef InputStream RWTInputStreamBufferImp< InputStream, FilteredInputStreamImp >::RWInputStream_type

A typedef for the template parameter InputStream which will be used as the source of elements.

Constructor & Destructor Documentation

◆ ~RWTInputStreamBufferImp()

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

Destructor.

◆ RWTInputStreamBufferImp() [1/3]

template<class InputStream , class FilteredInputStreamImp >
RWTInputStreamBufferImp< InputStream, FilteredInputStreamImp >::RWTInputStreamBufferImp ( const InputStream & sourceStream)
protected

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

Parameters
sourceStreamThe input stream that will serve as the source of elements.

◆ RWTInputStreamBufferImp() [2/3]

template<class InputStream , class FilteredInputStreamImp >
RWTInputStreamBufferImp< InputStream, FilteredInputStreamImp >::RWTInputStreamBufferImp ( const InputStream & sourceStream,
RWSize bufSize )
protected

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

Parameters
sourceStreamThe input stream that will serve as the source of elements.
bufSizeThe buffer capacity in number of elements.

◆ RWTInputStreamBufferImp() [3/3]

template<class InputStream , class FilteredInputStreamImp >
RWTInputStreamBufferImp< InputStream, FilteredInputStreamImp >::RWTInputStreamBufferImp ( const InputStream & sourceStream,
element_type * buffer,
RWSize bufSize )
protected

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

Parameters
sourceStreamThe input stream that will serve as the source of elements.
bufferA pre-allocated buffer of size bufSize to be used internally by the constructed RWTInputStreamBufferImp object.
bufSizeThe buffer capacity in number of elements.

Member Function Documentation

◆ available()

template<class InputStream , class FilteredInputStreamImp >
virtual RWSize RWTInputStreamBufferImp< InputStream, FilteredInputStreamImp >::available ( void ) const
virtual

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

◆ eback()

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

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

◆ ebuf()

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

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

◆ egptr()

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

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

◆ freeBuffer()

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

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

◆ gbump()

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

Moves the current get pointer n positions forward. Throws no exceptions.

Parameters
nThe number of elements the current get pointer should be advanced.

◆ gptr()

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

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

◆ isBad()

template<class InputStream , class FilteredInputStreamImp >
virtual bool RWTInputStreamBufferImp< InputStream, FilteredInputStreamImp >::isBad ( void ) const
virtual

If the stream is in bad state, then this function returns true, otherwise it returns false. Throws no exceptions.

◆ isEof()

template<class InputStream , class FilteredInputStreamImp >
virtual bool RWTInputStreamBufferImp< InputStream, FilteredInputStreamImp >::isEof ( void ) const
virtual

If no character can be obtained from the input sequence, this function returns true, otherwise it returns false. Throws no exceptions.

◆ isFail()

template<class InputStream , class FilteredInputStreamImp >
virtual bool RWTInputStreamBufferImp< InputStream, FilteredInputStreamImp >::isFail ( void ) const
virtual

If the stream is in fail state, then this function returns true, otherwise it returns false. Throws no exceptions.

◆ isGood()

template<class InputStream , class FilteredInputStreamImp >
virtual bool RWTInputStreamBufferImp< InputStream, FilteredInputStreamImp >::isGood ( void ) const
virtual

If the stream is in fail or bad state, then this function returns false, otherwise it returns true. Throws no exceptions.

◆ make() [1/3]

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

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

Parameters
sourceStreamThe input stream that will serve as the source of elements

◆ make() [2/3]

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

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

Parameters
sourceStreamThe input stream that will serve as the source of elements.
bufferA pre-allocated buffer of size bufSize to be used internally by the constructed RWTInputStreamBufferImp object.
bufSizeThe buffer capacity in number of elements.

◆ make() [3/3]

template<class InputStream , class FilteredInputStreamImp >
static InputStream RWTInputStreamBufferImp< InputStream, FilteredInputStreamImp >::make ( const InputStream & sourceStream,
RWSize bufSize )
inlinestatic

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

Parameters
sourceStreamThe input stream that will serve as the source of elements.
bufSizeThe buffer capacity in number of elements.

◆ read() [1/2]

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

Reads an array of elements. The function returns the actual number of elements read.

Parameters
arrayA pointer to the first element of the array. The array must have been pre-allocated to contain at least num elements.
numThe number of elements to be read from the stream.

◆ read() [2/2]

template<class InputStream , class FilteredInputStreamImp >
virtual element_type RWTInputStreamBufferImp< InputStream, FilteredInputStreamImp >::read ( void )
virtual

Reads a single element.

◆ readUntil()

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

Reads elements until the last element read is equal to delim, or 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.

Parameters
arrayA pointer to the array receiving the elements extracted from the stream.
maxSizeThe maximum number of elements to be read.
delimThe element value used as a delimiter.

◆ setBufferEnd()

template<class InputStream , class FilteredInputStreamImp >
void RWTInputStreamBufferImp< InputStream, FilteredInputStreamImp >::setBufferEnd ( element_type * gend_arg)
inlineprotected

Sets the buffer's end pointer. Throws no exceptions.

Parameters
gend_argThe value to be set in bufEnd_.

◆ setg()

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

Sets the buffer's pointers. Throws no exceptions.

Parameters
gbeg_argThe value to be set in gbeg_.
gcur_argThe value to be set in gnext_.
gend_argThe value to be set in gend_.

◆ skip()

template<class InputStream , class FilteredInputStreamImp >
virtual RWSize RWTInputStreamBufferImp< InputStream, FilteredInputStreamImp >::skip ( RWSize numUnits)
virtual

Skips numUnits elements from the input sequence if possible. The function returns the actual number of elements skipped, which can be any value between 0 and numUnits.

Parameters
numUnitsThe number of elements to be skipped.

◆ underflow()

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

Fills up the buffer. Returns true if there are elements available, otherwise returns false. Throws no exceptions.

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