diff src/win32/7zip/7z/CPP/7zip/Compress/BZip2Crc.h @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/win32/7zip/7z/CPP/7zip/Compress/BZip2Crc.h	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,31 @@
     1.4 +// BZip2Crc.h
     1.5 +
     1.6 +#ifndef __BZIP2_CRC_H
     1.7 +#define __BZIP2_CRC_H
     1.8 +
     1.9 +#include "Common/Types.h"
    1.10 +
    1.11 +class CBZip2Crc
    1.12 +{
    1.13 +  UInt32 _value;
    1.14 +  static UInt32 Table[256];
    1.15 +public:
    1.16 +  static void InitTable();
    1.17 +  CBZip2Crc(): _value(0xFFFFFFFF) {};
    1.18 +  void Init() { _value = 0xFFFFFFFF; }
    1.19 +  void UpdateByte(Byte b) { _value = Table[(_value >> 24) ^ b] ^ (_value << 8); }
    1.20 +  void UpdateByte(unsigned int b) { _value = Table[(_value >> 24) ^ b] ^ (_value << 8); }
    1.21 +  UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; }
    1.22 +};
    1.23 +
    1.24 +class CBZip2CombinedCrc
    1.25 +{
    1.26 +  UInt32 _value;
    1.27 +public:
    1.28 +  CBZip2CombinedCrc():  _value(0){};
    1.29 +  void Init() { _value = 0; }
    1.30 +  void Update(UInt32 v) { _value = ((_value << 1) | (_value >> 31)) ^ v; }
    1.31 +  UInt32 GetDigest() const { return _value ; }
    1.32 +};
    1.33 +
    1.34 +#endif