DWFCore::DWFBufferOutputStream Class Reference

#include "dwfcore/BufferOutputStream.h"

Inheritance diagram for DWFCore::DWFBufferOutputStream:

Inheritance graph
[legend]
Collaboration diagram for DWFCore::DWFBufferOutputStream:

Collaboration graph
[legend]
List of all members.

Detailed Description

An output stream object that caches data and, depending on the configuration, writes it to another stream.

Since:
1.0.1
This implementation of the DWFOutputStream can be used to provide stream writing functionality for several different data sinks. This class can be used to accumulate bytes in a fixed or growable memory buffer or to underlying [chained] stream. Chaining streams can be useful for adjusting data flow (I/O buffering) and modifying data on the fly.
Examples:

Files/Files.cpp.

Definition at line 52 of file BufferOutputStream.h.

Public Member Functions

_DWFCORE_API DWFBufferOutputStream (size_t nInitialBufferBytes, off_t nMaxBufferBytes=-1) throw ()
_DWFCORE_API DWFBufferOutputStream (void *pBuffer, size_t nBufferBytes) throw ()
_DWFCORE_API DWFBufferOutputStream (DWFOutputStream *pOutputStream, bool bOwnStream, size_t nBufferBytes) throw ()
virtual _DWFCORE_API ~DWFBufferOutputStream () throw ()
virtual _DWFCORE_API void flush () throw ( DWFException )
virtual _DWFCORE_API size_t write (const void *pBuffer, size_t nBytesToWrite) throw ( DWFException )
virtual _DWFCORE_API size_t bytes () const throw ()
virtual _DWFCORE_API const
void * 
buffer () const throw ()
virtual _DWFCORE_API size_t buffer (void **ppBuffer) const throw ( DWFException )

Protected Attributes

void * _pBuffer
size_t _iBufferPos
size_t _nBufferBytes
size_t _nBufferBytesRemaining


Constructor & Destructor Documentation

_DWFCORE_API DWFCore::DWFBufferOutputStream::DWFBufferOutputStream size_t  nInitialBufferBytes,
off_t  nMaxBufferBytes = -1
throw ()
 

Constructor

Use this constructor to configure with an automatically resizing (and internally allocated) memory buffer.

Parameters:
nInitialBufferBytes Specifies the initial size of the internal buffer.
nMaxBufferBytes Specifics the maximum length to which the internal buffer will be allowed to grow. -1 indicates that no limit will be enforced.
Exceptions:
None 

_DWFCORE_API DWFCore::DWFBufferOutputStream::DWFBufferOutputStream void *  pBuffer,
size_t  nBufferBytes
throw ()
 

Constructor

Use this constructor to provide a caller-managed buffer.

Parameters:
pBuffer A pointer to a memory block into which the stream will write. Providing a NULL pointer to this constructor will generate to exceptions when the stream is used.
nBufferBytes The number of bytes in the memory block pBuffer.
Exceptions:
None 

_DWFCORE_API DWFCore::DWFBufferOutputStream::DWFBufferOutputStream DWFOutputStream pOutputStream,
bool  bOwnStream,
size_t  nBufferBytes
throw ()
 

Constructor

Use this constructor to provide another output stream as the data sink.

Parameters:
pOutputStream An output stream to which data will be written. This object should be allocated with the DWFCORE_ALLOC_OBJECT macro if ownership will be transferred.
bOwnStream If true, this object will assume ownership of pInputStream and delete it as necessary using DWFCORE_FREE_OBJECT. If false, the caller retains ownership of pInputStream and is responsible for deleting it.
nBufferBytes If non-zero, an internal buffer will be used to cache write() invocations. Once this buffer fills or flush() is invoked, the bytes will be written into the chained output stream.
Exceptions:
None 

virtual _DWFCORE_API DWFCore::DWFBufferOutputStream::~DWFBufferOutputStream  )  throw () [virtual]
 

Destructor

Exceptions:
None 


Member Function Documentation

virtual _DWFCORE_API size_t DWFCore::DWFBufferOutputStream::buffer void **  ppBuffer  )  const throw ( DWFException ) [virtual]
 

Makes a copy of the internal buffer, if one exists. The caller should release this buffer with the DWFCORE_FREE_MEMORY macro.

Parameters:
ppBuffer Receives allocated buffer.
Returns:
The number of bytes in the buffer.
Exceptions:
DWFException 

virtual _DWFCORE_API const void* DWFCore::DWFBufferOutputStream::buffer  )  const throw () [inline, virtual]
 

Returns a pointer to the internal buffer, if one exists. Depending on the configuration, this may be some or all of the bytes that were written to the stream. This pointer must not be deleted by the caller.

Returns:
A pointer to the buffer.
Exceptions:
None 

Definition at line 175 of file BufferOutputStream.h.

virtual _DWFCORE_API size_t DWFCore::DWFBufferOutputStream::bytes  )  const throw () [inline, virtual]
 

Returns the total number of bytes written to the stream. Depending on the configuration of this object this method can be used to determine the size of the memory block returned from buffer().

Returns:
The total bytes written to the stream.
Exceptions:
None 

Definition at line 159 of file BufferOutputStream.h.

virtual _DWFCORE_API void DWFCore::DWFBufferOutputStream::flush  )  throw ( DWFException ) [virtual]
 

Flushes any remaining bytes from the stream. This method only applies if an output stream is chained to this object.

Exceptions:
DWFException 

Implements DWFCore::DWFOutputStream.

Examples:
Files/Files.cpp.

virtual _DWFCORE_API size_t DWFCore::DWFBufferOutputStream::write const void *  pBuffer,
size_t  nBytesToWrite
throw ( DWFException ) [virtual]
 

Writes at most nBytesToWrite into the stream from the buffer provided. If this object has been configured with a chained stream and cache buffer, this method will first attempt to fill the cache before writing to the underlying stream.

Parameters:
pBuffer A pointer to a block of memory whose data will be written into the stream.
nBytesToWrite The number of bytes to copy from pBuffer.
Returns:
The number of bytes actually written.
Exceptions:
DWFException 

Implements DWFCore::DWFOutputStream.

Reimplemented in DWFCore::DWFXMLSerializer::XMLOutputStream.

Examples:
Files/Files.cpp.


The documentation for this class was generated from the following file:
Generated on Tue Jan 6 22:39:32 2009 for Autodesk DWF Core Library by  doxygen 1.4.5