#include <cel_stream.h>

Public Member Functions | |
| size_t | getNumOfBytesRead () const |
| size_t | getNumOfBytesWritten () const |
| void | resetByteRead () |
| void | resetByteWritten () |
| virtual size_t | readBytes (void *buffer, size_t inSize, bool wouldBlock=false) |
| virtual void | writeBytes (const void *buffer, size_t inSize) |
| virtual void | flushBuffer () |
| virtual bool | isEof () const |
| virtual void | lock () const |
| virtual void | unlock () const |
Static Public Member Functions | |
| static AutoPtr< ByteCounterStream > | create (Stream *inStream) |
This stream class counts the number of bytes read from and written to a stream.
| static AutoPtr<ByteCounterStream> Celartem::ByteCounterStream::create | ( | Stream * | inStream | ) | [inline, static] |
This method creates an instance of CounterStream class.
| inStream | Base stream. The actual operation will be done on the stream. |
| virtual void Celartem::ByteCounterStream::flushBuffer | ( | ) | [inline, virtual] |
flushBuffer is provided for the purpose of flushing buffered stream.
Implements Celartem::Stream.
| size_t Celartem::ByteCounterStream::getNumOfBytesRead | ( | ) | const [inline] |
This method returns the number of bytes read from the stream.
| size_t Celartem::ByteCounterStream::getNumOfBytesWritten | ( | ) | const [inline] |
This method returns the number of bytes write to the stream.
| virtual bool Celartem::ByteCounterStream::isEof | ( | ) | const [inline, virtual] |
isEof return true if the stream pointer has already reached the end of stream; you should not rely on readBytes to determine the end of stream.
true if the file pointer reachs EOF, otherwise false. Implements Celartem::Stream.
| virtual void Celartem::ByteCounterStream::lock | ( | ) | const [inline, virtual] |
The actual meanings of this method is defined in the derived class.
Implements Celartem::Lockable.
| virtual size_t Celartem::ByteCounterStream::readBytes | ( | void * | buffer, | |
| size_t | inSize, | |||
| bool | wouldBlock = false | |||
| ) | [inline, virtual] |
readBytes tries to read bytes from the stream. If wouldBlock is false, readBytes reads the data currenly available and returned immediately; the returned value indicates the bytes actually read and it is no more than inSize. If wouldBlock is true, it blocks until it reads all the bytes specified by inSize parameter. If the stream is potentially read-only and it seems there're no chance to read the bytes specified by inSize, it throws some exception. In the case it throws some exception, the contents in the buffer is invalid and the position of stream pointer is not defined; they are implementation specific.
| buffer | Pointer to a buffer that receives the data. | |
| inSize | Maximum size to read; readBytes reads data no more than the number of bytes specified by inSize. | |
| wouldBlock | It specifies it blocks until all bytes comes or not. |
Implements Celartem::Stream.
| void Celartem::ByteCounterStream::resetByteRead | ( | ) | [inline] |
This method resets the number of bytes read to 0.
| void Celartem::ByteCounterStream::resetByteWritten | ( | ) | [inline] |
This method resets the number of bytes written to 0.
| virtual void Celartem::ByteCounterStream::unlock | ( | ) | const [inline, virtual] |
The actual meanings of this method is defined in the derived class.
Implements Celartem::Lockable.
| virtual void Celartem::ByteCounterStream::writeBytes | ( | const void * | buffer, | |
| size_t | inSize | |||
| ) | [inline, virtual] |
writeBytes tries to write the data to the stream. If it could not write all the bytes specified by inSize, it throws some exception, which describes the status. In the case it throws some exception, the position of stream pointer is not defined; it is implementation specific.
| buffer | Pointer to the buffer that holds the data to be sent. | |
| inSize | the number of bytes to be sent. |
Implements Celartem::Stream.