summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/lzma/CPP/7zip/Common/StreamObjects.h
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/lzma/CPP/7zip/Common/StreamObjects.h')
-rw-r--r--3rdparty/lzma/CPP/7zip/Common/StreamObjects.h95
1 files changed, 42 insertions, 53 deletions
diff --git a/3rdparty/lzma/CPP/7zip/Common/StreamObjects.h b/3rdparty/lzma/CPP/7zip/Common/StreamObjects.h
index e20e9bd80de..2c0ebea9d62 100644
--- a/3rdparty/lzma/CPP/7zip/Common/StreamObjects.h
+++ b/3rdparty/lzma/CPP/7zip/Common/StreamObjects.h
@@ -1,7 +1,7 @@
// StreamObjects.h
-#ifndef __STREAM_OBJECTS_H
-#define __STREAM_OBJECTS_H
+#ifndef ZIP7_INC_STREAM_OBJECTS_H
+#define ZIP7_INC_STREAM_OBJECTS_H
#include "../../Common/MyBuffer.h"
#include "../../Common/MyCom.h"
@@ -9,39 +9,33 @@
#include "../IStream.h"
-class CBufferInStream:
- public IInStream,
- public CMyUnknownImp
-{
+Z7_CLASS_IMP_IInStream(
+ CBufferInStream
+)
UInt64 _pos;
public:
CByteBuffer Buf;
void Init() { _pos = 0; }
-
- MY_UNKNOWN_IMP2(ISequentialInStream, IInStream)
-
- STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
- STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
};
-struct CReferenceBuf:
- public IUnknown,
- public CMyUnknownImp
-{
+
+Z7_CLASS_IMP_COM_0(
+ CReferenceBuf
+)
+public:
CByteBuffer Buf;
- MY_UNKNOWN_IMP
};
-class CBufInStream:
- public IInStream,
- public CMyUnknownImp
-{
+
+Z7_CLASS_IMP_IInStream(
+ CBufInStream
+)
const Byte *_data;
UInt64 _pos;
size_t _size;
CMyComPtr<IUnknown> _ref;
public:
- void Init(const Byte *data, size_t size, IUnknown *ref = 0)
+ void Init(const Byte *data, size_t size, IUnknown *ref = NULL)
{
_data = data;
_size = size;
@@ -50,22 +44,24 @@ public:
}
void Init(CReferenceBuf *ref) { Init(ref->Buf, ref->Buf.Size(), ref); }
- MY_UNKNOWN_IMP2(ISequentialInStream, IInStream)
- STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
- STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+ // Seek() is allowed here. So reading order could be changed
+ bool WasFinished() const { return _pos == _size; }
};
+
void Create_BufInStream_WithReference(const void *data, size_t size, IUnknown *ref, ISequentialInStream **stream);
void Create_BufInStream_WithNewBuffer(const void *data, size_t size, ISequentialInStream **stream);
inline void Create_BufInStream_WithNewBuffer(const CByteBuffer &buf, ISequentialInStream **stream)
{ Create_BufInStream_WithNewBuffer(buf, buf.Size(), stream); }
-class CByteDynBuffer
+
+class CByteDynBuffer Z7_final
{
size_t _capacity;
Byte *_buf;
+ Z7_CLASS_NO_COPY(CByteDynBuffer)
public:
- CByteDynBuffer(): _capacity(0), _buf(0) {};
+ CByteDynBuffer(): _capacity(0), _buf(NULL) {}
// there is no copy constructor. So don't copy this object.
~CByteDynBuffer() { Free(); }
void Free() throw();
@@ -75,10 +71,11 @@ public:
bool EnsureCapacity(size_t capacity) throw();
};
-class CDynBufSeqOutStream:
- public ISequentialOutStream,
- public CMyUnknownImp
-{
+
+Z7_CLASS_IMP_COM_1(
+ CDynBufSeqOutStream
+ , ISequentialOutStream
+)
CByteDynBuffer _buffer;
size_t _size;
public:
@@ -89,15 +86,13 @@ public:
void CopyToBuffer(CByteBuffer &dest) const;
Byte *GetBufPtrForWriting(size_t addSize);
void UpdateSize(size_t addSize) { _size += addSize; }
-
- MY_UNKNOWN_IMP1(ISequentialOutStream)
- STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
};
-class CBufPtrSeqOutStream:
- public ISequentialOutStream,
- public CMyUnknownImp
-{
+
+Z7_CLASS_IMP_COM_1(
+ CBufPtrSeqOutStream
+ , ISequentialOutStream
+)
Byte *_buffer;
size_t _size;
size_t _pos;
@@ -109,30 +104,28 @@ public:
_size = size;
}
size_t GetPos() const { return _pos; }
-
- MY_UNKNOWN_IMP1(ISequentialOutStream)
- STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
};
-class CSequentialOutStreamSizeCount:
- public ISequentialOutStream,
- public CMyUnknownImp
-{
+
+Z7_CLASS_IMP_COM_1(
+ CSequentialOutStreamSizeCount
+ , ISequentialOutStream
+)
CMyComPtr<ISequentialOutStream> _stream;
UInt64 _size;
public:
void SetStream(ISequentialOutStream *stream) { _stream = stream; }
void Init() { _size = 0; }
UInt64 GetSize() const { return _size; }
-
- MY_UNKNOWN_IMP1(ISequentialOutStream)
- STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
};
+
class CCachedInStream:
public IInStream,
public CMyUnknownImp
{
+ Z7_IFACES_IMP_UNK_2(ISequentialInStream, IInStream)
+
UInt64 *_tags;
Byte *_data;
size_t _dataSize;
@@ -143,15 +136,11 @@ class CCachedInStream:
protected:
virtual HRESULT ReadBlock(UInt64 blockIndex, Byte *dest, size_t blockSize) = 0;
public:
- CCachedInStream(): _tags(0), _data(0) {}
- virtual ~CCachedInStream() { Free(); } // the destructor must be virtual (release calls it) !!!
+ CCachedInStream(): _tags(NULL), _data(NULL) {}
+ virtual ~CCachedInStream() { Free(); } // the destructor must be virtual (Release() calls it) !!!
void Free() throw();
bool Alloc(unsigned blockSizeLog, unsigned numBlocksLog) throw();
void Init(UInt64 size) throw();
-
- MY_UNKNOWN_IMP2(ISequentialInStream, IInStream)
- STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
- STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
};
#endif