source: box/trunk/lib/common/IOStream.h @ 2439

Revision 2439, 2.0 KB checked in by chris, 3 years ago (diff)

Remove definitions of unwanted copy constructor and assignment operator,
to avoid accidentally calling them.

  • Property svn:eol-style set to native
Line 
1// --------------------------------------------------------------------------
2//
3// File
4//              Name:    IOStream.h
5//              Purpose: I/O Stream abstraction
6//              Created: 2003/07/31
7//
8// --------------------------------------------------------------------------
9
10#ifndef IOSTREAM__H
11#define IOSTREAM__H
12
13// --------------------------------------------------------------------------
14//
15// Class
16//              Name:    IOStream
17//              Purpose: Abstract interface to streams of data
18//              Created: 2003/07/31
19//
20// --------------------------------------------------------------------------
21class IOStream
22{
23public:
24        IOStream();
25        virtual ~IOStream();
26
27private:
28        IOStream(const IOStream &rToCopy); /* forbidden */
29        IOStream& operator=(const IOStream &rToCopy); /* forbidden */
30               
31public:
32        enum
33        {
34                TimeOutInfinite = -1,
35                SizeOfStreamUnknown = -1
36        };
37       
38        enum
39        {
40                SeekType_Absolute = 0,
41                SeekType_Relative = 1,
42                SeekType_End = 2
43        };
44       
45        // Timeout in milliseconds
46        // Read may return 0 -- does not mean end of stream.
47        typedef int64_t pos_type;
48        virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite) = 0;
49        virtual pos_type BytesLeftToRead();     // may return IOStream::SizeOfStreamUnknown (and will for most stream types)
50        virtual void Write(const void *pBuffer, int NBytes) = 0;
51        virtual void Write(const char *pBuffer);
52        virtual void WriteAllBuffered();
53        virtual pos_type GetPosition() const;
54        virtual void Seek(pos_type Offset, int SeekType);
55        virtual void Close();
56       
57        // Has all data that can be read been read?
58        virtual bool StreamDataLeft() = 0;
59        // Has the stream been closed (writing not possible)
60        virtual bool StreamClosed() = 0;
61       
62        // Utility functions
63        bool ReadFullBuffer(void *pBuffer, int NBytes, int *pNBytesRead, int Timeout = IOStream::TimeOutInfinite);
64        bool CopyStreamTo(IOStream &rCopyTo, int Timeout = IOStream::TimeOutInfinite, int BufferSize = 1024);
65        void Flush(int Timeout = IOStream::TimeOutInfinite);
66       
67        static int ConvertSeekTypeToOSWhence(int SeekType);
68};
69
70
71#endif // IOSTREAM__H
72
73
Note: See TracBrowser for help on using the repository browser.