Crc32C Class Reference

#include <crc32c.h>

详细描述

This class implements a CRC32C generator which is based on the generator polynom x^32+x^28+x^27+x^26+x^25+x^23+x^22+x^20+x^19+x^18+x^14+x^13+x^11+x^10+x^9+x^8+x^6+1 0x11EDC6F41 (the iSCSI CRC). If available the SSE4.2 instructions are used, otherwise it will be calculated by software. The returned CRC value is equal for all machines. All these examples should deliver the same result per line (0xcdee067a) on all systems: UpdateUInt64(0x1234567890abcdef) UpdateUInt32(0x90abcdef) UpdateUInt32(0x12345678) UpdateUInt16(0xcdef) UpdateUInt32(0x567890ab) UpdateUInt16(0x1234) UpdateUChar(0xef) UpdateUChar(0xcd) UpdateUInt32(0x567890ab) UpdateUChar(0x34) UpdateUChar(0x12) UInt64 val = 0x1234567890abcdef Update(&val, 8) see http://drdobbs.com/cpp/229401411 and http://download.intel.com/design/intarch/papers/323405.pdf for a parallelized CRC

公共成员函数

  Crc32C ()
  Crc32C ( UInt32 u)
UInt32   GetCrc () const
void  重置 ()
void  Set ( UInt32 u)
const Crc32C operator= (const Crc32C &other)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateUInt64 ( UInt64 u)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateUInt32 ( UInt32 u)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateUInt16 ( UInt16 u)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateUChar ( UChar u)
MAXON_ATTRIBUTE_FORCE_INLINE void  更新 (const Block < const Byte > &mem)
template<Int ALIGNMENT>
MAXON_ATTRIBUTE_FORCE_INLINE void  更新 (const Block < const Byte > &mem)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateUInt ( UInt u)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateInt64 ( Int64 i)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateInt32 ( Int32 i)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateInt16 ( Int16 i)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateInt ( Int i)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateChar ( Char i)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateBool ( Bool b)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateFloat32 ( Float32 r)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateFloat64 ( Float64 r)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateFloat ( Float r)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateVector2d32 (const Vector2d32 &r)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateVector32 (const Vector32 &r)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateVector4d32 (const Vector4d32 &r)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateVector2d64 (const Vector2d64 &r)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateVector64 (const Vector64 &r)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateVector4d64 (const Vector4d64 &r)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateVector2d (const Vector2d &r)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateVector (const 向量 &r)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdateVector4d (const Vector4d &r)
MAXON_ATTRIBUTE_FORCE_INLINE void  UpdatePointer (const void *p)

静态公共成员函数

static constexpr UInt32   GetResetValue ()

静态公共属性

static const UInt32   UNSET_VALUE

Protected Attributes

UInt32   _crc

Static Protected Attributes

static const UInt32   crc32tab_o32 [256]
static const UInt32   crc32tab_o40 [256]
static const UInt32   crc32tab_o48 [256]
static const UInt32   crc32tab_o56 [256]
static const UInt32   crc32tab_o64 [256]
static const UInt32   crc32tab_o72 [256]
static const UInt32   crc32tab_o80 [256]
static const UInt32   crc32tab_o88 [256]
static const UInt32   RESET_VALUE

Friends

Bool   operator== (const Crc32C &a, const Crc32C &b)
Bool   operator!= (const Crc32C &a, const Crc32C &b)

构造函数 & 析构函数文档编制

◆  Crc32C() [1/2]

Crc32C ( )

Constructs the object and resets its state.

◆  Crc32C() [2/2]

Crc32C ( UInt32   u )
explicit

Constructs the object and sets its state to a certain value.

参数
[in] u The initial value.

成员函数文档编制

◆  GetCrc()

UInt32 GetCrc ( ) const

Gets the CRC value.

返回
The CRC value.

◆  Reset()

void Reset ( )

Resets the state of this instance.

◆  Set()

void Set ( UInt32   u )

Constructs the objects and resets its state.

参数
[in] u The new state value.

◆  operator=()

const Crc32C & operator= ( const Crc32C other )

Assigns another value.

参数
[in] other The new value.
返回
A reference to itself.

◆  GetResetValue()

static constexpr UInt32 GetResetValue ( )
static constexpr

Gets the internal value of a reset class.

返回
The reset value.

◆  UpdateUInt64()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateUInt64 ( UInt64   u )

Accumulates the CRC value.

参数
[in] u The value used to accumulate the CRC value.

◆  UpdateUInt32()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateUInt32 ( UInt32   u )

Accumulates the CRC value.

参数
[in] u The value used to accumulate the CRC value.

◆  UpdateUInt16()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateUInt16 ( UInt16   u )

Accumulates the CRC value.

参数
[in] u The value used to accumulate the CRC value.

◆  UpdateUChar()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateUChar ( UChar   u )

Accumulates the CRC value.

参数
[in] u The value used to accumulate the CRC value.

◆  Update() [1/2]

MAXON_ATTRIBUTE_FORCE_INLINE void Update ( const Block < const Byte > &  mem )

Accumulates the CRC value.

参数
[in] mem A raw memory buffer.

◆  Update() [2/2]

MAXON_ATTRIBUTE_FORCE_INLINE void Update ( const Block < const Byte > &  mem )

Accumulates the CRC value.

Template Parameters
ALIGNMENT Alignment hint. Must be a power of 2.
参数
[in] mem A raw memory buffer.

◆  UpdateUInt()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateUInt ( UInt   u )

Accumulates the CRC value.

参数
[in] u The value used to accumulate the CRC value.

◆  UpdateInt64()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateInt64 ( Int64   i )

Accumulates the CRC value.

参数
[in] i The value used to accumulate the CRC value.

◆  UpdateInt32()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateInt32 ( Int32   i )

Accumulates the CRC value.

参数
[in] i The value used to accumulate the CRC value.

◆  UpdateInt16()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateInt16 ( Int16   i )

Accumulates the CRC value.

参数
[in] i The value used to accumulate the CRC value.

◆  UpdateInt()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateInt ( Int   i )

Accumulates the CRC value.

参数
[in] i The value used to accumulate the CRC value.

◆  UpdateChar()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateChar ( Char   i )

Accumulates the CRC value.

参数
[in] i The value used to accumulate the CRC value.

◆  UpdateBool()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateBool ( Bool   b )

Accumulates the CRC value.

参数
[in] b The value used to accumulate the CRC value.

◆  UpdateFloat32()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateFloat32 ( Float32   r )

Accumulates the CRC value.

参数
[in] r The value used to accumulate the CRC value.

◆  UpdateFloat64()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateFloat64 ( Float64   r )

Accumulates the CRC value.

参数
[in] r The value used to accumulate the CRC value.

◆  UpdateFloat()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateFloat ( Float   r )

Accumulates the CRC value.

参数
[in] r The value used to accumulate the CRC value.

◆  UpdateVector2d32()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateVector2d32 ( const Vector2d32 r )

Accumulates the CRC value.

参数
[in] r The value used to accumulate the CRC value.

◆  UpdateVector32()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateVector32 ( const Vector32 r )

Accumulates the CRC value.

参数
[in] r The value used to accumulate the CRC value.

◆  UpdateVector4d32()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateVector4d32 ( const Vector4d32 r )

Accumulates the CRC value.

参数
[in] r The value used to accumulate the CRC value.

◆  UpdateVector2d64()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateVector2d64 ( const Vector2d64 r )

Accumulates the CRC value.

参数
[in] r The value used to accumulate the CRC value.

◆  UpdateVector64()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateVector64 ( const Vector64 r )

Accumulates the CRC value.

参数
[in] r The value used to accumulate the CRC value.

◆  UpdateVector4d64()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateVector4d64 ( const Vector4d64 r )

Accumulates the CRC value.

参数
[in] r The value used to accumulate the CRC value.

◆  UpdateVector2d()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateVector2d ( const Vector2d r )

Accumulates the CRC value.

参数
[in] r The value used to accumulate the CRC value.

◆  UpdateVector()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateVector ( const 向量 r )

Accumulates the CRC value.

参数
[in] r The value used to accumulate the CRC value.

◆  UpdateVector4d()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdateVector4d ( const Vector4d r )

Accumulates the CRC value.

参数
[in] r The value used to accumulate the CRC value.

◆  UpdatePointer()

MAXON_ATTRIBUTE_FORCE_INLINE void UpdatePointer ( const void *  p )

Accumulates the CRC value.

参数
[in] p The value used to accumulate the CRC value.

Friends And Related Function Documentation

◆  operator==

Bool operator== ( const Crc32C a ,
const Crc32C b  
)
friend

Checks for equality.

参数
[in] a First operand.
[in] b Second operand.
返回
True, if both are equal.

◆  operator!=

Bool operator!= ( const Crc32C a ,
const Crc32C b  
)
friend

Checks for inequality.

参数
[in] a First operand.
[in] b Second operand.
返回
True, if both are equal.

Member Data Documentation

◆  _crc

UInt32 _crc
protected

The CRC value that is accumulated.

◆  crc32tab_o32

const UInt32 crc32tab_o32[256]
static protected

A helper table for the software CRC.

◆  crc32tab_o40

const UInt32 crc32tab_o40[256]
static protected

◆  crc32tab_o48

const UInt32 crc32tab_o48[256]
static protected

◆  crc32tab_o56

const UInt32 crc32tab_o56[256]
static protected

◆  crc32tab_o64

const UInt32 crc32tab_o64[256]
static protected

◆  crc32tab_o72

const UInt32 crc32tab_o72[256]
static protected

◆  crc32tab_o80

const UInt32 crc32tab_o80[256]
static protected

◆  crc32tab_o88

const UInt32 crc32tab_o88[256]
static protected

◆  RESET_VALUE

const UInt32 RESET_VALUE
static protected

◆  UNSET_VALUE

const UInt32 UNSET_VALUE static

Crc is most liekly unset if GetCrc returns UNSET_VALUE.