ZStreamR_Count Class Reference

A read filter stream that counts the number of bytes read from it. More...

#include <ZStream_Count.h>

Inheritance diagram for ZStreamR_Count:

ZStreamR List of all members.

Public Member Functions

 ZStreamR_Count (const ZStreamR &iStreamSource)
virtual size_t Imp_CountReadable ()
 Returns the number of bytes guaranteed to be readable without blocking.
virtual void Imp_CopyToDispatch (const ZStreamW &iStreamW, uint64 iCount, uint64 *oCountRead, uint64 *oCountWritten)
 Invoke iStreamW's Imp_CopyFrom method.
virtual void Imp_CopyTo (const ZStreamW &iStreamW, uint64 iCount, uint64 *oCountRead, uint64 *oCountWritten)
 Actually copy data from this stream to iStreamW.
virtual void Imp_Skip (uint64 iCount, uint64 *oCountSkipped)
 Read and discard iCount bytes.
uint64 GetCount ()
 Returns the number of bytes read since construction or the last call to ZeroCount.
void ZeroCount ()
 Resets our counter back to zero.

Detailed Description

A read filter stream that counts the number of bytes read from it.

Every read is satisfied by calling through to the real stream, and the number of bytes succesfully read is accumulated. Call GetCount to find how many bytes have been read. Call ZeroCount to reset that count.

Note:
GetCount returns the number of bytes that have been read by calling Read/Skip/CopyTo against the ZStreamR_Count itself. It obviously has no way of knowing how many bytes have been read from the referenced real stream.


Constructor & Destructor Documentation

ZStreamR_Count::ZStreamR_Count ( const ZStreamR iStreamSource  ) 

Parameters:
iStreamSource The stream from which data is to be read.


Member Function Documentation

size_t ZStreamR_Count::Imp_CountReadable (  )  [virtual]

Returns the number of bytes guaranteed to be readable without blocking.

If the stream does not or cannot know this information it should return zero. A zero return thus does not mean no data is available, simply that a subsequent Read or Skip may block indefinitely.

Reimplemented from ZStreamR.

void ZStreamR_Count::Imp_CopyToDispatch ( const ZStreamW iStreamW,
uint64  iCount,
uint64 oCountRead,
uint64 oCountWritten 
) [virtual]

Invoke iStreamW's Imp_CopyFrom method.

The first part of the two-stage dispatch initiated by ZStreamR::CopyTo and ZStreamR::CopyAllTo. Override this method if your stream's data is in memory and thus can be written to iStreamW by a single call to its Write method.

Reimplemented from ZStreamR.

void ZStreamR_Count::Imp_CopyTo ( const ZStreamW iStreamW,
uint64  iCount,
uint64 oCountRead,
uint64 oCountWritten 
) [virtual]

Actually copy data from this stream to iStreamW.

The second part of the two-stage dispatch initiated by ZStreamW::CopyFrom and ZStreamW::CopyAllFrom. The default implementation calls sCopyReadToWrite. Override this method if your stream's data is in memory and thus can be written to iStreamW by a single call to its Write method.

See also:
sCopyReadToWrite

Reimplemented from ZStreamR.

void ZStreamR_Count::Imp_Skip ( uint64  iCount,
uint64 oCountSkipped 
) [virtual]

Read and discard iCount bytes.

Override this method if your stream implementation can skip past bytes in the stream without actually reading them.

Parameters:
iCount Count of bytes to be skipped.
oCountSkipped Number of bytes that were actually skipped. If iCount is non zero and oCountSkipped is set to zero then this indicates that the stream has reached its end.

Reimplemented from ZStreamR.


The documentation for this class was generated from the following files:
Generated on Thu Jul 26 11:22:02 2007 for ZooLib by  doxygen 1.4.7