view src/win32/7zip/7z/CPP/7zip/Common/StreamObjects.h @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line source
1 // StreamObjects.h
3 #ifndef __STREAMOBJECTS_H
4 #define __STREAMOBJECTS_H
6 #include "../../Common/DynamicBuffer.h"
7 #include "../../Common/MyCom.h"
8 #include "../IStream.h"
10 class CSequentialInStreamImp:
11 public ISequentialInStream,
12 public CMyUnknownImp
13 {
14 const Byte *_dataPointer;
15 size_t _size;
16 size_t _pos;
18 public:
19 void Init(const Byte *dataPointer, size_t size)
20 {
21 _dataPointer = dataPointer;
22 _size = size;
23 _pos = 0;
24 }
26 MY_UNKNOWN_IMP
28 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
29 };
32 class CWriteBuffer
33 {
34 CByteDynamicBuffer _buffer;
35 size_t _size;
36 public:
37 CWriteBuffer(): _size(0) {}
38 void Init() { _size = 0; }
39 void Write(const void *data, size_t size);
40 size_t GetSize() const { return _size; }
41 const CByteDynamicBuffer& GetBuffer() const { return _buffer; }
42 };
44 class CSequentialOutStreamImp:
45 public ISequentialOutStream,
46 public CMyUnknownImp
47 {
48 CWriteBuffer _writeBuffer;
49 public:
50 void Init() { _writeBuffer.Init(); }
51 size_t GetSize() const { return _writeBuffer.GetSize(); }
52 const CByteDynamicBuffer& GetBuffer() const { return _writeBuffer.GetBuffer(); }
54 MY_UNKNOWN_IMP
56 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
57 };
59 class CSequentialOutStreamImp2:
60 public ISequentialOutStream,
61 public CMyUnknownImp
62 {
63 Byte *_buffer;
64 size_t _size;
65 size_t _pos;
66 public:
68 void Init(Byte *buffer, size_t size)
69 {
70 _buffer = buffer;
71 _pos = 0;
72 _size = size;
73 }
75 size_t GetPos() const { return _pos; }
77 MY_UNKNOWN_IMP
79 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
80 };
82 class CSequentialInStreamSizeCount:
83 public ISequentialInStream,
84 public CMyUnknownImp
85 {
86 CMyComPtr<ISequentialInStream> _stream;
87 UInt64 _size;
88 public:
89 void Init(ISequentialInStream *stream)
90 {
91 _stream = stream;
92 _size = 0;
93 }
94 UInt64 GetSize() const { return _size; }
96 MY_UNKNOWN_IMP
98 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
99 };
101 class CSequentialOutStreamSizeCount:
102 public ISequentialOutStream,
103 public CMyUnknownImp
104 {
105 CMyComPtr<ISequentialOutStream> _stream;
106 UInt64 _size;
107 public:
108 void SetStream(ISequentialOutStream *stream) { _stream = stream; }
109 void Init() { _size = 0; }
110 UInt64 GetSize() const { return _size; }
112 MY_UNKNOWN_IMP
114 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
115 };
117 #endif