61#if __cplusplus >= 201103L && !defined(CRCPP_USE_CPP11)
62#define CRCPP_USE_CPP11
77# ifdef CRCPP_USE_CPP11
79# define crcpp_uint8 ::std::uint8_t
82# define crcpp_uint8 uint8_t
87# ifdef CRCPP_USE_CPP11
89# define crcpp_uint16 ::std::uint16_t
92# define crcpp_uint16 uint16_t
97# ifdef CRCPP_USE_CPP11
99# define crcpp_uint32 ::std::uint32_t
102# define crcpp_uint32 uint32_t
107# ifdef CRCPP_USE_CPP11
109# define crcpp_uint64 ::std::uint64_t
112# define crcpp_uint64 uint64_t
117# ifdef CRCPP_USE_CPP11
119# define crcpp_size ::std::size_t
122# define crcpp_size size_t
126#ifdef CRCPP_USE_CPP11
128# define crcpp_constexpr constexpr
131# define crcpp_constexpr const
134#if defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER)
137#pragma warning(disable : 4127)
140#ifdef CRCPP_USE_NAMESPACE
145#ifdef CRCPP_USE_CPP11
152#define CRCPP_MAJOR_VERSION 1
153#define CRCPP_MINOR_VERSION 2
154#define CRCPP_PATCH_VERSION 1
155#define CRCPP_REVISION_VERSION 0
156#define CRCPP_COPYRIGHT "Copyright (c) 2022-2025, Daniel Bahr"
170 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
176 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
192 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
198#ifdef CRCPP_USE_CPP11
206 CRCType
operator[](
unsigned char index)
const;
217 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
220 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
223 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
226 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
229 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
232 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
235 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
238 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
243#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
255#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
277#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
286#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
294#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
307#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
312#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
318#ifdef CRCPP_USE_CPP11
327#ifndef CRCPP_USE_CPP11
333 template <
typename IntegerType>
336 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
337 static CRCType
Finalize(CRCType remainder, CRCType finalXOR,
bool reflectOutput);
339 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
340 static CRCType
UndoFinalize(CRCType remainder, CRCType finalXOR,
bool reflectOutput);
342 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
345 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
348 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
360template <
typename CRCType, crcpp_u
int16 CRCW
idth>
373template <
typename CRCType, crcpp_u
int16 CRCW
idth>
380#ifdef CRCPP_USE_CPP11
387template <
typename CRCType, crcpp_u
int16 CRCW
idth>
401template <
typename CRCType, crcpp_u
int16 CRCW
idth>
413template <
typename CRCType, crcpp_u
int16 CRCW
idth>
426template <
typename CRCType, crcpp_u
int16 CRCW
idth>
437template <
typename CRCType, crcpp_u
int16 CRCW
idth>
441 static crcpp_constexpr CRCType BIT_MASK((CRCType(1) << (CRCWidth - CRCType(1))) |
442 ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1)));
445 static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ?
static_cast<CRCType
>(CHAR_BIT - CRCWidth) : 0);
448 unsigned char byte = 0;
460 if (!
parameters.reflectInput && CRCWidth < CHAR_BIT)
464 crc =
static_cast<CRCType
>(crc << SHIFT);
481template <
typename CRCType, crcpp_u
int16 CRCW
idth>
501template <
typename CRCType, crcpp_u
int16 CRCW
idth>
522template <
typename CRCType, crcpp_u
int16 CRCW
idth>
545template <
typename CRCType, crcpp_u
int16 CRCW
idth>
568template <
typename CRCType, crcpp_u
int16 CRCW
idth>
575 crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
576 if (wholeNumberOfBytes > 0)
581 crcpp_size remainingNumberOfBits = size % CHAR_BIT;
582 if (remainingNumberOfBits != 0)
584 unsigned char lastByte = *(
reinterpret_cast<const unsigned char *
>(data) + wholeNumberOfBytes);
603template <
typename CRCType, crcpp_u
int16 CRCW
idth>
610 crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
611 if (wholeNumberOfBytes > 0)
616 crcpp_size remainingNumberOfBits = size % CHAR_BIT;
617 if (remainingNumberOfBits != 0)
619 unsigned char lastByte = *(
reinterpret_cast<const unsigned char *
>(data) + wholeNumberOfBytes);
637template <
typename CRCType, crcpp_u
int16 CRCW
idth>
646 crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
647 if (wholeNumberOfBytes > 0)
652 crcpp_size remainingNumberOfBits = size % CHAR_BIT;
653 if (remainingNumberOfBits != 0)
655 unsigned char lastByte = *(
reinterpret_cast<const unsigned char *
>(data) + wholeNumberOfBytes);
675template <
typename CRCType, crcpp_u
int16 CRCW
idth>
684 crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
685 if (wholeNumberOfBytes > 0)
690 crcpp_size remainingNumberOfBits = size % CHAR_BIT;
691 if (remainingNumberOfBits > 0)
693 unsigned char lastByte = *(
reinterpret_cast<const unsigned char *
>(data) + wholeNumberOfBytes);
709template <
typename IntegerType>
712 IntegerType reversedValue(0);
716 reversedValue =
static_cast<IntegerType
>((reversedValue << 1) | (value & 1));
717 value =
static_cast<IntegerType
>(value >> 1);
720 return reversedValue;
732template <
typename CRCType, crcpp_u
int16 CRCW
idth>
733inline CRCType
CRC::Finalize(CRCType remainder, CRCType finalXOR,
bool reflectOutput)
736 static crcpp_constexpr CRCType BIT_MASK = (CRCType(1) << (CRCWidth - CRCType(1))) |
737 ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1));
741 remainder =
Reflect(remainder, CRCWidth);
744 return (remainder ^ finalXOR) & BIT_MASK;
764template <
typename CRCType, crcpp_u
int16 CRCW
idth>
768 static crcpp_constexpr CRCType BIT_MASK = (CRCType(1) << (CRCWidth - CRCType(1))) |
769 ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1));
771 crc = (crc & BIT_MASK) ^ finalXOR;
791template <
typename CRCType, crcpp_u
int16 CRCW
idth>
794#ifdef CRCPP_USE_CPP11
797 static_assert(::std::numeric_limits<CRCType>::digits >= CRCWidth,
"CRCType is too small to contain a CRC of width CRCWidth.");
801 enum { static_assert_failed_CRCType_is_too_small_to_contain_a_CRC_of_width_CRCWidth = 1 / (::std::numeric_limits<CRCType>::digits >= CRCWidth ? 1 : 0) };
804 const unsigned char * current =
reinterpret_cast<const unsigned char *
>(data);
813 remainder =
static_cast<CRCType
>(remainder ^ *current++);
818#ifdef CRCPP_BRANCHLESS
824 remainder =
static_cast<CRCType
>((remainder >> 1) ^ ((remainder & 1) * polynomial));
826 remainder =
static_cast<CRCType
>((remainder & 1) ? ((remainder >> 1) ^ polynomial) : (remainder >> 1));
831 else if (CRCWidth >= CHAR_BIT)
833 static crcpp_constexpr CRCType CRC_WIDTH_MINUS_ONE(CRCWidth - CRCType(1));
834#ifndef CRCPP_BRANCHLESS
835 static crcpp_constexpr CRCType CRC_HIGHEST_BIT_MASK(CRCType(1) << CRC_WIDTH_MINUS_ONE);
838 static crcpp_constexpr CRCType SHIFT((CRCWidth >= CHAR_BIT) ?
static_cast<CRCType
>(CRCWidth - CHAR_BIT) : 0);
842 remainder =
static_cast<CRCType
>(remainder ^ (
static_cast<CRCType
>(*current++) << SHIFT));
847#ifdef CRCPP_BRANCHLESS
853 remainder =
static_cast<CRCType
>((remainder << 1) ^ (((remainder >> CRC_WIDTH_MINUS_ONE) & 1) * parameters.
polynomial));
855 remainder =
static_cast<CRCType
>((remainder & CRC_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ parameters.
polynomial) : (remainder << 1));
863#ifndef CRCPP_BRANCHLESS
864 static crcpp_constexpr CRCType CHAR_BIT_HIGHEST_BIT_MASK(CRCType(1) << CHAR_BIT_MINUS_ONE);
867 static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ?
static_cast<CRCType
>(CHAR_BIT - CRCWidth) : 0);
869 CRCType polynomial =
static_cast<CRCType
>(parameters.
polynomial << SHIFT);
870 remainder =
static_cast<CRCType
>(remainder << SHIFT);
874 remainder =
static_cast<CRCType
>(remainder ^ *current++);
879#ifdef CRCPP_BRANCHLESS
885 remainder =
static_cast<CRCType
>((remainder << 1) ^ (((remainder >> CHAR_BIT_MINUS_ONE) & 1) * polynomial));
887 remainder =
static_cast<CRCType
>((remainder & CHAR_BIT_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ polynomial) : (remainder << 1));
892 remainder =
static_cast<CRCType
>(remainder >> SHIFT);
908template <
typename CRCType, crcpp_u
int16 CRCW
idth>
911 const unsigned char * current =
reinterpret_cast<const unsigned char *
>(data);
917#if defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER)
921# pragma warning (push)
922# pragma warning (disable : 4333)
924 remainder =
static_cast<CRCType
>((remainder >> CHAR_BIT) ^ lookupTable[
static_cast<unsigned char>(remainder ^ *current++)]);
925#if defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER)
926# pragma warning (pop)
930 else if (CRCWidth >= CHAR_BIT)
933 static crcpp_constexpr CRCType SHIFT((CRCWidth >= CHAR_BIT) ?
static_cast<CRCType
>(CRCWidth - CHAR_BIT) : 0);
937 remainder =
static_cast<CRCType
>((remainder << CHAR_BIT) ^ lookupTable[static_cast<unsigned char>((remainder >> SHIFT) ^ *current++)]);
943 static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ?
static_cast<CRCType
>(CHAR_BIT - CRCWidth) : 0);
945 remainder =
static_cast<CRCType
>(remainder << SHIFT);
950 remainder = lookupTable[
static_cast<unsigned char>(remainder ^ *current++)];
953 remainder =
static_cast<CRCType
>(remainder >> SHIFT);
959template <
typename CRCType, crcpp_u
int16 CRCW
idth>
967 remainder =
static_cast<CRCType
>(remainder ^ byte);
972#ifdef CRCPP_BRANCHLESS
978 remainder =
static_cast<CRCType
>((remainder >> 1) ^ ((remainder & 1) * polynomial));
980 remainder =
static_cast<CRCType
>((remainder & 1) ? ((remainder >> 1) ^ polynomial) : (remainder >> 1));
984 else if (CRCWidth >= CHAR_BIT)
986 static crcpp_constexpr CRCType CRC_WIDTH_MINUS_ONE(CRCWidth - CRCType(1));
987#ifndef CRCPP_BRANCHLESS
988 static crcpp_constexpr CRCType CRC_HIGHEST_BIT_MASK(CRCType(1) << CRC_WIDTH_MINUS_ONE);
991 static crcpp_constexpr CRCType SHIFT((CRCWidth >= CHAR_BIT) ?
static_cast<CRCType
>(CRCWidth - CHAR_BIT) : 0);
993 remainder =
static_cast<CRCType
>(remainder ^ (
static_cast<CRCType
>(byte) << SHIFT));
998#ifdef CRCPP_BRANCHLESS
1004 remainder =
static_cast<CRCType
>((remainder << 1) ^ (((remainder >> CRC_WIDTH_MINUS_ONE) & 1) * parameters.
polynomial));
1006 remainder =
static_cast<CRCType
>((remainder & CRC_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ parameters.
polynomial) : (remainder << 1));
1013#ifndef CRCPP_BRANCHLESS
1014 static crcpp_constexpr CRCType CHAR_BIT_HIGHEST_BIT_MASK(CRCType(1) << CHAR_BIT_MINUS_ONE);
1017 static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ?
static_cast<CRCType
>(CHAR_BIT - CRCWidth) : 0);
1019 CRCType polynomial =
static_cast<CRCType
>(parameters.
polynomial << SHIFT);
1020 remainder =
static_cast<CRCType
>((remainder << SHIFT) ^ byte);
1025#ifdef CRCPP_BRANCHLESS
1031 remainder =
static_cast<CRCType
>((remainder << 1) ^ (((remainder >> CHAR_BIT_MINUS_ONE) & 1) * polynomial));
1033 remainder =
static_cast<CRCType
>((remainder & CHAR_BIT_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ polynomial) : (remainder << 1));
1037 remainder =
static_cast<CRCType
>(remainder >> SHIFT);
1043#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
1226#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
1589#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
1717#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
1828#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
2031#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
2087#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
2143#ifdef CRCPP_USE_NAMESPACE
2147#if defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER)
crcpp_constexpr int CRCPP_PATCH_VERSION
Definition CRC.h:148
crcpp_constexpr int CRCPP_MAJOR_VERSION
Definition CRC.h:146
crcpp_constexpr char CRCPP_COPYRIGHT[]
Definition CRC.h:150
crcpp_constexpr int CRCPP_MINOR_VERSION
Definition CRC.h:147
#define crcpp_constexpr
Compile-time expression definition.
Definition CRC.h:128
#define crcpp_uint16
Unsigned 16-bit integer definition, used primarily for parameter definitions.
Definition CRC.h:89
crcpp_constexpr int CRCPP_REVISION_VERSION
Definition CRC.h:149
#define crcpp_size
Unsigned size definition, used for specifying data sizes.
Definition CRC.h:119
static CRCType CalculateBits(const void *data, crcpp_size size, const Parameters< CRCType, CRCWidth > ¶meters)
Computes a CRC.
Definition CRC.h:569
CRC(const CRC &other)=delete
static const Parameters< crcpp_uint16, 12 > & CRC_12_DECT()
Returns a set of parameters for CRC-12 DECT (aka CRC-12 X-CRC).
Definition CRC.h:1438
static const Parameters< crcpp_uint32, 24 > & CRC_24_NRC()
Returns a set of parameters for CRC-24 NR-C.
Definition CRC.h:1970
static const Parameters< crcpp_uint32, 24 > & CRC_24_FLEXRAYB()
Returns a set of parameters for CRC-24 FlexRay-B.
Definition CRC.h:1913
static const Parameters< crcpp_uint32, 24 > & CRC_24_LTEB()
Returns a set of parameters for CRC-24 LTE-B/NR-B.
Definition CRC.h:1951
static const Parameters< crcpp_uint16, 10 > & CRC_10()
Returns a set of parameters for CRC-10 ITU.
Definition CRC.h:1347
static const Parameters< crcpp_uint8, 6 > & CRC_6_ITU()
Returns a set of parameters for CRC-6 ITU.
Definition CRC.h:1164
static const Parameters< crcpp_uint8, 7 > & CRC_7()
Returns a set of parameters for CRC-7 JEDEC.
Definition CRC.h:1201
static const Parameters< crcpp_uint8, 4 > & CRC_4_ITU()
Returns a set of parameters for CRC-4 ITU.
Definition CRC.h:1056
CRC & operator=(const CRC &other)=delete
static const Parameters< crcpp_uint8, 5 > & CRC_5_EPC()
Returns a set of parameters for CRC-5 EPC.
Definition CRC.h:1074
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:1822
static CRCType CalculateRemainderBits(unsigned char byte, crcpp_size numBits, const Parameters< CRCType, CRCWidth > ¶meters, CRCType remainder)
Definition CRC.h:960
static const Parameters< crcpp_uint32, 30 > & CRC_30()
Returns a set of parameters for CRC-30 CDMA.
Definition CRC.h:1988
static const Parameters< crcpp_uint16, 16 > & CRC_16_DECTR()
Returns a set of parameters for CRC-16 DECT-R (aka CRC-16 R-CRC).
Definition CRC.h:1638
static const Parameters< crcpp_uint32, 17 > & CRC_17_CAN()
Returns a set of parameters for CRC-17 CAN.
Definition CRC.h:1841
static const Parameters< crcpp_uint8, 8 > & CRC_8()
Returns a set of parameters for CRC-8 SMBus.
Definition CRC.h:1220
static const Parameters< crcpp_uint32, 24 > & CRC_24()
Returns a set of parameters for CRC-24 OPENPGP.
Definition CRC.h:1877
static const Parameters< crcpp_uint16, 15 > & CRC_15_MPT1327()
Returns a set of parameters for CRC-15 MPT1327.
Definition CRC.h:1510
static const Parameters< crcpp_uint32, 32 > & CRC_32_MPEG2()
Returns a set of parameters for CRC-32 MPEG-2.
Definition CRC.h:2063
static CRCType UndoFinalize(CRCType remainder, CRCType finalXOR, bool reflectOutput)
Undoes the process of computing the final reflection and XOR of a CRC remainder.
Definition CRC.h:765
static const Parameters< crcpp_uint32, 24 > & CRC_24_FLEXRAYA()
Returns a set of parameters for CRC-24 FlexRay-A.
Definition CRC.h:1895
static const Parameters< crcpp_uint16, 16 > & CRC_16_MAXIM()
Returns a set of parameters for CRC-16 MAXIM.
Definition CRC.h:1730
static const Parameters< crcpp_uint32, 32 > & CRC_32_C()
Returns a set of parameters for CRC-32 C (aka CRC-32 ISCSI, CRC-32 Castagnoli, CRC-32 Interlaken).
Definition CRC.h:2044
static const Parameters< crcpp_uint16, 13 > & CRC_13_BBC()
Returns a set of parameters for CRC-13 BBC.
Definition CRC.h:1474
static const Parameters< crcpp_uint8, 8 > & CRC_8_MAXIM()
Returns a set of parameters for CRC-8 MAXIM (aka CRC-8 DOW-CRC).
Definition CRC.h:1275
static const Parameters< crcpp_uint8, 8 > & CRC_8_HDLC()
Returns a set of parameters for CRC-8 HDLC (ISO/IEC 13239:2002).
Definition CRC.h:1257
static const Parameters< crcpp_uint8, 8 > & CRC_8_WCDMA()
Returns a set of parameters for CRC-8 WCDMA.
Definition CRC.h:1293
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:1547
static CRCType CalculateRemainder(const void *data, crcpp_size size, const Parameters< CRCType, CRCWidth > ¶meters, CRCType remainder)
Computes a CRC remainder.
Definition CRC.h:792
static const Parameters< crcpp_uint8, 6 > & CRC_6_NR()
Returns a set of parameters for CRC-6 NR.
Definition CRC.h:1183
static const Parameters< crcpp_uint32, 24 > & CRC_24_LTEA()
Returns a set of parameters for CRC-24 LTE-A/NR-A.
Definition CRC.h:1932
static const Parameters< crcpp_uint16, 15 > & CRC_15()
Returns a set of parameters for CRC-15 CAN.
Definition CRC.h:1492
static const Parameters< crcpp_uint16, 16 > & CRC_16_DECTX()
Returns a set of parameters for CRC-16 DECT-X (aka CRC-16 X-CRC).
Definition CRC.h:1656
static const Parameters< crcpp_uint32, 21 > & CRC_21_CAN()
Returns a set of parameters for CRC-21 CAN.
Definition CRC.h:1859
static const Parameters< crcpp_uint16, 12 > & CRC_12_UMTS()
Returns a set of parameters for CRC-12 UMTS (aka CRC-12 3GPP).
Definition CRC.h:1456
static const Parameters< crcpp_uint16, 16 > & CRC_16_CMS()
Returns a set of parameters for CRC-16 CMS.
Definition CRC.h:1620
static const Parameters< crcpp_uint16, 10 > & CRC_10_CDMA2000()
Returns a set of parameters for CRC-10 CDMA2000.
Definition CRC.h:1365
CRC & operator=(CRC &&other)=delete
static const Parameters< crcpp_uint8, 6 > & CRC_6_CDMA2000B()
Returns a set of parameters for CRC-6 CDMA2000-B.
Definition CRC.h:1146
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:1711
static const Parameters< crcpp_uint16, 11 > & CRC_11()
Returns a set of parameters for CRC-11 FlexRay.
Definition CRC.h:1383
static const Parameters< crcpp_uint32, 32 > & CRC_32_Q()
Returns a set of parameters for CRC-32 Q.
Definition CRC.h:2100
static const Parameters< crcpp_uint16, 16 > & CRC_16_T10DIF()
Returns a set of parameters for CRC-16 T10-DIF.
Definition CRC.h:1766
static const Parameters< crcpp_uint16, 16 > & CRC_16_MCRF4XX()
Returns a set of parameters for CRC-16 MCRF4XX.
Definition CRC.h:1583
static const Parameters< crcpp_uint16, 12 > & CRC_12_CDMA2000()
Returns a set of parameters for CRC-12 CDMA2000.
Definition CRC.h:1420
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:1693
static IntegerType Reflect(IntegerType value, crcpp_uint16 numBits)
Reflects (i.e. reverses the bits within) an integer value.
Definition CRC.h:710
static const Parameters< crcpp_uint8, 8 > & CRC_8_EBU()
Returns a set of parameters for CRC-8 EBU (aka CRC-8 AES).
Definition CRC.h:1239
static const Parameters< crcpp_uint8, 5 > & CRC_5_USB()
Returns a set of parameters for CRC-5 USB.
Definition CRC.h:1110
static const Parameters< crcpp_uint16, 16 > & CRC_16_USB()
Returns a set of parameters for CRC-16 USB.
Definition CRC.h:1784
static const Parameters< crcpp_uint16, 16 > & CRC_16_MODBUS()
Returns a set of parameters for CRC-16 MODBUS.
Definition CRC.h:1748
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:2025
static const Parameters< crcpp_uint16, 16 > & CRC_16_CDMA2000()
Returns a set of parameters for CRC-16 CDMA2000.
Definition CRC.h:1602
static const Parameters< crcpp_uint16, 16 > & CRC_16_CCITTFALSE()
Returns a set of parameters for CRC-16 CCITT FALSE.
Definition CRC.h:1565
static const Parameters< crcpp_uint32, 32 > & CRC_32_POSIX()
Returns a set of parameters for CRC-32 POSIX.
Definition CRC.h:2081
static const Parameters< crcpp_uint16, 11 > & CRC_11_NR()
Returns a set of parameters for CRC-11 NR.
Definition CRC.h:1402
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:1804
static const Parameters< crcpp_uint8, 6 > & CRC_6_CDMA2000A()
Returns a set of parameters for CRC-6 CDMA2000-A.
Definition CRC.h:1128
static const Parameters< crcpp_uint8, 5 > & CRC_5_ITU()
Returns a set of parameters for CRC-5 ITU.
Definition CRC.h:1092
static const Parameters< crcpp_uint8, 8 > & CRC_8_LTE()
Returns a set of parameters for CRC-8 LTE.
Definition CRC.h:1311
static const Parameters< crcpp_uint8, 8 > & CRC_8_NRSC5()
Returns a set of parameters for CRC-8 NRSC-5.
Definition CRC.h:1329
static CRCType Calculate(const void *data, crcpp_size size, const Parameters< CRCType, CRCWidth > ¶meters)
Computes a CRC.
Definition CRC.h:482
static const Parameters< crcpp_uint16, 16 > & CRC_16_DNP()
Returns a set of parameters for CRC-16 DNP.
Definition CRC.h:1674
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:1529
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:2007
static const Parameters< crcpp_uint64, 64 > & CRC_64()
Returns a set of parameters for CRC-64 ECMA.
Definition CRC.h:2136
static CRCType Finalize(CRCType remainder, CRCType finalXOR, bool reflectOutput)
Computes the final reflection and XOR of a CRC remainder.
Definition CRC.h:733
static const Parameters< crcpp_uint64, 40 > & CRC_40_GSM()
Returns a set of parameters for CRC-40 GSM.
Definition CRC.h:2118
CRC parameters.
Definition CRC.h:178
Table< CRCType, CRCWidth > MakeTable() const
Returns a CRC lookup table construct using these CRC parameters.
Definition CRC.h:361
CRCType initialValue
Initial CRC value.
Definition CRC.h:180
CRCType polynomial
CRC polynomial.
Definition CRC.h:179
CRCType finalXOR
Value to XOR with the final CRC.
Definition CRC.h:181
bool reflectInput
true to reflect all input bytes
Definition CRC.h:182
bool reflectOutput
true to reflect the output CRC (reflection occurs before the final XOR)
Definition CRC.h:183
CRC lookup table. After construction, the CRC parameters are fixed.
Definition CRC.h:194
const CRCType * GetTable() const
Gets the CRC table.
Definition CRC.h:414
const Parameters< CRCType, CRCWidth > & GetParameters() const
Gets the CRC parameters used to construct the CRC table.
Definition CRC.h:402
CRCType operator[](unsigned char index) const
Gets an entry in the CRC table.
Definition CRC.h:427
Table(const Parameters< CRCType, CRCWidth > ¶meters)
Constructs a CRC table from a set of CRC parameters.
Definition CRC.h:374
CRCType table[1<< CHAR_BIT]
CRC lookup table.
Definition CRC.h:212
void InitTable()
Initializes a CRC table.
Definition CRC.h:438
Parameters< CRCType, CRCWidth > parameters
CRC parameters used to construct the table.
Definition CRC.h:211