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_type * | epptr () const |
void | freeBuffer () |
element_type * | pbase () const |
void | pbump (RWSize n) |
element_type * | pptr () const |
void | setp (element_type *pbeg_arg, element_type *pend_arg) |
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::element_type RWTOutputStreamBufferImp< OutputStream, FilteredOutputStreamImp >::element_type |
A typedef for the type of element to be written to RWOutputStream_type.
typedef OutputStream RWTOutputStreamBufferImp< OutputStream, FilteredOutputStreamImp >::RWOutputStream_type |
A typedef for the template parameter OutputStream
which will be used as the sink for elements.
|
virtual |
Destructor.
|
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.
sinkStream | The output stream that will serve as the sink of elements. |
|
protected |
Initializes the reference to the output stream that will be used as the sink of elements, as well as the buffer capacity.
sinkStream | The output stream that will serve as the sink of elements. |
bufSize | The buffer capacity in number of elements. |
|
protected |
Initializes the reference to the output stream that will be used as the sink of elements, as well as the internal buffer.
sinkStream | The output stream that will serve as the sink of elements. |
buffer | A pre-allocated buffer of size bufSize used internally by the constructed RWTOutputStreamBufferImp object. |
bufSize | The buffer capacity in number of elements. |
|
virtual |
|
inlineprotected |
Returns a pointer one position past the buffer's last element. Throws no exceptions.
|
virtual |
Flushes the buffer by forwarding its content to the next processing stream.
|
protected |
Frees the memory associated with the internal buffer if necessary. Throws no exceptions.
|
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.
sinkStream | The output stream that will serve as the sink of elements. |
|
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.
sinkStream | The output stream that will serve as the sink of elements. |
bufSize | The buffer capacity in number of elements. |
|
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.
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. |
bufSize | The buffer capacity in number of elements. |
|
inlineprotected |
Returns a pointer to the buffer's first element. Throws no exceptions.
|
inlineprotected |
Moves the current put pointer n position forward. Throws no exceptions.
n | The number of elements the current put pointer should be advanced. |
|
inlineprotected |
Returns a pointer to the buffer's current position. Throws no exceptions.
|
inlineprotected |
Sets the buffer's pointers. Throws no exceptions.
pbeg_arg | The value to be set in pbeg_ and pnext_ . |
pend_arg | The value to be set in pend_ . |
|
virtual |
Writes a single element to the stream.
value | The element to be written to the stream. |
|
virtual |
Writes an array of elements to the stream.
array | A pointer to the first element of the array. |
numElements | The number of elements to be written to the stream. |
Copyright © 2021 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |