Class CRC¶
Static class for computing CRCs. More...
#include <CRC.h>
Classes¶
| Type | Name |
|---|---|
| struct | Parameters <typename CRCType, CRCWidth> CRC parameters. |
| struct | Table <typename CRCType, CRCWidth> CRC lookup table. After construction, theCRC parameters are fixed. |
Public Static Functions¶
| Type | Name |
|---|---|
| const Parameters< uint16_t, 16 > & | CRC_16_ARC () Returns a set of parameters for CRC-16 ARC (aka CRC-16 IBM, CRC-16 LHA). |
| const Parameters< uint16_t, 16 > & | CRC_16_BUYPASS () Returns a set of parameters for CRC-16 BUYPASS (aka CRC-16 VERIFONE, CRC-16 UMTS). |
| const Parameters< uint16_t, 16 > & | CRC_16_CCITTFALSE () Returns a set of parameters for CRC-16 CCITT FALSE. |
| const Parameters< uint16_t, 16 > & | CRC_16_GENIBUS () Returns a set of parameters for CRC-16 GENIBUS (aka CRC-16 EPC, CRC-16 I-CODE, CRC-16 DARC). |
| const Parameters< uint16_t, 16 > & | CRC_16_KERMIT () Returns a set of parameters for CRC-16 KERMIT (aka CRC-16 CCITT, CRC-16 CCITT-TRUE). |
| const Parameters< uint16_t, 16 > & | CRC_16_X25 () Returns a set of parameters for CRC-16 X-25 (aka CRC-16 IBM-SDLC, CRC-16 ISO-HDLC, CRC-16 B). |
| const Parameters< uint16_t, 16 > & | CRC_16_XMODEM () Returns a set of parameters for CRC-16 XMODEM (aka CRC-16 ZMODEM, CRC-16 ACORN, CRC-16 LTE). |
| const Parameters< uint32_t, 32 > & | CRC_32 () Returns a set of parameters for CRC-32 (aka CRC-32 ADCCP, CRC-32 PKZip). |
| const Parameters< uint32_t, 32 > & | CRC_32_BZIP2 () Returns a set of parameters for CRC-32 BZIP2 (aka CRC-32 AAL5, CRC-32 DECT-B, CRC-32 B-CRC). |
| const Parameters< uint32_t, 32 > & | CRC_32_MPEG2 () Returns a set of parameters for CRC-32 MPEG-2. |
| const Parameters< uint32_t, 32 > & | CRC_32_POSIX () Returns a set of parameters for CRC-32 POSIX. |
| const Parameters< uint8_t, 8 > & | CRC_8 () Returns a set of parameters for CRC-8 SMBus. |
| CRCType | Calculate (const void * data, size_t size, const Parameters< CRCType, CRCWidth > & parameters) Computes a CRC . |
| CRCType | Calculate (const void * data, size_t size, const Parameters< CRCType, CRCWidth > & parameters, CRCType crc) Appends additional data to a previous CRC calculation. |
| CRCType | Calculate (const void * data, size_t size, const Table< CRCType, CRCWidth > & lookupTable) Computes a CRC via a lookup table. |
| CRCType | Calculate (const void * data, size_t size, const Table< CRCType, CRCWidth > & lookupTable, CRCType crc) Appends additional data to a previous CRC calculation using a lookup table. |
Detailed Description¶
Note:
This class supports computation of full and multi-part CRCs, using a bit-by-bit algorithm or a byte-by-byte lookup table. The CRCs are calculated using as many optimizations as is reasonable. If compiling with C++11, the constexpr keyword is used liberally so that many calculations are performed at compile-time instead of at runtime.
Public Static Functions Documentation¶
function CRC_16_ARC¶
Returns a set of parameters for CRC-16 ARC (aka CRC-16 IBM, CRC-16 LHA).
Note:
The parameters are static and are delayed-constructed to reduce memory footprint.
Note:
CRC-16 ARC has the following parameters and check value: * polynomial = 0x8005 * initial value = 0x0000 * final XOR = 0x0000 * reflect input = true * reflect output = true * check value = 0xBB3D
Returns:
CRC-16 ARC parameters
function CRC_16_BUYPASS¶
Returns a set of parameters for CRC-16 BUYPASS (aka CRC-16 VERIFONE, CRC-16 UMTS).
Note:
The parameters are static and are delayed-constructed to reduce memory footprint.
Note:
CRC-16 BUYPASS has the following parameters and check value: * polynomial = 0x8005 * initial value = 0x0000 * final XOR = 0x0000 * reflect input = false * reflect output = false * check value = 0xFEE8
Returns:
CRC-16 BUYPASS parameters
function CRC_16_CCITTFALSE¶
Returns a set of parameters for CRC-16 CCITT FALSE.
Note:
The parameters are static and are delayed-constructed to reduce memory footprint.
Note:
CRC-16 CCITT FALSE has the following parameters and check value: * polynomial = 0x1021 * initial value = 0xFFFF * final XOR = 0x0000 * reflect input = false * reflect output = false * check value = 0x29B1
Returns:
CRC-16 CCITT FALSE parameters
function CRC_16_GENIBUS¶
Returns a set of parameters for CRC-16 GENIBUS (aka CRC-16 EPC, CRC-16 I-CODE, CRC-16 DARC).
Note:
The parameters are static and are delayed-constructed to reduce memory footprint.
Note:
CRC-16 GENIBUS has the following parameters and check value: * polynomial = 0x1021 * initial value = 0xFFFF * final XOR = 0xFFFF * reflect input = false * reflect output = false * check value = 0xD64E
Returns:
CRC-16 GENIBUS parameters
function CRC_16_KERMIT¶
Returns a set of parameters for CRC-16 KERMIT (aka CRC-16 CCITT, CRC-16 CCITT-TRUE).
Note:
The parameters are static and are delayed-constructed to reduce memory footprint.
Note:
CRC-16 KERMIT has the following parameters and check value: * polynomial = 0x1021 * initial value = 0x0000 * final XOR = 0x0000 * reflect input = true * reflect output = true * check value = 0x2189
Returns:
CRC-16 KERMIT parameters
function CRC_16_X25¶
Returns a set of parameters for CRC-16 X-25 (aka CRC-16 IBM-SDLC, CRC-16 ISO-HDLC, CRC-16 B).
Note:
The parameters are static and are delayed-constructed to reduce memory footprint.
Note:
CRC-16 X-25 has the following parameters and check value: * polynomial = 0x1021 * initial value = 0xFFFF * final XOR = 0xFFFF * reflect input = true * reflect output = true * check value = 0x906E
Returns:
CRC-16 X-25 parameters
function CRC_16_XMODEM¶
Returns a set of parameters for CRC-16 XMODEM (aka CRC-16 ZMODEM, CRC-16 ACORN, CRC-16 LTE).
Note:
The parameters are static and are delayed-constructed to reduce memory footprint.
Note:
CRC-16 XMODEM has the following parameters and check value: * polynomial = 0x1021 * initial value = 0x0000 * final XOR = 0x0000 * reflect input = false * reflect output = false * check value = 0x31C3
Returns:
CRC-16 XMODEM parameters
function CRC_32¶
Returns a set of parameters for CRC-32 (aka CRC-32 ADCCP, CRC-32 PKZip).
Note:
The parameters are static and are delayed-constructed to reduce memory footprint.
Note:
CRC-32 has the following parameters and check value: * polynomial = 0x04C11DB7 * initial value = 0xFFFFFFFF * final XOR = 0xFFFFFFFF * reflect input = true * reflect output = true * check value = 0xCBF43926
Returns:
CRC-32 parameters
function CRC_32_BZIP2¶
Returns a set of parameters for CRC-32 BZIP2 (aka CRC-32 AAL5, CRC-32 DECT-B, CRC-32 B-CRC).
Note:
The parameters are static and are delayed-constructed to reduce memory footprint.
Note:
CRC-32 BZIP2 has the following parameters and check value: * polynomial = 0x04C11DB7 * initial value = 0xFFFFFFFF * final XOR = 0xFFFFFFFF * reflect input = false * reflect output = false * check value = 0xFC891918
Returns:
CRC-32 BZIP2 parameters
function CRC_32_MPEG2¶
Returns a set of parameters for CRC-32 MPEG-2.
Note:
The parameters are static and are delayed-constructed to reduce memory footprint.
Note:
CRC-32 MPEG-2 has the following parameters and check value: * polynomial = 0x04C11DB7 * initial value = 0xFFFFFFFF * final XOR = 0x00000000 * reflect input = false * reflect output = false * check value = 0x0376E6E7
Returns:
CRC-32 MPEG-2 parameters
function CRC_32_POSIX¶
Returns a set of parameters for CRC-32 POSIX.
Note:
The parameters are static and are delayed-constructed to reduce memory footprint.
Note:
CRC-32 POSIX has the following parameters and check value: * polynomial = 0x04C11DB7 * initial value = 0x00000000 * final XOR = 0xFFFFFFFF * reflect input = false * reflect output = false * check value = 0x765E7680
Returns:
CRC-32 POSIX parameters
function CRC_8¶
Returns a set of parameters for CRC-8 SMBus.
Note:
The parameters are static and are delayed-constructed to reduce memory footprint.
Note:
CRC-8 SMBus has the following parameters and check value: * polynomial = 0x07 * initial value = 0x00 * final XOR = 0x00 * reflect input = false * reflect output = false * check value = 0xF4
Returns:
CRC-8 SMBus parameters
function Calculate [1/4]¶
Computes a CRC .
template<typename CRCType, uint16_t CRCWidth>
static inline CRCType CRC::Calculate (
const void * data,
size_t size,
const Parameters < CRCType , CRCWidth > & parameters
)
Parameters:
Template parameters:
Returns:
function Calculate [2/4]¶
Appends additional data to a previous CRC calculation.
template<typename CRCType, uint16_t CRCWidth>
static inline CRCType CRC::Calculate (
const void * data,
size_t size,
const Parameters < CRCType , CRCWidth > & parameters,
CRCType crc
)
Note:
This function can be used to compute multi-part CRCs.
Parameters:
dataData over which CRC will be computedsizeSize of the dataparametersCRC parameterscrcCRC from a previous calculation
Template parameters:
Returns:
function Calculate [3/4]¶
Computes a CRC via a lookup table.
template<typename CRCType, uint16_t CRCWidth>
static inline CRCType CRC::Calculate (
const void * data,
size_t size,
const Table < CRCType , CRCWidth > & lookupTable
)
Parameters:
Template parameters:
Returns:
function Calculate [4/4]¶
Appends additional data to a previous CRC calculation using a lookup table.
template<typename CRCType, uint16_t CRCWidth>
static inline CRCType CRC::Calculate (
const void * data,
size_t size,
const Table < CRCType , CRCWidth > & lookupTable,
CRCType crc
)
Note:
This function can be used to compute multi-part CRCs.
Parameters:
dataData over which CRC will be computedsizeSize of the datalookupTableCRC lookup tablecrcCRC from a previous calculation
Template parameters:
Returns:
The documentation for this class was generated from the following file cubrid/src/base/CRC.h