| 1 | // -------------------------------------------------------------------------- |
|---|
| 2 | // |
|---|
| 3 | // File |
|---|
| 4 | // Name: MemBlockStream.h |
|---|
| 5 | // Purpose: Stream out data from any memory block |
|---|
| 6 | // Created: 2003/09/05 |
|---|
| 7 | // |
|---|
| 8 | // -------------------------------------------------------------------------- |
|---|
| 9 | |
|---|
| 10 | #ifndef MEMBLOCKSTREAM__H |
|---|
| 11 | #define MEMBLOCKSTREAM__H |
|---|
| 12 | |
|---|
| 13 | #include "IOStream.h" |
|---|
| 14 | |
|---|
| 15 | class StreamableMemBlock; |
|---|
| 16 | class CollectInBufferStream; |
|---|
| 17 | |
|---|
| 18 | // -------------------------------------------------------------------------- |
|---|
| 19 | // |
|---|
| 20 | // Class |
|---|
| 21 | // Name: MemBlockStream |
|---|
| 22 | // Purpose: Stream out data from any memory block -- be careful the lifetime |
|---|
| 23 | // of the block is greater than the lifetime of this stream. |
|---|
| 24 | // Created: 2003/09/05 |
|---|
| 25 | // |
|---|
| 26 | // -------------------------------------------------------------------------- |
|---|
| 27 | class MemBlockStream : public IOStream |
|---|
| 28 | { |
|---|
| 29 | public: |
|---|
| 30 | MemBlockStream(const void *pBuffer, int Size); |
|---|
| 31 | MemBlockStream(const StreamableMemBlock &rBlock); |
|---|
| 32 | MemBlockStream(const CollectInBufferStream &rBuffer); |
|---|
| 33 | MemBlockStream(const MemBlockStream &rToCopy); |
|---|
| 34 | ~MemBlockStream(); |
|---|
| 35 | public: |
|---|
| 36 | |
|---|
| 37 | virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite); |
|---|
| 38 | virtual pos_type BytesLeftToRead(); |
|---|
| 39 | virtual void Write(const void *pBuffer, int NBytes); |
|---|
| 40 | virtual pos_type GetPosition() const; |
|---|
| 41 | virtual void Seek(pos_type Offset, int SeekType); |
|---|
| 42 | virtual bool StreamDataLeft(); |
|---|
| 43 | virtual bool StreamClosed(); |
|---|
| 44 | |
|---|
| 45 | private: |
|---|
| 46 | const char *mpBuffer; |
|---|
| 47 | int mBytesInBuffer; |
|---|
| 48 | int mReadPosition; |
|---|
| 49 | }; |
|---|
| 50 | |
|---|
| 51 | #endif // MEMBLOCKSTREAM__H |
|---|
| 52 | |
|---|