source: box/trunk/lib/common/CollectInBufferStream.h @ 217

Revision 217, 1.5 KB checked in by martin, 6 years ago (diff)

Set svn:eol-style as appropriate for all files

  • Property svn:eol-style set to native
Line 
1// --------------------------------------------------------------------------
2//
3// File
4//              Name:    CollectInBufferStream.h
5//              Purpose: Collect data in a buffer, and then read it out.
6//              Created: 2003/08/26
7//
8// --------------------------------------------------------------------------
9
10#ifndef COLLECTINBUFFERSTREAM__H
11#define COLLECTINBUFFERSTREAM__H
12
13#include "IOStream.h"
14#include "Guards.h"
15
16// --------------------------------------------------------------------------
17//
18// Class
19//              Name:    CollectInBufferStream
20//              Purpose: Collect data in a buffer, and then read it out.
21//              Created: 2003/08/26
22//
23// --------------------------------------------------------------------------
24class CollectInBufferStream : public IOStream
25{
26public:
27        CollectInBufferStream();
28        ~CollectInBufferStream();
29private:
30        // No copying
31        CollectInBufferStream(const CollectInBufferStream &);
32        CollectInBufferStream(const IOStream &);
33public:
34
35        virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite);
36        virtual pos_type BytesLeftToRead();
37        virtual void Write(const void *pBuffer, int NBytes);
38        virtual pos_type GetPosition() const;
39        virtual void Seek(pos_type Offset, int SeekType);
40        virtual bool StreamDataLeft();
41        virtual bool StreamClosed();
42
43        void SetForReading();
44       
45        void Reset();
46       
47        void *GetBuffer() const;
48        int GetSize() const;
49        bool IsSetForReading() const {return !mInWritePhase;}
50
51private:
52        MemoryBlockGuard<char*> mBuffer;
53        int mBufferSize;
54        int mBytesInBuffer;
55        int mReadPosition;
56        bool mInWritePhase;
57};
58
59#endif // COLLECTINBUFFERSTREAM__H
60
Note: See TracBrowser for help on using the repository browser.