Public Member Functions | List of all members
Celartem::ChecksumStream Class Referenceabstract

#include <cel_checksum.h>

Inheritance diagram for Celartem::ChecksumStream:
Inheritance graph
[legend]

Public Member Functions

virtual void writeSum (Stream *inStream=NULL)=0
 
virtual bool verifySum (Stream *inStream=NULL)=0
 
virtual void resetSum ()=0
 
virtual const u8getCurrentSum ()=0
 
virtual size_t getSumSize () const =0
 
- Public Member Functions inherited from Celartem::Stream
virtual size_t readBytes (void *buffer, size_t inSize, bool wouldBlock=false)=0
 
virtual void writeBytes (const void *buffer, size_t inSize)=0
 
virtual void flushBuffer ()=0
 
virtual bool isEof () const =0
 
virtual size_t duplicateStream (Stream *inStream, size_t inBufferSize=1024, DuplicateStreamCallback inCallback=NULL, void *inCallbackContext=NULL)
 
virtual size_t duplicateStreamBytes (Stream *inStream, size_t inMaximumByteSize, size_t inBufferSize=1024, DuplicateStreamCallback inCallback=NULL, void *inCallbackContext=NULL)
 
- Public Member Functions inherited from Celartem::Referable
 Referable ()
 
void addRef () const
 
void releaseRef () const
 
size_t getReferenceCount () const
 
- Public Member Functions inherited from Celartem::Lockable
virtual void lock () const =0
 
virtual void unlock () const =0
 

Additional Inherited Members

- Static Public Member Functions inherited from Celartem::Referable
static void dumpDbgAllRefCount ()
 

Detailed Description

This class calculates the sum of the data that is "read from" or "write to" this stream.

// Writer sample
void writeData(Stream *inStream)
{
AutoPtr<MD5Stream> md5 = MD5Stream::create(inStream);
// write data as if it were the original stream.
md5->writeBytes(...);
md5->writeBytes(...);
md5->writeBytes(...);
// save the current MD5 sum
md5->writeSum();
}
// Reader sample
void readData(Stream *inStream)
{
AutoPtr<MD5Stream> md5 = MD5Stream::create(inStream);
// read the data as if it were the original stream.
// This should read the bytes exactly identical to the ones
// written by writeData function, otherwise the verifySum
// fails.
md5->readBytes(...);
md5->readBytes(...);
md5->readBytes(...);
// verify the current MD5 sum
if(md5->verifySum())
{
// The sum is identical
}
else
{
// The sum is not identical
}
}

ChecksumStream defines an interface for the Stream with Checksum feature.

See Also
MD5Stream, SHA1Stream, SHA256Stream, Checksum

Member Function Documentation

virtual const u8* Celartem::ChecksumStream::getCurrentSum ( )
pure virtual

This method gets the current sum as the binary block.

Returns
Pointer that points the binary block. This pointer is valid until the next call to the method of the instance. The size of that block is obtained by getSumSize method.
virtual size_t Celartem::ChecksumStream::getSumSize ( ) const
pure virtual

This method gets the size of sums in bytes that is generated by the instance. The size of sum is usually a constant; MD5 uses 16, SHA-1 uses 20.

Returns
The size of sums.
virtual void Celartem::ChecksumStream::resetSum ( )
pure virtual

This method resets the current sum and revert to the initial state.

virtual bool Celartem::ChecksumStream::verifySum ( Stream inStream = NULL)
pure virtual

This method verifies the sum which is read from the specified stream.

Parameters
inStreamA stream to read from. NULL to read from this stream.
Returns
true if the sum read from the specified stream is match to the one of current sum, otherwise false.
virtual void Celartem::ChecksumStream::writeSum ( Stream inStream = NULL)
pure virtual

This method writes the sum to the specified stream.

Parameters
inStreamA stream to write. NULL to write on this stream.

The documentation for this class was generated from the following file:

Cuminas DjVu SDK 3.0.33103
This document is made with doxygen 1.8.5 at Sun Dec 15 2013 19:38:06.
Cuminas Logo