Module: Advanced Tools Package: Streams
RWTOutputStreamBufferImp FilteredOutputStreamImp
close() element_type epptr() flush() |
freeBuffer() make() pbase() pbump() |
pptr() RWOutputStream_type RWTOutputStreamBufferImp() setp() |
write() ~RWTOutputStreamBufferImp() |
#include <rw/stream/RWTOutputStreamBufferImp.h>
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.
typedef OutputStream RWOutputStream_type RWOutputStream_type typedef OutputStream::element_type element_type
RWTOutputStreamBufferImp(OutputStream& sinkStream);
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.
Parameter List
sinkStream |
The output stream that will serve as the sink of elements. |
RWTOutputStreamBufferImp(OutputStream& sinkStream,
RWSize bufSize);
Initializes the reference to the output stream that will be used as the sink of elements, as well as the buffer capacity.
Parameter List
sinkStream |
The output stream that will serve as the sink of elements. |
bufSize |
The buffer capacity in number of elements. |
RWTOutputStreamBufferImp(OutputStream& sinkStream,
element_type* buffer,
RWSize bufSize);
Initializes the reference to the output stream that will be used as the sink of elements, as well as the internal buffer.
Parameter List
sinkStream |
The output stream that will serve as the sink of elements. |
buffer |
A pre-allocated buffer of size bufSize to be used internally by the constructed RWTOutputStreamBufferImp object. |
virtual ~RWTOutputStreamBufferImp();
Destructor.
static OutputStream make(OutputStream& sinkStream);
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.
Parameter List
sinkStream |
The output stream that will serve as the sink of elements. |
static OutputStream make(OutputStream& sinkStream, RWSize bufSize);
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.
Parameter List
sinkStream |
The output stream that will serve as the sink of elements. |
bufSize |
The buffer capacity in number of elements. |
static OutputStream make(OutputStream& sinkStream, element_type* buffer,
RWSize bufSize);
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.
Parameter List
sinkStream |
The output stream that will serve as the sink of elements. |
buffer |
A pre-allocated buffer of size bufSize to be used internally by the constructed RWTOutputStreamBufferImp object. |
virtual void close();
Calls flush(), then calls close() on the next processing stream.
virtual void flush();
Flushes the buffer by forwarding its content to the next processing stream.
virtual void write(const element_type* array, RWSize numElements);
Writes an array of elements to the stream.
Parameter List
array |
A pointer to the first element of the array. |
numElements |
The number of elements to be written to the stream. |
virtual void write(element_type value);
Writes a single element to the stream.
Parameter List
value |
The element to be written to the stream. |
element_type* epptr() const;
Returns a pointer one position past the buffer's last element. Throws no exceptions.
void freeBuffer();
Frees the memory associated with the internal buffer if necessary. Throws no exceptions.
element_type* pbase() const;
Returns a pointer to the buffer's first element. Throws no exceptions.
void pbump(RWSize n);
Moves the current put pointer n position forward. Throws no exceptions.
Parameter List
n |
The number of elements the current put pointer should be advanced. |
element_type* pptr() const;
Returns a pointer to the buffer's current position. Throws no exceptions.
void setp(element_type* pbeg_arg,element_type* pend_arg);
Sets the buffer's pointers. Throws no exceptions.
Parameter List
pbeg_arg |
The value to be set in pbeg_ and pnext_. |
pend_arg |
The value to be set in pend_. |
© 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.