DWFCore::DWFDigestOutputStream Class Reference

#include "dwfcore/DigestOutputStream.h"

Inheritance diagram for DWFCore::DWFDigestOutputStream:

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

Collaboration graph
[legend]
List of all members.

Detailed Description

The interface for an output stream object that computes a digest for a complete sequence of bytes written.

Since:
1.2
Implementations of this can be used to determine a digest (MD5, SHA-1, SHA256, etc.) for the complete sequence of bytes that are written to another linked [chained] output stream. The bytes essentially pass through this implementation for digest computation.
Examples:

Digest/main.cpp.

Definition at line 48 of file DigestOutputStream.h.

Public Member Functions

_DWFCORE_API DWFDigestOutputStream () throw ()
_DWFCORE_API DWFDigestOutputStream (DWFDigest *pDigest, DWFOutputStream *pOutputStream, bool bOwnStream) throw ()
virtual _DWFCORE_API ~DWFDigestOutputStream () throw ()
_DWFCORE_API void setDigest (DWFDigest *pDigest) throw ()
virtual _DWFCORE_API void chainOutputStream (DWFOutputStream *pOutputStream, bool bOwnStream) throw ()
virtual _DWFCORE_API bool isDigestProgressive () throw ( DWFException )
virtual _DWFCORE_API DWFString digest () throw ( DWFException )
virtual _DWFCORE_API size_t digestRawBytes (unsigned char *&rpBytes) throw ( DWFException )
virtual _DWFCORE_API DWFString digestBase64 () throw ( DWFException )
virtual _DWFCORE_API void flush () throw ( DWFException )
virtual _DWFCORE_API size_t write (const void *pBuffer, size_t nBytesToWrite) throw ( DWFException )


Constructor & Destructor Documentation

_DWFCORE_API DWFCore::DWFDigestOutputStream::DWFDigestOutputStream  )  throw ()
 

Constructor. If the default constructor is used, then the user must set the digest and the output stream using setDigest and chainOutputStream respectively, otherwise an exception will be thrown.

_DWFCORE_API DWFCore::DWFDigestOutputStream::DWFDigestOutputStream DWFDigest pDigest,
DWFOutputStream pOutputStream,
bool  bOwnStream
throw ()
 

Constructor. If either the digest or the output stream is NULL, then it must be set using setDigest or chainOutputStream respectively.

Parameters:
pDigest A pointer to the digest object that will be used to determine the digest of the stream data. This digest stream will take ownership of the digest. The digest should be allocated with the DWFCORE_ALLOC_OBJECT macro.
pOutputStream A pointer to a stream to chain to this object. If this pointer is NULL and another stream was previously chained to this object, it will be cleared (and deleted if owned.) 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 pOutputStream and delete it as necessary using DWFCORE_FREE_OBJECT. If false, the caller retains ownership of pInputStream and is responsible for deleting it.
Exceptions:
None 

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

Destructor


Member Function Documentation

virtual _DWFCORE_API void DWFCore::DWFDigestOutputStream::chainOutputStream DWFOutputStream pOutputStream,
bool  bOwnStream
throw () [virtual]
 

Attaches (or detaches) another output stream to this object. Chaining simply refers to the process of using one stream as the source for another. Any number of these objects can be chained together to add functionality and data modification in a single write() invocation.

Parameters:
pOutputStream A pointer to a stream to chain to this object. If this pointer is NULL and another stream was previously chained to this object, it will be cleared (and deleted if owned.) 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 pOutputStream and delete it as necessary using DWFCORE_FREE_OBJECT. If false, the caller retains ownership of pOutputStream and is responsible for deleting it.
Exceptions:
None 
Examples:
Digest/main.cpp.

virtual _DWFCORE_API DWFString DWFCore::DWFDigestOutputStream::digest  )  throw ( DWFException ) [virtual]
 

Return the digest computed on the bytes written. If the digest being used is not progressive, this should not be called until all bytes have been written. If no output stream has been linked, this will throw a DWFIllegalStateException.

Returns:
The digest. The length depends on the algorithm used.
Exceptions:
DWFException 

virtual _DWFCORE_API DWFString DWFCore::DWFDigestOutputStream::digestBase64  )  throw ( DWFException ) [virtual]
 

Return the digest computed on the bytes written, in base 64 encoding. If no output stream has been linked, this will throw a DWFIllegalStateException.

Returns:
The digest in base 64 encoding. The length depends on the algorithm used.
Exceptions:
DWFException 

virtual _DWFCORE_API size_t DWFCore::DWFDigestOutputStream::digestRawBytes unsigned char *&  rpBytes  )  throw ( DWFException ) [virtual]
 

Return the digest computed on the bytes written, in terms of the raw digest bytes. The bytes are return in a array of unsigned characters that must be deleted by the caller using DWFCORE_FREE_MEMORY(). If no output stream has been linked, this will throw a DWFIllegalStateException.

Parameters:
rpBytes The array of bytes will be allocated and returned via this pointer. It should be initialized to NULL before calling this.
Returns:
The size of the character array holding the raw bytes of the digest. The length depends on the algorithm used.
Exceptions:
DWFException 

virtual _DWFCORE_API void DWFCore::DWFDigestOutputStream::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.

virtual _DWFCORE_API bool DWFCore::DWFDigestOutputStream::isDigestProgressive  )  throw ( DWFException ) [virtual]
 

This returns whether or not the underlying digest is progressive, that is, the digest can be returned on the number of bytes streamed so far, and still be updated. If a digest is not progressive, digest() should be called only after all bytes have been streamed through the digest stream.

Returns:
True if the digest supports digest() calls while bytes are being streamed.
Exceptions:
DWFException 

_DWFCORE_API void DWFCore::DWFDigestOutputStream::setDigest DWFDigest pDigest  )  throw ()
 

Set the digest object to use to evaluate the digest of the streamed data. Any This will delete any digest that the digest stream may already own.

Parameters:
pDigest A pointer to the digest object that will be used to determine the digest of the stream data. This digest stream will take ownership of the new digest which should be allocated with the DWFCORE_ALLOC_OBJECT macro.
Exceptions:
DWFException 

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

Writes at most nBytesToWrite to the chained stream from the buffer provided. The underlying digest computation will be updated in the process. If no output stream has been linked, this will throw a DWFIllegalStateException.

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.

Examples:
Digest/main.cpp.


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