Cross-Platform C++

ot::io
class FilterOutputStream

#include "ot/io/FilterOutputStream.h"

ot::io::OutputStream ot::ManagedObject ot::io::DataOutputStream A base class that derives from OutputStream but also contains another OutputStream which is used as the output sink. FilterOutputStream and its sister class FilterInputStream provide an extensible framework for building chains of processing.

The FilterOutputStream class overrides all methods of OutputStream with versions that pass requests to the contained output stream. Derived classes of FilterOutputStream are expected to further override some of these methods to perform some useful function before the data is written out to the sink (which may be yet another FilterOutputStream).

If a write() method is overridden by a derived class, it is usually necessary for both of the write() methods to be overridden. This is necessary to avoid the situation where the non-overridden write() is passed directly to the contained input stream and, in doing so, bypasses the logic contained in the derived class.

When a FilterOutputStream is destroyed, the reference to the contained OutputStream is released, but the latter is not automatically closed. However, if nothing else holds a reference to the contained OutputStream, it's reference count will be decremented to zero which will cause to to close.




Constructor/Destructor Summary
FilterOutputStream(OutputStream* pOutputStream)
         Constructs a FilterOutputStream using pOutputStream as the contained output stream.

Method Summary
 virtual void close()
         Closes the output stream and releases system resources associated with the stream.
 virtual void flush()
         Forces all buffered data to be written out and sent to the final data sink.
 virtual void flushBuffers()
         Forces all OpenTop data buffers associated with this output stream to be written out.
protected  RefPtr< OutputStream > getOutputStream() const
         Returns the contained output stream.
protected  void setOutputStream(OutputStream* pOutputStream)
         Replaces the contained OutputStream with another, or null.
 virtual void write(Byte x)
         Writes the single byte x to this output stream.
 virtual void write(const Byte* pBuffer, size_t bufLen)
         Writes an array of bytes to this output stream.

Methods inherited from class ot::ManagedObject
addRef(), getRefCount(), onFinalRelease(), operator=(const ManagedObject&), release()

Constructor/Destructor Detail

FilterOutputStream

 FilterOutputStream(OutputStream* pOutputStream)
Constructs a FilterOutputStream using pOutputStream as the contained output stream.

Exceptions:
NullPointerException - if pOutputStream is null.

Method Detail

close

virtual void close()
Closes the output stream and releases system resources associated with the stream. Once an OutputStream is closed further calls to write(), flush() or flushBuffers() will result in an IOException being thrown. Further calls to close() are legal but have no effect.

Exceptions:
IOException - if an I/O error occurs.

flush

virtual void flush()
Forces all buffered data to be written out and sent to the final data sink.

Exceptions:
IOException - if an I/O error occurs.
See also:
flushBuffers()

flushBuffers

virtual void flushBuffers()
Forces all OpenTop data buffers associated with this output stream to be written out. This may not cause the data to be sent to the final sink if the underlying sink maintains its own buffering scheme.

Exceptions:
IOException - if an I/O error occurs.
See also:
flush()

getOutputStream

protected RefPtr< OutputStreamgetOutputStream() const
Returns the contained output stream.


setOutputStream

protected void setOutputStream(OutputStream* pOutputStream)
Replaces the contained OutputStream with another, or null.

Parameters:
pOutputStream - the OutputStream to be used as the new contained OutputStream for this FilterOutputStream. The value of pOutputStream may be null, in which case all further operations on this FilterOutputStream will behave as if the stream is closed.
Since:
OpenTop 1.4

write

virtual void write(Byte x)
Writes the single byte x to this output stream.

Parameters:
x - the byte to write
Exceptions:
IOException - if an I/O error occurs.

write

virtual void write(const Byte* pBuffer,
                   size_t bufLen)
Writes an array of bytes to this output stream.

Parameters:
pBuffer - pointer to the start of an array of bytes to be written
bufLen - length of the byte array
Exceptions:
NullPointerException - if pBuffer is null.
IOException - if an I/O error occurs.


Cross-Platform C++

Found a bug or missing feature? Please email us at support@elcel.com

Copyright © 2000-2005 ElCel Technology   Trademark Acknowledgements