comparison 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
comparison
equal deleted inserted replaced
0:8ced16adf2e1 1:f9f4f1b99eed
1 // BZip2Crc.h
2
3 #ifndef __BZIP2_CRC_H
4 #define __BZIP2_CRC_H
5
6 #include "Common/Types.h"
7
8 class CBZip2Crc
9 {
10 UInt32 _value;
11 static UInt32 Table[256];
12 public:
13 static void InitTable();
14 CBZip2Crc(): _value(0xFFFFFFFF) {};
15 void Init() { _value = 0xFFFFFFFF; }
16 void UpdateByte(Byte b) { _value = Table[(_value >> 24) ^ b] ^ (_value << 8); }
17 void UpdateByte(unsigned int b) { _value = Table[(_value >> 24) ^ b] ^ (_value << 8); }
18 UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; }
19 };
20
21 class CBZip2CombinedCrc
22 {
23 UInt32 _value;
24 public:
25 CBZip2CombinedCrc(): _value(0){};
26 void Init() { _value = 0; }
27 void Update(UInt32 v) { _value = ((_value << 1) | (_value >> 31)) ^ v; }
28 UInt32 GetDigest() const { return _value ; }
29 };
30
31 #endif