CRC32Calculator.h
Go to the documentation of this file.
1 #ifndef cetlib_test_CRC32Calculator_h
2 #define cetlib_test_CRC32Calculator_h
3 
4 /*
5 Code to calculate a CRC32 checksum on a string. This code is based
6 on code copied from the web in the public domain. The code was modified
7 quite a bit to provide the interface we need, remove extraneous code
8 related to NAACR records, convert from C to C++, and use a
9 standard library type for the 32 unsigned integers, but the essential features
10 of the CRC calculation are the same. The array values, constants,
11 and algorithmic steps are identical. The comments in the header
12 from the original code follow below to attribute the source.
13 */
14 
15 /* crc32.c
16 
17  C implementation of CRC-32 checksums for NAACCR records. Code is based
18  upon and utilizes algorithm published by Ross Williams.
19 
20  This file contains:
21  CRC lookup table
22  function CalcCRC32 for calculating CRC-32 checksum
23  function AssignCRC32 for assigning CRC-32 in NAACCR record
24  function CheckCRC32 for checking CRC-32 in NAACCR record
25 
26  Provided by:
27  Eric Durbin
28  Kentucky Cancer Registry
29  University of Kentucky
30  October 14, 1998
31 
32  Status:
33  Public Domain
34 */
35 
36 /*****************************************************************/
37 /* */
38 /* CRC LOOKUP TABLE */
39 /* ================ */
40 /* The following CRC lookup table was generated automagically */
41 /* by the Rocksoft^tm Model CRC Algorithm Table Generation */
42 /* Program V1.0 using the following model parameters: */
43 /* */
44 /* Width : 4 bytes. */
45 /* Poly : 0x04C11DB7L */
46 /* Reverse : TRUE. */
47 /* */
48 /* For more information on the Rocksoft^tm Model CRC Algorithm, */
49 /* see the document titled "A Painless Guide to CRC Error */
50 /* Detection Algorithms" by Ross Williams */
51 /* (ross@guest.adelaide.edu.au.). This document is likely to be */
52 /* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */
53 /* */
54 /*****************************************************************/
55 
56 #include <cstdint>
57 
58 #include <string>
59 
60 namespace cet {
61 
63  public:
64  explicit CRC32Calculator(std::string const& message);
65  std::uint32_t
66  checksum() const
67  {
68  return checksum_;
69  }
70 
71  private:
72  std::uint32_t checksum_;
73  };
74 }
75 #endif /* cetlib_test_CRC32Calculator_h */
76 
77 // Local Variables:
78 // mode: c++
79 // End:
std::string string
Definition: nybbler.cc:12
std::uint32_t checksum() const
CRC32Calculator(std::string const &message)
std::uint32_t checksum_