misc/libphysfs/lzma/CPP/7zip/Common/StreamObjects.h
changeset 13904 99b265e0d1d0
parent 13903 5f819b90d479
child 13905 b172a5d40eee
equal deleted inserted replaced
13903:5f819b90d479 13904:99b265e0d1d0
     1 // StreamObjects.h
       
     2 
       
     3 #ifndef __STREAMOBJECTS_H
       
     4 #define __STREAMOBJECTS_H
       
     5 
       
     6 #include "../../Common/DynamicBuffer.h"
       
     7 #include "../../Common/MyCom.h"
       
     8 #include "../IStream.h"
       
     9 
       
    10 class CSequentialInStreamImp: 
       
    11   public ISequentialInStream,
       
    12   public CMyUnknownImp
       
    13 {
       
    14   const Byte *_dataPointer;
       
    15   size_t _size;
       
    16   size_t _pos;
       
    17 
       
    18 public:
       
    19   void Init(const Byte *dataPointer, size_t size)
       
    20   {
       
    21     _dataPointer = dataPointer;
       
    22     _size = size;
       
    23     _pos = 0;
       
    24   }
       
    25 
       
    26   MY_UNKNOWN_IMP
       
    27 
       
    28   STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
       
    29 };
       
    30 
       
    31 
       
    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 };
       
    43 
       
    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(); }
       
    53 
       
    54   MY_UNKNOWN_IMP
       
    55 
       
    56   STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
       
    57 };
       
    58 
       
    59 class CSequentialOutStreamImp2: 
       
    60   public ISequentialOutStream,
       
    61   public CMyUnknownImp
       
    62 {
       
    63   Byte *_buffer;
       
    64   size_t _size;
       
    65   size_t _pos;
       
    66 public:
       
    67 
       
    68   void Init(Byte *buffer, size_t size)  
       
    69   { 
       
    70     _buffer = buffer;
       
    71     _pos = 0;
       
    72     _size = size; 
       
    73   }
       
    74 
       
    75   size_t GetPos() const { return _pos; }
       
    76 
       
    77   MY_UNKNOWN_IMP
       
    78 
       
    79   STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
       
    80 };
       
    81 
       
    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; }
       
    95 
       
    96   MY_UNKNOWN_IMP
       
    97 
       
    98   STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
       
    99 };
       
   100 
       
   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; }
       
   111 
       
   112   MY_UNKNOWN_IMP
       
   113 
       
   114   STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
       
   115 };
       
   116 
       
   117 #endif