BaseLibCompressor.h
Go to the documentation of this file.
1 
2 // This source file is part of the ZipArchive library source distribution and
3 // is Copyrighted 2000 - 2013 by Artpol Software - Tadeusz Dracz
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // For the licensing details refer to the License.txt file.
11 //
12 // Web Site: http://www.artpol-software.com
14 
21 #if !defined(ZIPARCHIVE_BASELIBCOMPRESSOR_DOT_H)
22 #define ZIPARCHIVE_BASELIBCOMPRESSOR_DOT_H
23 
24 #if _MSC_VER > 1000
25 #pragma once
26 #endif
27 
28 #include "ZipExport.h"
29 #include "ZipCompressor.h"
30 #include "ZipCollections.h"
31 #include "ZipException.h"
32 
33 namespace ZipArchiveLib
34 {
35 
39 class ZIP_API CBaseLibCompressor : public CZipCompressor
40 {
41 public:
51  {
52  COptions()
53  {
54  m_bDetectLibMemoryLeaks = true;
55  }
56 
62  };
63 
71  :CZipCompressor(pStorage)
72  {
73  }
74 
75  void InitDecompression(CZipFileHeader* pFile, CZipCryptograph* pCryptograph)
76  {
77  CZipCompressor::InitDecompression(pFile, pCryptograph);
78  m_bDecompressionDone = false;
79  }
80 
82  {
83  EmptyPtrList();
84  }
85 protected:
86 
102  static void* _zipalloc(void* opaque, UINT items, UINT size)
103  {
104  void* p = new char[size * items];
105  if (opaque)
106  {
107  CZipPtrList<void*>* list = (CZipPtrList<void*>*) opaque;
108  list->AddTail(p);
109  }
110  return p;
111  }
112 
122  static void _zipfree(void* opaque, void* address)
123  {
124  if (opaque)
125  {
126  CZipPtrList<void*>* list = (CZipPtrList<void*>*) opaque;
127  CZipPtrListIter iter = list->Find(address);
128  if (list->IteratorValid(iter))
129  list->RemoveAt(iter);
130  }
131  delete[] (char*) address;
132  }
133 
138  void EmptyPtrList();
139 
149  virtual bool IsCodeErrorOK(int iErr) const = 0;
150 
158  void CheckForError(int iErr)
159  {
160  if (!IsCodeErrorOK(iErr))
161  ThrowError(iErr, true);
162  }
163 
172  void SetOpaque(void** opaque, const COptions* pOptions);
173 
178 private:
179  typedef CZipPtrList<void*>::iterator CZipPtrListIter;
180 
181 #if (_MSC_VER > 1000) && (defined ZIP_HAS_DLL)
182  #pragma warning (push)
183  #pragma warning( disable : 4251 ) // needs to have dll-interface to be used by clients of class
184 #endif
185 
186  CZipPtrList<void*> m_list;
187 
188 #if (_MSC_VER > 1000) && (defined ZIP_HAS_DLL)
189  #pragma warning( pop)
190 #endif
191 
192 };
193 
194 } // namespace
195 
196 #endif

The ZipArchive Library Copyright © 2000 - 2013 Artpol Software - Tadeusz Dracz. Generated at Mon Feb 25 2013 16:29:20.