Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cCRC.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cCRC_H
7 #define _INC_cCRC_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "cHashBase.h"
15 
16 namespace GrayLib
17 {
19  typedef UINT32 CRC32_t;
20 
21  class GRAYLIB_LINK cCRC32Table // cSingleton
22  {
25 
26  public:
28  static const cCRC32Table k_Def;
29 
30  public:
31  static const CRC32_t k_nStart = 0xFFFFFFFFUL;
32  static const CRC32_t k_nPolynomial = 0xEDB88320UL;
33 
34  cCRC32Table();
35  ~cCRC32Table();
36 
37  void BuildTable(CRC32_t nPoly = k_nPolynomial);
38  CRC32_t CalculateBufferCRC(const void* pInput, size_t nInputSize, CRC32_t nCrc = k_nStart) const;
39 
41  };
42 
43  class cCRC32Builder : public cHashBase
44  {
47  typedef cHashBase SUPER_t;
48 
49  public:
51  public:
53  : m_HashVal(nStart)
54  {
55  }
56  virtual ~cCRC32Builder() noexcept
57  {
58  }
59 
60  virtual void ResetHash() override
61  {
63  }
64  virtual void AddToHash(const void* pInput, size_t nInputSize) override;
65  virtual size_t FinalizeHash(OUT BYTE* pOutput) override;
66  };
67 
68  //*************************************************************************
69 
70  typedef UINT64 CRC64_t;
71 
72  class GRAYLIB_LINK cCRC64Table // cSingleton
73  {
76 
77  public:
78  static const CRC64_t k_nStart = 0xFFFFFFFFFFFFFFFFULL;
79  static const CRC64_t k_nPolynomial = 0x95AC9329AC4BC9B5ULL;
81 
82  public:
83  cCRC64Table();
84  ~cCRC64Table();
85 
86  void BuildTable(CRC64_t nPoly = k_nPolynomial);
87  CRC64_t CalculateBufferCRC(const void* pInput, size_t nInputSize, CRC64_t nCrc = k_nStart) const;
88  };
89 };
90 
91 #endif // _INC_cCRC_H
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
Definition: cCRC.h:44
virtual void ResetHash() override
Definition: cCRC.h:60
CRC32_t m_HashVal
Definition: cCRC.h:50
virtual size_t FinalizeHash(OUT BYTE *pOutput) override
Digest finalization function.
Definition: cCRC.cpp:115
cCRC32Builder(CRC32_t nStart=cCRC32Table::k_nStart) noexcept
Definition: cCRC.h:52
virtual void AddToHash(const void *pInput, size_t nInputSize) override
Digest update function.
Definition: cCRC.cpp:110
virtual ~cCRC32Builder() noexcept
Definition: cCRC.h:56
Definition: cCRC.h:22
static const cCRC32Table k_Def
default instance.
Definition: cCRC.h:28
cArrayVal< CRC32_t > m_CRCTable
working CRC lookup table. [ 256 ]
Definition: cCRC.h:27
static const CRC32_t k_nStart
Default starting value for CRC.
Definition: cCRC.h:31
Definition: cCRC.h:73
cArrayVal< CRC64_t > m_CRCTable
working CRC lookup table. [ 256 ]
Definition: cCRC.h:80
Definition: cHashBase.h:20
Definition: cMesh.h:22
UNITTEST2_PREDEF(cQuadtree)
UINT64 CRC64_t
64 bit CRC
Definition: cCRC.h:70
UINT32 CRC32_t
32 bit CRC
Definition: cCRC.h:19