Module: Advanced Tools Package: Streams
RWTInputStreamBufferImp FilteredInputStreamImp
#include <rw/stream/RWTInputStreamBufferImp.h>
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.
typedef Inputstream RWInputStream_type RWInputStream_type typedef InputStream::element_type element_type
RWTInputStreamBufferImp(InputStream& sourceStream);
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.
Parameter List
sourceStream |
The input stream that will serve as the source of elements. |
RWTInputStreamBufferImp(InputStream& sourceStream,
RWSize bufSize);
Initializes the reference to the input stream that will be used as the source of elements, as well as the buffer capacity.
Parameter List
sourceStream |
The input stream that will serve as the source of elements. |
bufSize |
The buffer capacity in number of elements. |
RWTInputStreamBufferImp(InputStream& sourceStream,
element_type* buffer, RWSize bufSize);
Initializes the reference to the input stream that will be used as the source of elements, as well as the internal buffer.
Parameter List
sourceStream |
The input stream that will serve as the source of elements. |
buffer |
A pre-allocated buffer of size bufSize to be used internally by the constructed RWTInputStreamBufferImp object. |
virtual ~RWTInputStreamBufferImp();
Destructor.
static InputStream make(InputStream& sourceStream);
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.
Parameter List
sourceStream |
The input stream that will serve as the source of elements. |
static InputStream make(InputStream& sourceStream, RWSize bufSize);
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.
Parameter List
sourceStream |
The input stream that will serve as the source of elements. |
bufSize |
The buffer capacity in number of elements. |
static InputStream make(InputStream& sourceStream, element_type* buffer,
RWSize bufSize);
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.
Parameter List
sourceStream |
The input stream that will serve as the source of elements. |
buffer |
A pre-allocated buffer of size bufSize to be used internally by the constructed RWTInputStreamBufferImp object. |
virtual RWSize available() const;
Returns the number of elements that can be read from the stream without blocking. Throws no exceptions.
virtual bool isBad() const;
If the stream is in bad state, then this function returns true, otherwise it returns false. Throws no exceptions.
virtual bool isEof() const;
If no character can be obtained from the input sequence, this function returns true, otherwise it returns false. Throws no exceptions.
virtual bool isFail() const;
If the stream is in fail state, then this function returns true, otherwise it returns false. Throws no exceptions.
virtual bool isGood() const;
If the stream is in fail or bad state, then this function returns false, otherwise it returns true. Throws no exceptions.
virtual element_type read();
Reads a single element.
virtual RWSize read(element_type* array, RWSize num);
Reads an array of elements. The function returns the actual number of elements read.
Parameter List
array |
A pointer to the first element of the array. The array must have been pre-allocated to contain at least num elements. |
num |
The number of elements to be read from the stream. |
virtual RWSize readUntil(element_type* array, RWSize maxSize,
element_type delim);
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.
Parameter List
array |
A pointer to the array receiving the elements extracted from the stream. |
maxSize |
The maximum number of elements to be read. |
delim |
The element value used as a delimiter. |
virtual RWSize skip(RWSize numUnits);
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.
Parameter List
numUnits |
The number of elements to be skipped. |
element_type* eback() const;
Returns a pointer to the buffer first element. Throws no exceptions.
element_type* ebuf() const;
Returns a pointer one position past the end of the buffer. Throws no exceptions.
element_type* egptr() const;
Returns a pointer one position past the input sequence last element. Throws no exceptions.
void freeBuffer();
Frees the memory associated with the internal buffer if necessary. Throws no exceptions.
element_type* gptr() const;
Returns a pointer to the input sequence current position. Throws no exceptions.
void gbump(RWSize n);
Moves the current get pointer n positions forward. Throws no exceptions.
Parameter List
n |
The number of elements the current get pointer should be advanced. |
void setBufferEnd(element_type* gend_arg);
Sets the buffer's end pointer. Throws no exceptions.
Parameter List
gend_arg |
The value to be set in bufEnd_. |
void setg(element_type* gbeg_arg,
element_type* gcur_arg,element_type* gend_arg);
Sets the buffer's pointers. Throws no exceptions.
Parameter List
gbeg_arg |
The value to be set in gbeg_. |
gcur_arg |
The value to be set in gnext_. |
gend_arg |
The value to be set in gend_. |
bool underflow();
Fills up the buffer. Returns true if there are elements available, otherwise returns false. Throws no exceptions.
© 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.