• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // CWrappers.h
2 
3 #ifndef __C_WRAPPERS_H
4 #define __C_WRAPPERS_H
5 
6 #include "../ICoder.h"
7 #include "../../Common/MyCom.h"
8 
9 SRes HRESULT_To_SRes(HRESULT res, SRes defaultRes) throw();
10 HRESULT SResToHRESULT(SRes res) throw();
11 
12 struct CCompressProgressWrap
13 {
14   ICompressProgress vt;
15   ICompressProgressInfo *Progress;
16   HRESULT Res;
17 
18   void Init(ICompressProgressInfo *progress) throw();
19 };
20 
21 
22 struct CSeqInStreamWrap
23 {
24   ISeqInStream vt;
25   ISequentialInStream *Stream;
26   HRESULT Res;
27   UInt64 Processed;
28 
29   void Init(ISequentialInStream *stream) throw();
30 };
31 
32 
33 struct CSeekInStreamWrap
34 {
35   ISeekInStream vt;
36   IInStream *Stream;
37   HRESULT Res;
38 
39   void Init(IInStream *stream) throw();
40 };
41 
42 
43 struct CSeqOutStreamWrap
44 {
45   ISeqOutStream vt;
46   ISequentialOutStream *Stream;
47   HRESULT Res;
48   UInt64 Processed;
49 
50   void Init(ISequentialOutStream *stream) throw();
51 };
52 
53 
54 struct CByteInBufWrap
55 {
56   IByteIn vt;
57   const Byte *Cur;
58   const Byte *Lim;
59   Byte *Buf;
60   UInt32 Size;
61   ISequentialInStream *Stream;
62   UInt64 Processed;
63   bool Extra;
64   HRESULT Res;
65 
66   CByteInBufWrap();
~CByteInBufWrapCByteInBufWrap67   ~CByteInBufWrap() { Free(); }
68   void Free() throw();
69   bool Alloc(UInt32 size) throw();
InitCByteInBufWrap70   void Init()
71   {
72     Lim = Cur = Buf;
73     Processed = 0;
74     Extra = false;
75     Res = S_OK;
76   }
GetProcessedCByteInBufWrap77   UInt64 GetProcessed() const { return Processed + (size_t)(Cur - Buf); }
78   Byte ReadByteFromNewBlock() throw();
ReadByteCByteInBufWrap79   Byte ReadByte()
80   {
81     if (Cur != Lim)
82       return *Cur++;
83     return ReadByteFromNewBlock();
84   }
85 };
86 
87 
88 /*
89 struct CLookToSequentialWrap
90 {
91   Byte *BufBase;
92   UInt32 Size;
93   ISequentialInStream *Stream;
94   UInt64 Processed;
95   bool Extra;
96   HRESULT Res;
97 
98   CLookToSequentialWrap(): BufBase(NULL) {}
99   ~CLookToSequentialWrap() { Free(); }
100   void Free() throw();
101   bool Alloc(UInt32 size) throw();
102   void Init()
103   {
104     // Lim = Cur = Buf;
105     Processed = 0;
106     Extra = false;
107     Res = S_OK;
108   }
109   // UInt64 GetProcessed() const { return Processed + (Cur - Buf); }
110 
111   Byte ReadByteFromNewBlock() throw();
112   Byte ReadByte()
113   {
114     if (Cur != Lim)
115       return *Cur++;
116     return ReadByteFromNewBlock();
117   }
118 };
119 
120 EXTERN_C_BEGIN
121 // void CLookToSequentialWrap_Look(ILookInSeqStream *pp);
122 EXTERN_C_END
123 */
124 
125 
126 
127 struct CByteOutBufWrap
128 {
129   IByteOut vt;
130   Byte *Cur;
131   const Byte *Lim;
132   Byte *Buf;
133   size_t Size;
134   ISequentialOutStream *Stream;
135   UInt64 Processed;
136   HRESULT Res;
137 
138   CByteOutBufWrap() throw();
~CByteOutBufWrapCByteOutBufWrap139   ~CByteOutBufWrap() { Free(); }
140   void Free() throw();
141   bool Alloc(size_t size) throw();
InitCByteOutBufWrap142   void Init()
143   {
144     Cur = Buf;
145     Lim = Buf + Size;
146     Processed = 0;
147     Res = S_OK;
148   }
GetProcessedCByteOutBufWrap149   UInt64 GetProcessed() const { return Processed + (size_t)(Cur - Buf); }
150   HRESULT Flush() throw();
WriteByteCByteOutBufWrap151   void WriteByte(Byte b)
152   {
153     *Cur++ = b;
154     if (Cur == Lim)
155       Flush();
156   }
157 };
158 
159 
160 /*
161 struct CLookOutWrap
162 {
163   ILookOutStream vt;
164   Byte *Buf;
165   size_t Size;
166   ISequentialOutStream *Stream;
167   UInt64 Processed;
168   HRESULT Res;
169 
170   CLookOutWrap() throw();
171   ~CLookOutWrap() { Free(); }
172   void Free() throw();
173   bool Alloc(size_t size) throw();
174   void Init()
175   {
176     Processed = 0;
177     Res = S_OK;
178   }
179 };
180 */
181 
182 #endif
183