Mercurial > vba-linux
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/win32/7zip/7z/CPP/7zip/Common/StreamObjects.h Sat Mar 03 10:31:27 2012 -0600 1.3 @@ -0,0 +1,117 @@ 1.4 +// StreamObjects.h 1.5 + 1.6 +#ifndef __STREAMOBJECTS_H 1.7 +#define __STREAMOBJECTS_H 1.8 + 1.9 +#include "../../Common/DynamicBuffer.h" 1.10 +#include "../../Common/MyCom.h" 1.11 +#include "../IStream.h" 1.12 + 1.13 +class CSequentialInStreamImp: 1.14 + public ISequentialInStream, 1.15 + public CMyUnknownImp 1.16 +{ 1.17 + const Byte *_dataPointer; 1.18 + size_t _size; 1.19 + size_t _pos; 1.20 + 1.21 +public: 1.22 + void Init(const Byte *dataPointer, size_t size) 1.23 + { 1.24 + _dataPointer = dataPointer; 1.25 + _size = size; 1.26 + _pos = 0; 1.27 + } 1.28 + 1.29 + MY_UNKNOWN_IMP 1.30 + 1.31 + STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); 1.32 +}; 1.33 + 1.34 + 1.35 +class CWriteBuffer 1.36 +{ 1.37 + CByteDynamicBuffer _buffer; 1.38 + size_t _size; 1.39 +public: 1.40 + CWriteBuffer(): _size(0) {} 1.41 + void Init() { _size = 0; } 1.42 + void Write(const void *data, size_t size); 1.43 + size_t GetSize() const { return _size; } 1.44 + const CByteDynamicBuffer& GetBuffer() const { return _buffer; } 1.45 +}; 1.46 + 1.47 +class CSequentialOutStreamImp: 1.48 + public ISequentialOutStream, 1.49 + public CMyUnknownImp 1.50 +{ 1.51 + CWriteBuffer _writeBuffer; 1.52 +public: 1.53 + void Init() { _writeBuffer.Init(); } 1.54 + size_t GetSize() const { return _writeBuffer.GetSize(); } 1.55 + const CByteDynamicBuffer& GetBuffer() const { return _writeBuffer.GetBuffer(); } 1.56 + 1.57 + MY_UNKNOWN_IMP 1.58 + 1.59 + STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 1.60 +}; 1.61 + 1.62 +class CSequentialOutStreamImp2: 1.63 + public ISequentialOutStream, 1.64 + public CMyUnknownImp 1.65 +{ 1.66 + Byte *_buffer; 1.67 + size_t _size; 1.68 + size_t _pos; 1.69 +public: 1.70 + 1.71 + void Init(Byte *buffer, size_t size) 1.72 + { 1.73 + _buffer = buffer; 1.74 + _pos = 0; 1.75 + _size = size; 1.76 + } 1.77 + 1.78 + size_t GetPos() const { return _pos; } 1.79 + 1.80 + MY_UNKNOWN_IMP 1.81 + 1.82 + STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 1.83 +}; 1.84 + 1.85 +class CSequentialInStreamSizeCount: 1.86 + public ISequentialInStream, 1.87 + public CMyUnknownImp 1.88 +{ 1.89 + CMyComPtr<ISequentialInStream> _stream; 1.90 + UInt64 _size; 1.91 +public: 1.92 + void Init(ISequentialInStream *stream) 1.93 + { 1.94 + _stream = stream; 1.95 + _size = 0; 1.96 + } 1.97 + UInt64 GetSize() const { return _size; } 1.98 + 1.99 + MY_UNKNOWN_IMP 1.100 + 1.101 + STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); 1.102 +}; 1.103 + 1.104 +class CSequentialOutStreamSizeCount: 1.105 + public ISequentialOutStream, 1.106 + public CMyUnknownImp 1.107 +{ 1.108 + CMyComPtr<ISequentialOutStream> _stream; 1.109 + UInt64 _size; 1.110 +public: 1.111 + void SetStream(ISequentialOutStream *stream) { _stream = stream; } 1.112 + void Init() { _size = 0; } 1.113 + UInt64 GetSize() const { return _size; } 1.114 + 1.115 + MY_UNKNOWN_IMP 1.116 + 1.117 + STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 1.118 +}; 1.119 + 1.120 +#endif