73# ifdef CRCPP_USE_CPP11
75# define crcpp_uint8 ::std::uint8_t
78# define crcpp_uint8 uint8_t
83# ifdef CRCPP_USE_CPP11
85# define crcpp_uint16 ::std::uint16_t
88# define crcpp_uint16 uint16_t
93# ifdef CRCPP_USE_CPP11
95# define crcpp_uint32 ::std::uint32_t
98# define crcpp_uint32 uint32_t
103# ifdef CRCPP_USE_CPP11
105# define crcpp_uint64 ::std::uint64_t
108# define crcpp_uint64 uint64_t
113# ifdef CRCPP_USE_CPP11
115# define crcpp_size ::std::size_t
118# define crcpp_size size_t
122#ifdef CRCPP_USE_CPP11
124# define crcpp_constexpr constexpr
127# define crcpp_constexpr const
130#if defined(WIN32) || defined(_WIN32) || defined(WINCE)
133#pragma warning(disable : 4127)
136#ifdef CRCPP_USE_NAMESPACE
152 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
158 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
174 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
180#ifdef CRCPP_USE_CPP11
186 const CRCType * GetTable()
const;
188 CRCType operator[](
unsigned char index)
const;
194 CRCType table[1 << CHAR_BIT];
199 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
202 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
205 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
208 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
211 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
214 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
217 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
220 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
225#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
237#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
258#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
267#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
275#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
288#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
293#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
299#ifdef CRCPP_USE_CPP11
301 CRC(
const CRC & other) =
delete;
302 CRC & operator=(
const CRC & other) =
delete;
303 CRC(
CRC && other) =
delete;
304 CRC & operator=(
CRC && other) =
delete;
308#ifndef CRCPP_USE_CPP11
311 CRC & operator=(
const CRC & other);
314 template <
typename IntegerType>
315 static IntegerType Reflect(IntegerType value,
crcpp_uint16 numBits);
317 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
318 static CRCType Finalize(CRCType remainder, CRCType finalXOR,
bool reflectOutput);
320 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
321 static CRCType UndoFinalize(CRCType remainder, CRCType finalXOR,
bool reflectOutput);
323 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
326 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
329 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
341template <
typename CRCType, crcpp_u
int16 CRCW
idth>
354template <
typename CRCType, crcpp_u
int16 CRCW
idth>
361#ifdef CRCPP_USE_CPP11
368template <
typename CRCType, crcpp_u
int16 CRCW
idth>
370 parameters(::std::move(params))
382template <
typename CRCType, crcpp_u
int16 CRCW
idth>
394template <
typename CRCType, crcpp_u
int16 CRCW
idth>
407template <
typename CRCType, crcpp_u
int16 CRCW
idth>
418template <
typename CRCType, crcpp_u
int16 CRCW
idth>
422 static crcpp_constexpr CRCType BIT_MASK((CRCType(1) << (CRCWidth - CRCType(1))) |
423 ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1)));
426 static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ?
static_cast<CRCType
>(CHAR_BIT - CRCWidth) : 0);
429 unsigned char byte = 0;
434 crc = CRC::CalculateRemainder<CRCType, CRCWidth>(&
byte,
sizeof(
byte), parameters, CRCType(0));
441 if (!parameters.reflectInput && CRCWidth < CHAR_BIT)
445 crc =
static_cast<CRCType
>(crc << SHIFT);
462template <
typename CRCType, crcpp_u
int16 CRCW
idth>
465 CRCType remainder = CalculateRemainder(data, size, parameters, parameters.
initialValue);
482template <
typename CRCType, crcpp_u
int16 CRCW
idth>
487 remainder = CalculateRemainder(data, size, parameters, remainder);
503template <
typename CRCType, crcpp_u
int16 CRCW
idth>
508 CRCType remainder = CalculateRemainder(data, size, lookupTable, parameters.
initialValue);
526template <
typename CRCType, crcpp_u
int16 CRCW
idth>
533 remainder = CalculateRemainder(data, size, lookupTable, remainder);
549template <
typename CRCType, crcpp_u
int16 CRCW
idth>
556 crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
557 if (wholeNumberOfBytes > 0)
559 remainder = CalculateRemainder(data, wholeNumberOfBytes, parameters, remainder);
562 crcpp_size remainingNumberOfBits = size % CHAR_BIT;
563 if (remainingNumberOfBits != 0)
565 unsigned char lastByte = *(
reinterpret_cast<const unsigned char *
>(data) + wholeNumberOfBytes);
566 remainder = CalculateRemainderBits(lastByte, remainingNumberOfBits, parameters, remainder);
584template <
typename CRCType, crcpp_u
int16 CRCW
idth>
591 crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
592 if (wholeNumberOfBytes > 0)
594 remainder = CalculateRemainder(data, wholeNumberOfBytes, parameters, parameters.
initialValue);
597 crcpp_size remainingNumberOfBits = size % CHAR_BIT;
598 if (remainingNumberOfBits != 0)
600 unsigned char lastByte = *(
reinterpret_cast<const unsigned char *
>(data) + wholeNumberOfBytes);
601 remainder = CalculateRemainderBits(lastByte, remainingNumberOfBits, parameters, remainder);
618template <
typename CRCType, crcpp_u
int16 CRCW
idth>
627 crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
628 if (wholeNumberOfBytes > 0)
630 remainder = CalculateRemainder(data, wholeNumberOfBytes, lookupTable, remainder);
633 crcpp_size remainingNumberOfBits = size % CHAR_BIT;
634 if (remainingNumberOfBits != 0)
636 unsigned char lastByte = *(
reinterpret_cast<const unsigned char *
>(data) + wholeNumberOfBytes);
637 remainder = CalculateRemainderBits(lastByte, remainingNumberOfBits, parameters, remainder);
656template <
typename CRCType, crcpp_u
int16 CRCW
idth>
665 crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
666 if (wholeNumberOfBytes > 0)
668 remainder = CalculateRemainder(data, wholeNumberOfBytes, lookupTable, parameters.
initialValue);
671 crcpp_size remainingNumberOfBits = size % CHAR_BIT;
672 if (remainingNumberOfBits > 0)
674 unsigned char lastByte = *(
reinterpret_cast<const unsigned char *
>(data) + wholeNumberOfBytes);
675 remainder = CalculateRemainderBits(lastByte, remainingNumberOfBits, parameters, remainder);
690template <
typename IntegerType>
691inline IntegerType CRC::Reflect(IntegerType value,
crcpp_uint16 numBits)
693 IntegerType reversedValue(0);
697 reversedValue =
static_cast<IntegerType
>((reversedValue << 1) | (value & 1));
698 value =
static_cast<IntegerType
>(value >> 1);
701 return reversedValue;
713template <
typename CRCType, crcpp_u
int16 CRCW
idth>
714inline CRCType CRC::Finalize(CRCType remainder, CRCType finalXOR,
bool reflectOutput)
717 static crcpp_constexpr CRCType BIT_MASK = (CRCType(1) << (CRCWidth - CRCType(1))) |
718 ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1));
722 remainder = Reflect(remainder, CRCWidth);
725 return (remainder ^ finalXOR) & BIT_MASK;
745template <
typename CRCType, crcpp_u
int16 CRCW
idth>
746inline CRCType CRC::UndoFinalize(CRCType crc, CRCType finalXOR,
bool reflectOutput)
749 static crcpp_constexpr CRCType BIT_MASK = (CRCType(1) << (CRCWidth - CRCType(1))) |
750 ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1));
752 crc = (crc & BIT_MASK) ^ finalXOR;
756 crc = Reflect(crc, CRCWidth);
772template <
typename CRCType, crcpp_u
int16 CRCW
idth>
773inline CRCType CRC::CalculateRemainder(
const void * data,
crcpp_size size,
const Parameters<CRCType, CRCWidth> & parameters, CRCType remainder)
775#ifdef CRCPP_USE_CPP11
778 static_assert(::std::numeric_limits<CRCType>::digits >= CRCWidth,
"CRCType is too small to contain a CRC of width CRCWidth.");
782 enum { static_assert_failed_CRCType_is_too_small_to_contain_a_CRC_of_width_CRCWidth = 1 / (::std::numeric_limits<CRCType>::digits >= CRCWidth ? 1 : 0) };
785 const unsigned char * current =
reinterpret_cast<const unsigned char *
>(data);
789 if (parameters.reflectInput)
791 CRCType polynomial = CRC::Reflect(parameters.polynomial, CRCWidth);
794 remainder =
static_cast<CRCType
>(remainder ^ *current++);
799#ifdef CRCPP_BRANCHLESS
805 remainder =
static_cast<CRCType
>((remainder >> 1) ^ ((remainder & 1) * polynomial));
807 remainder =
static_cast<CRCType
>((remainder & 1) ? ((remainder >> 1) ^ polynomial) : (remainder >> 1));
812 else if (CRCWidth >= CHAR_BIT)
814 static crcpp_constexpr CRCType CRC_WIDTH_MINUS_ONE(CRCWidth - CRCType(1));
815#ifndef CRCPP_BRANCHLESS
816 static crcpp_constexpr CRCType CRC_HIGHEST_BIT_MASK(CRCType(1) << CRC_WIDTH_MINUS_ONE);
819 static crcpp_constexpr CRCType SHIFT((CRCWidth >= CHAR_BIT) ?
static_cast<CRCType
>(CRCWidth - CHAR_BIT) : 0);
823 remainder =
static_cast<CRCType
>(remainder ^ (
static_cast<CRCType
>(*current++) << SHIFT));
828#ifdef CRCPP_BRANCHLESS
834 remainder =
static_cast<CRCType
>((remainder << 1) ^ (((remainder >> CRC_WIDTH_MINUS_ONE) & 1) * parameters.polynomial));
836 remainder =
static_cast<CRCType
>((remainder & CRC_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ parameters.polynomial) : (remainder << 1));
844#ifndef CRCPP_BRANCHLESS
845 static crcpp_constexpr CRCType CHAR_BIT_HIGHEST_BIT_MASK(CRCType(1) << CHAR_BIT_MINUS_ONE);
848 static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ?
static_cast<CRCType
>(CHAR_BIT - CRCWidth) : 0);
850 CRCType polynomial =
static_cast<CRCType
>(parameters.polynomial << SHIFT);
851 remainder =
static_cast<CRCType
>(remainder << SHIFT);
855 remainder =
static_cast<CRCType
>(remainder ^ *current++);
860#ifdef CRCPP_BRANCHLESS
866 remainder =
static_cast<CRCType
>((remainder << 1) ^ (((remainder >> CHAR_BIT_MINUS_ONE) & 1) * polynomial));
868 remainder =
static_cast<CRCType
>((remainder & CHAR_BIT_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ polynomial) : (remainder << 1));
873 remainder =
static_cast<CRCType
>(remainder >> SHIFT);
889template <
typename CRCType, crcpp_u
int16 CRCW
idth>
890inline CRCType CRC::CalculateRemainder(
const void * data,
crcpp_size size,
const Table<CRCType, CRCWidth> & lookupTable, CRCType remainder)
892 const unsigned char * current =
reinterpret_cast<const unsigned char *
>(data);
894 if (lookupTable.GetParameters().reflectInput)
898#if defined(WIN32) || defined(_WIN32) || defined(WINCE)
902# pragma warning (push)
903# pragma warning (disable : 4333)
905 remainder =
static_cast<CRCType
>((remainder >> CHAR_BIT) ^ lookupTable[
static_cast<unsigned char>(remainder ^ *current++)]);
906#if defined(WIN32) || defined(_WIN32) || defined(WINCE)
907# pragma warning (pop)
911 else if (CRCWidth >= CHAR_BIT)
914 static crcpp_constexpr CRCType SHIFT((CRCWidth >= CHAR_BIT) ?
static_cast<CRCType
>(CRCWidth - CHAR_BIT) : 0);
918 remainder =
static_cast<CRCType
>((remainder << CHAR_BIT) ^ lookupTable[static_cast<unsigned char>((remainder >> SHIFT) ^ *current++)]);
924 static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ?
static_cast<CRCType
>(CHAR_BIT - CRCWidth) : 0);
926 remainder =
static_cast<CRCType
>(remainder << SHIFT);
931 remainder = lookupTable[
static_cast<unsigned char>(remainder ^ *current++)];
934 remainder =
static_cast<CRCType
>(remainder >> SHIFT);
940template <
typename CRCType, crcpp_u
int16 CRCW
idth>
941inline CRCType CRC::CalculateRemainderBits(
unsigned char byte,
crcpp_size numBits,
const Parameters<CRCType, CRCWidth> & parameters, CRCType remainder)
945 if (parameters.reflectInput)
947 CRCType polynomial = CRC::Reflect(parameters.polynomial, CRCWidth);
948 remainder =
static_cast<CRCType
>(remainder ^ byte);
953#ifdef CRCPP_BRANCHLESS
959 remainder =
static_cast<CRCType
>((remainder >> 1) ^ ((remainder & 1) * polynomial));
961 remainder =
static_cast<CRCType
>((remainder & 1) ? ((remainder >> 1) ^ polynomial) : (remainder >> 1));
965 else if (CRCWidth >= CHAR_BIT)
967 static crcpp_constexpr CRCType CRC_WIDTH_MINUS_ONE(CRCWidth - CRCType(1));
968#ifndef CRCPP_BRANCHLESS
969 static crcpp_constexpr CRCType CRC_HIGHEST_BIT_MASK(CRCType(1) << CRC_WIDTH_MINUS_ONE);
972 static crcpp_constexpr CRCType SHIFT((CRCWidth >= CHAR_BIT) ?
static_cast<CRCType
>(CRCWidth - CHAR_BIT) : 0);
974 remainder =
static_cast<CRCType
>(remainder ^ (
static_cast<CRCType
>(byte) << SHIFT));
979#ifdef CRCPP_BRANCHLESS
985 remainder =
static_cast<CRCType
>((remainder << 1) ^ (((remainder >> CRC_WIDTH_MINUS_ONE) & 1) * parameters.polynomial));
987 remainder =
static_cast<CRCType
>((remainder & CRC_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ parameters.polynomial) : (remainder << 1));
994#ifndef CRCPP_BRANCHLESS
995 static crcpp_constexpr CRCType CHAR_BIT_HIGHEST_BIT_MASK(CRCType(1) << CHAR_BIT_MINUS_ONE);
998 static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ?
static_cast<CRCType
>(CHAR_BIT - CRCWidth) : 0);
1000 CRCType polynomial =
static_cast<CRCType
>(parameters.polynomial << SHIFT);
1001 remainder =
static_cast<CRCType
>((remainder << SHIFT) ^
byte);
1006#ifdef CRCPP_BRANCHLESS
1012 remainder =
static_cast<CRCType
>((remainder << 1) ^ (((remainder >> CHAR_BIT_MINUS_ONE) & 1) * polynomial));
1014 remainder =
static_cast<CRCType
>((remainder & CHAR_BIT_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ polynomial) : (remainder << 1));
1018 remainder =
static_cast<CRCType
>(remainder >> SHIFT);
1024#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
1039 static const Parameters<crcpp_uint8, 4> parameters = { 0x3, 0x0, 0x0,
true,
true };
1057 static const Parameters<crcpp_uint8, 5> parameters = { 0x09, 0x09, 0x00,
false,
false };
1075 static const Parameters<crcpp_uint8, 5> parameters = { 0x15, 0x00, 0x00,
true,
true };
1093 static const Parameters<crcpp_uint8, 5> parameters = { 0x05, 0x1F, 0x1F,
true,
true };
1111 static const Parameters<crcpp_uint8, 6> parameters = { 0x27, 0x3F, 0x00,
false,
false };
1129 static const Parameters<crcpp_uint8, 6> parameters = { 0x07, 0x3F, 0x00,
false,
false };
1147 static const Parameters<crcpp_uint8, 6> parameters = { 0x03, 0x00, 0x00,
true,
true };
1166 static const Parameters<crcpp_uint8, 6> parameters = { 0x21, 0x00, 0x00,
false,
false };
1184 static const Parameters<crcpp_uint8, 7> parameters = { 0x09, 0x00, 0x00,
false,
false };
1207#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
1222 static const Parameters<crcpp_uint8, 8> parameters = { 0x1D, 0xFF, 0x00,
true,
true };
1240 static const Parameters<crcpp_uint8, 8> parameters = { 0x07, 0xFF, 0xFF,
true,
true };
1258 static const Parameters<crcpp_uint8, 8> parameters = { 0x31, 0x00, 0x00,
true,
true };
1276 static const Parameters<crcpp_uint8, 8> parameters = { 0x9B, 0x00, 0x00,
true,
true };
1294 static const Parameters<crcpp_uint8, 8> parameters = { 0x9B, 0x00, 0x00,
false,
false };
1312 static const Parameters<crcpp_uint16, 10> parameters = { 0x233, 0x000, 0x000,
false,
false };
1330 static const Parameters<crcpp_uint16, 10> parameters = { 0x3D9, 0x3FF, 0x000,
false,
false };
1348 static const Parameters<crcpp_uint16, 11> parameters = { 0x385, 0x01A, 0x000,
false,
false };
1367 static const Parameters<crcpp_uint16, 11> parameters = { 0x621, 0x000, 0x000,
false,
false };
1385 static const Parameters<crcpp_uint16, 12> parameters = { 0xF13, 0xFFF, 0x000,
false,
false };
1403 static const Parameters<crcpp_uint16, 12> parameters = { 0x80F, 0x000, 0x000,
false,
false };
1421 static const Parameters<crcpp_uint16, 12> parameters = { 0x80F, 0x000, 0x000,
false,
true };
1439 static const Parameters<crcpp_uint16, 13> parameters = { 0x1CF5, 0x0000, 0x0000,
false,
false };
1457 static const Parameters<crcpp_uint16, 15> parameters = { 0x4599, 0x0000, 0x0000,
false,
false };
1475 static const Parameters<crcpp_uint16, 15> parameters = { 0x6815, 0x0000, 0x0001,
false,
false };
1552#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
1567 static const Parameters<crcpp_uint16, 16> parameters = { 0xC867, 0xFFFF, 0x0000,
false,
false };
1585 static const Parameters<crcpp_uint16, 16> parameters = { 0x8005, 0xFFFF, 0x0000,
false,
false };
1603 static const Parameters<crcpp_uint16, 16> parameters = { 0x0589, 0x0000, 0x0001,
false,
false };
1621 static const Parameters<crcpp_uint16, 16> parameters = { 0x0589, 0x0000, 0x0000,
false,
false };
1639 static const Parameters<crcpp_uint16, 16> parameters = { 0x3D65, 0x0000, 0xFFFF,
true,
true };
1680#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
1695 static const Parameters<crcpp_uint16, 16> parameters = { 0x8005, 0x0000, 0xFFFF,
true,
true };
1713 static const Parameters<crcpp_uint16, 16> parameters = { 0x8005, 0xFFFF, 0x0000,
true,
true };
1731 static const Parameters<crcpp_uint16, 16> parameters = { 0x8BB7, 0x0000, 0x0000,
false,
false };
1749 static const Parameters<crcpp_uint16, 16> parameters = { 0x8005, 0xFFFF, 0xFFFF,
true,
true };
1791#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
1806 static const Parameters<crcpp_uint32, 17> parameters = { 0x1685B, 0x00000, 0x00000,
false,
false };
1824 static const Parameters<crcpp_uint32, 21> parameters = { 0x102899, 0x000000, 0x000000,
false,
false };
1842 static const Parameters<crcpp_uint32, 24> parameters = { 0x864CFB, 0xB704CE, 0x000000,
false,
false };
1860 static const Parameters<crcpp_uint32, 24> parameters = { 0x5D6DCB, 0xFEDCBA, 0x000000,
false,
false };
1878 static const Parameters<crcpp_uint32, 24> parameters = { 0x5D6DCB, 0xABCDEF, 0x000000,
false,
false };
1897 static const Parameters<crcpp_uint32, 24> parameters = { 0x864CFB, 0x000000, 0x000000,
false,
false };
1916 static const Parameters<crcpp_uint32, 24> parameters = { 0x800063, 0x000000, 0x000000,
false,
false };
1935 static const Parameters<crcpp_uint32, 24> parameters = { 0xB2B117, 0x000000, 0x000000,
false,
false };
1953 static const Parameters<crcpp_uint32, 30> parameters = { 0x2030B9C7, 0x3FFFFFFF, 0x00000000,
false,
false };
1994#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
2009 static const Parameters<crcpp_uint32, 32> parameters = { 0x1EDC6F41, 0xFFFFFFFF, 0xFFFFFFFF,
true,
true };
2050#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
2065 static const Parameters<crcpp_uint32, 32> parameters = { 0x814141AB, 0x00000000, 0x00000000,
false,
false };
2083 static const Parameters<crcpp_uint64, 40> parameters = { 0x0004820009, 0x0000000000, 0xFFFFFFFFFF,
false,
false };
2101 static const Parameters<crcpp_uint64, 64> parameters = { 0x42F0E1EBA9EA3693, 0x0000000000000000, 0x0000000000000000,
false,
false };
2106#ifdef CRCPP_USE_NAMESPACE
2110#if defined(WIN32) || defined(_WIN32) || defined(WINCE)
#define crcpp_constexpr
Compile-time expression definition.
Definition: CRC.h:127
#define crcpp_uint16
Unsigned 16-bit integer definition, used primarily for parameter definitions.
Definition: CRC.h:88
#define crcpp_size
Unsigned size definition, used for specifying data sizes.
Definition: CRC.h:118
Static class for computing CRCs.
Definition: CRC.h:149
static CRCType CalculateBits(const void *data, crcpp_size size, const Parameters< CRCType, CRCWidth > ¶meters)
Computes a CRC.
Definition: CRC.h:550
static const Parameters< crcpp_uint16, 16 > & CRC_16_XMODEM()
Returns a set of parameters for CRC-16 XMODEM (aka CRC-16 ZMODEM, CRC-16 ACORN, CRC-16 LTE).
Definition: CRC.h:1785
static const Parameters< crcpp_uint8, 8 > & CRC_8()
Returns a set of parameters for CRC-8 SMBus.
Definition: CRC.h:1201
static const Parameters< crcpp_uint32, 32 > & CRC_32_MPEG2()
Returns a set of parameters for CRC-32 MPEG-2.
Definition: CRC.h:2026
static const Parameters< crcpp_uint16, 16 > & CRC_16_BUYPASS()
Returns a set of parameters for CRC-16 BUYPASS (aka CRC-16 VERIFONE, CRC-16 UMTS).
Definition: CRC.h:1510
static const Parameters< crcpp_uint16, 16 > & CRC_16_KERMIT()
Returns a set of parameters for CRC-16 KERMIT (aka CRC-16 CCITT, CRC-16 CCITT-TRUE).
Definition: CRC.h:1674
static const Parameters< crcpp_uint16, 16 > & CRC_16_MCRF4XX()
Returns a set of parameters for CRC-16 MCRF4XX.
Definition: CRC.h:1546
static const Parameters< crcpp_uint16, 16 > & CRC_16_GENIBUS()
Returns a set of parameters for CRC-16 GENIBUS (aka CRC-16 EPC, CRC-16 I-CODE, CRC-16 DARC).
Definition: CRC.h:1656
static const Parameters< crcpp_uint32, 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).
Definition: CRC.h:1988
static const Parameters< crcpp_uint16, 16 > & CRC_16_CCITTFALSE()
Returns a set of parameters for CRC-16 CCITT FALSE.
Definition: CRC.h:1528
static const Parameters< crcpp_uint32, 32 > & CRC_32_POSIX()
Returns a set of parameters for CRC-32 POSIX.
Definition: CRC.h:2044
static const Parameters< crcpp_uint16, 16 > & CRC_16_X25()
Returns a set of parameters for CRC-16 X-25 (aka CRC-16 IBM-SDLC, CRC-16 ISO-HDLC,...
Definition: CRC.h:1767
static CRCType Calculate(const void *data, crcpp_size size, const Parameters< CRCType, CRCWidth > ¶meters)
Computes a CRC.
Definition: CRC.h:463
static const Parameters< crcpp_uint16, 16 > & CRC_16_ARC()
Returns a set of parameters for CRC-16 ARC (aka CRC-16 IBM, CRC-16 LHA).
Definition: CRC.h:1492
static const Parameters< crcpp_uint32, 32 > & CRC_32()
Returns a set of parameters for CRC-32 (aka CRC-32 ADCCP, CRC-32 PKZip).
Definition: CRC.h:1970
int i
Definition: decode_rs.h:73
CRC parameters.
Definition: CRC.h:160
Table< CRCType, CRCWidth > MakeTable() const
Returns a CRC lookup table construct using these CRC parameters.
Definition: CRC.h:342
CRCType initialValue
Initial CRC value.
Definition: CRC.h:162
CRCType polynomial
CRC polynomial.
Definition: CRC.h:161
CRCType finalXOR
Value to XOR with the final CRC.
Definition: CRC.h:163
bool reflectInput
true to reflect all input bytes
Definition: CRC.h:164
bool reflectOutput
true to reflect the output CRC (reflection occurs before the final XOR)
Definition: CRC.h:165
CRC lookup table. After construction, the CRC parameters are fixed.
Definition: CRC.h:176
const CRCType * GetTable() const
Gets the CRC table.
Definition: CRC.h:395
const Parameters< CRCType, CRCWidth > & GetParameters() const
Gets the CRC parameters used to construct the CRC table.
Definition: CRC.h:383
CRCType operator[](unsigned char index) const
Gets an entry in the CRC table.
Definition: CRC.h:408
Table(const Parameters< CRCType, CRCWidth > ¶meters)
Constructs a CRC table from a set of CRC parameters.
Definition: CRC.h:355