Mercurial > vba-linux
diff src/win32/7zip/7z/CPP/7zip/Common/OutBuffer.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/OutBuffer.h Sat Mar 03 10:31:27 2012 -0600 1.3 @@ -0,0 +1,64 @@ 1.4 +// OutBuffer.h 1.5 + 1.6 +#ifndef __OUTBUFFER_H 1.7 +#define __OUTBUFFER_H 1.8 + 1.9 +#include "../IStream.h" 1.10 +#include "../../Common/MyCom.h" 1.11 +#include "../../Common/MyException.h" 1.12 + 1.13 +#ifndef _NO_EXCEPTIONS 1.14 +struct COutBufferException: public CSystemException 1.15 +{ 1.16 + COutBufferException(HRESULT errorCode): CSystemException(errorCode) {} 1.17 +}; 1.18 +#endif 1.19 + 1.20 +class COutBuffer 1.21 +{ 1.22 +protected: 1.23 + Byte *_buffer; 1.24 + UInt32 _pos; 1.25 + UInt32 _limitPos; 1.26 + UInt32 _streamPos; 1.27 + UInt32 _bufferSize; 1.28 + CMyComPtr<ISequentialOutStream> _stream; 1.29 + UInt64 _processedSize; 1.30 + Byte *_buffer2; 1.31 + bool _overDict; 1.32 + 1.33 + HRESULT FlushPart(); 1.34 +public: 1.35 + #ifdef _NO_EXCEPTIONS 1.36 + HRESULT ErrorCode; 1.37 + #endif 1.38 + 1.39 + COutBuffer(): _buffer(0), _pos(0), _stream(0), _buffer2(0) {} 1.40 + ~COutBuffer() { Free(); } 1.41 + 1.42 + bool Create(UInt32 bufferSize); 1.43 + void Free(); 1.44 + 1.45 + void SetMemStream(Byte *buffer) { _buffer2 = buffer; } 1.46 + void SetStream(ISequentialOutStream *stream); 1.47 + void Init(); 1.48 + HRESULT Flush(); 1.49 + void FlushWithCheck(); 1.50 + void ReleaseStream() { _stream.Release(); } 1.51 + 1.52 + void WriteByte(Byte b) 1.53 + { 1.54 + _buffer[_pos++] = b; 1.55 + if(_pos == _limitPos) 1.56 + FlushWithCheck(); 1.57 + } 1.58 + void WriteBytes(const void *data, size_t size) 1.59 + { 1.60 + for (size_t i = 0; i < size; i++) 1.61 + WriteByte(((const Byte *)data)[i]); 1.62 + } 1.63 + 1.64 + UInt64 GetProcessedSize() const; 1.65 +}; 1.66 + 1.67 +#endif