Mercurial > vba-clojure
comparison src/win32/7zip/7z/CPP/7zip/Common/LimitedStreams.h @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:8ced16adf2e1 | 1:f9f4f1b99eed |
---|---|
1 // LimitedStreams.h | |
2 | |
3 #ifndef __LIMITEDSTREAMS_H | |
4 #define __LIMITEDSTREAMS_H | |
5 | |
6 #include "../../Common/MyCom.h" | |
7 #include "../IStream.h" | |
8 | |
9 class CLimitedSequentialInStream: | |
10 public ISequentialInStream, | |
11 public CMyUnknownImp | |
12 { | |
13 CMyComPtr<ISequentialInStream> _stream; | |
14 UInt64 _size; | |
15 UInt64 _pos; | |
16 bool _wasFinished; | |
17 public: | |
18 void SetStream(ISequentialInStream *stream) { _stream = stream; } | |
19 void Init(UInt64 streamSize) | |
20 { | |
21 _size = streamSize; | |
22 _pos = 0; | |
23 _wasFinished = false; | |
24 } | |
25 | |
26 MY_UNKNOWN_IMP | |
27 | |
28 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); | |
29 UInt64 GetSize() const { return _pos; } | |
30 bool WasFinished() const { return _wasFinished; } | |
31 }; | |
32 | |
33 class CLimitedSequentialOutStream: | |
34 public ISequentialOutStream, | |
35 public CMyUnknownImp | |
36 { | |
37 CMyComPtr<ISequentialOutStream> _stream; | |
38 UInt64 _size; | |
39 bool _overflow; | |
40 public: | |
41 MY_UNKNOWN_IMP | |
42 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); | |
43 void SetStream(ISequentialOutStream *stream) { _stream = stream; } | |
44 void ReleaseStream() { _stream.Release(); } | |
45 void Init(UInt64 size) | |
46 { | |
47 _size = size; | |
48 _overflow = false; | |
49 } | |
50 bool IsFinishedOK() const { return (_size == 0 && !_overflow); } | |
51 UInt64 GetRem() const { return _size; } | |
52 }; | |
53 | |
54 #endif |