compressor.h

Engine/source/core/util/zip/compressor.h

More...

Classes:

Namespaces:

namespace

Namespace for the zip code.

Public Defines

define
CompressorCreateReadStream(name)     * Compressor##name::createReadStream( CentralDir *cdir,  *zipStream)
define
CompressorCreateWriteStream(name)     * Compressor##name::createWriteStream( CentralDir *cdir,  *zipStream)
define
ImplementCompressor(name, method)    class Compressor##name : public Compressor   \
   {                                            \
   public:                                      \
      Compressor##name( m,  char *) : Compressor(m, ) {} \
      virtual  *createReadStream( CentralDir *cdir,  *zipStream); \
      virtual  *createWriteStream( CentralDir *cdir,  *zipStream); \
   };                                           \
   Compressor##name gCompressor##name##instance(method, #name);

Detailed Description

Public Defines

CompressorCreateReadStream(name)     * Compressor##name::createReadStream( CentralDir *cdir,  *zipStream)
CompressorCreateWriteStream(name)     * Compressor##name::createWriteStream( CentralDir *cdir,  *zipStream)
ImplementCompressor(name, method)    class Compressor##name : public Compressor   \
   {                                            \
   public:                                      \
      Compressor##name( m,  char *) : Compressor(m, ) {} \
      virtual  *createReadStream( CentralDir *cdir,  *zipStream); \
      virtual  *createWriteStream( CentralDir *cdir,  *zipStream); \
   };                                           \
   Compressor##name gCompressor##name##instance(method, #name);
  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#include "core/util/zip/centralDir.h"
 25
 26#ifndef _COMPRESSOR_H_
 27#define _COMPRESSOR_H_
 28
 29// Forward refs
 30class Stream;
 31
 32namespace Zip
 33{
 34
 35/// @addtogroup zipint_group
 36/// @ingroup zip_group
 37// @{
 38
 39// [tom, 10/26/2006] Standard Zip compression methods
 40enum CompressionMethod
 41{
 42   Stored            = 0,
 43   Shrunk            = 1,
 44   ReducedL1         = 2,
 45   ReducedL2         = 3,
 46   ReducedL3         = 4,
 47   ReducedL4         = 5,
 48   Imploded          = 6,
 49   ReservedTokenized = 7,
 50   Deflated          = 8,
 51   EnhDefalted       = 9,
 52   DateCompression   = 10,
 53   ReservedPKWARE    = 11,
 54   BZip2             = 12,
 55   PPMd              = 98,
 56   AESEncrypted      = 99,    // WinZip's AES Encrypted zips use compression method 99
 57                              // to indicate AES encryption. The actual compression
 58                              // method is specified in the AES extra field.
 59};
 60
 61class Compressor
 62{
 63   Compressor *mNext;
 64
 65protected:
 66   const char *mName;         //!< The name of the compression method
 67   S32 mMethod;               //!< The compression method as in the Zip header
 68
 69public:
 70   Compressor(S32 method, const char *name);
 71   virtual ~Compressor() {}
 72
 73   inline const char * getName()                { return mName; }
 74   inline S32 getMethod()                       { return mMethod; }
 75
 76   virtual Stream *createReadStream(const CentralDir *cdir, Stream *zipStream) = 0;
 77   virtual Stream *createWriteStream(const CentralDir *cdir, Stream *zipStream) = 0;
 78
 79   // Run time lookup methods
 80   static Compressor *findCompressor(const char *name);
 81   static Compressor *findCompressor(S32 method);
 82};
 83
 84#define ImplementCompressor(name, method)       \
 85   class Compressor##name : public Compressor   \
 86   {                                            \
 87   public:                                      \
 88      Compressor##name(S32 m, const char *n) : Compressor(m, n) {} \
 89      virtual Stream *createReadStream(const CentralDir *cdir, Stream *zipStream); \
 90      virtual Stream *createWriteStream(const CentralDir *cdir, Stream *zipStream); \
 91   };                                           \
 92   Compressor##name gCompressor##name##instance(method, #name);
 93
 94#define  CompressorCreateReadStream(name) \
 95   Stream * Compressor##name::createReadStream(const CentralDir *cdir, Stream *zipStream)
 96
 97#define  CompressorCreateWriteStream(name) \
 98   Stream * Compressor##name::createWriteStream(const CentralDir *cdir, Stream *zipStream)
 99
100// @}
101
102} // end namespace Zip
103
104#endif // _COMPRESSOR_H_
105