~ubuntu-branches/ubuntu/precise/p7zip/precise-updates

« back to all changes in this revision

Viewing changes to CPP/7zip/Compress/BZip2Crc.h

  • Committer: Bazaar Package Importer
  • Author(s): Mohammed Adnène Trojette
  • Date: 2009-02-14 20:12:27 UTC
  • mfrom: (1.1.11 upstream) (2.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090214201227-go63qxm9ozfdma60
Tags: 4.65~dfsg.1-1
* New upstream release.
* Remove wx2.8 Build-Depends added by mistakes (7zG is not yet
  intended to be built).
* Use dh_clean without -k.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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