Imported Upstream version 9.20
[platform/upstream/7zip.git] / CPP / 7zip / IStream.h
1 // IStream.h\r
2 \r
3 #ifndef __ISTREAM_H\r
4 #define __ISTREAM_H\r
5 \r
6 #include "../Common/MyUnknown.h"\r
7 #include "../Common/Types.h"\r
8 \r
9 #include "IDecl.h"\r
10 \r
11 #define STREAM_INTERFACE_SUB(i, base, x) DECL_INTERFACE_SUB(i, base, 3, x)\r
12 #define STREAM_INTERFACE(i, x) STREAM_INTERFACE_SUB(i, IUnknown, x)\r
13 \r
14 STREAM_INTERFACE(ISequentialInStream, 0x01)\r
15 {\r
16   STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) PURE;\r
17   /*\r
18   Out: if size != 0, return_value = S_OK and (*processedSize == 0),\r
19     then there are no more bytes in stream.\r
20   if (size > 0) && there are bytes in stream,\r
21   this function must read at least 1 byte.\r
22   This function is allowed to read less than number of remaining bytes in stream.\r
23   You must call Read function in loop, if you need exact amount of data\r
24   */\r
25 };\r
26 \r
27 STREAM_INTERFACE(ISequentialOutStream, 0x02)\r
28 {\r
29   STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize) PURE;\r
30   /*\r
31   if (size > 0) this function must write at least 1 byte.\r
32   This function is allowed to write less than "size".\r
33   You must call Write function in loop, if you need to write exact amount of data\r
34   */\r
35 };\r
36 \r
37 STREAM_INTERFACE_SUB(IInStream, ISequentialInStream, 0x03)\r
38 {\r
39   STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE;\r
40 };\r
41 \r
42 STREAM_INTERFACE_SUB(IOutStream, ISequentialOutStream, 0x04)\r
43 {\r
44   STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE;\r
45   STDMETHOD(SetSize)(UInt64 newSize) PURE;\r
46 };\r
47 \r
48 STREAM_INTERFACE(IStreamGetSize, 0x06)\r
49 {\r
50   STDMETHOD(GetSize)(UInt64 *size) PURE;\r
51 };\r
52 \r
53 STREAM_INTERFACE(IOutStreamFlush, 0x07)\r
54 {\r
55   STDMETHOD(Flush)() PURE;\r
56 };\r
57 \r
58 #endif\r