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 2
155#define CRCPP_REVISION_VERSION 0
156#define CRCPP_COPYRIGHT "Copyright (c) 2022-2026, 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>
502template <
typename CRCType, crcpp_u
int16 CRCW
idth>
523template <
typename CRCType, crcpp_u
int16 CRCW
idth>
547template <
typename CRCType, crcpp_u
int16 CRCW
idth>
570template <
typename CRCType, crcpp_u
int16 CRCW
idth>
577 crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
578 if (wholeNumberOfBytes > 0)
583 crcpp_size remainingNumberOfBits = size % CHAR_BIT;
584 if (remainingNumberOfBits != 0)
586 unsigned char lastByte = *(
reinterpret_cast<const unsigned char *
>(data) + wholeNumberOfBytes);
605template <
typename CRCType, crcpp_u
int16 CRCW
idth>
612 crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
613 if (wholeNumberOfBytes > 0)
618 crcpp_size remainingNumberOfBits = size % CHAR_BIT;
619 if (remainingNumberOfBits != 0)
621 unsigned char lastByte = *(
reinterpret_cast<const unsigned char *
>(data) + wholeNumberOfBytes);
639template <
typename CRCType, crcpp_u
int16 CRCW
idth>
648 crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
649 if (wholeNumberOfBytes > 0)
654 crcpp_size remainingNumberOfBits = size % CHAR_BIT;
655 if (remainingNumberOfBits != 0)
657 unsigned char lastByte = *(
reinterpret_cast<const unsigned char *
>(data) + wholeNumberOfBytes);
677template <
typename CRCType, crcpp_u
int16 CRCW
idth>
686 crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
687 if (wholeNumberOfBytes > 0)
692 crcpp_size remainingNumberOfBits = size % CHAR_BIT;
693 if (remainingNumberOfBits > 0)
695 unsigned char lastByte = *(
reinterpret_cast<const unsigned char *
>(data) + wholeNumberOfBytes);
711template <
typename IntegerType>
714 IntegerType reversedValue(0);
718 reversedValue =
static_cast<IntegerType
>((reversedValue << 1) | (value & 1));
719 value =
static_cast<IntegerType
>(value >> 1);
722 return reversedValue;
734template <
typename CRCType, crcpp_u
int16 CRCW
idth>
735inline CRCType
CRC::Finalize(CRCType remainder, CRCType finalXOR,
bool reflectOutput)
738 static crcpp_constexpr CRCType BIT_MASK = (CRCType(1) << (CRCWidth - CRCType(1))) |
739 ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1));
743 remainder =
Reflect(remainder, CRCWidth);
746 return (remainder ^ finalXOR) & BIT_MASK;
766template <
typename CRCType, crcpp_u
int16 CRCW
idth>
770 static crcpp_constexpr CRCType BIT_MASK = (CRCType(1) << (CRCWidth - CRCType(1))) |
771 ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1));
773 crc = (crc & BIT_MASK) ^ finalXOR;
793template <
typename CRCType, crcpp_u
int16 CRCW
idth>
796#ifdef CRCPP_USE_CPP11
799 static_assert(::std::numeric_limits<CRCType>::digits >= CRCWidth,
"CRCType is too small to contain a CRC of width CRCWidth.");
803 enum { static_assert_failed_CRCType_is_too_small_to_contain_a_CRC_of_width_CRCWidth = 1 / (::std::numeric_limits<CRCType>::digits >= CRCWidth ? 1 : 0) };
806 const unsigned char * current =
reinterpret_cast<const unsigned char *
>(data);
815 remainder =
static_cast<CRCType
>(remainder ^ *current++);
820#ifdef CRCPP_BRANCHLESS
826 remainder =
static_cast<CRCType
>((remainder >> 1) ^ ((remainder & 1) * polynomial));
828 remainder =
static_cast<CRCType
>((remainder & 1) ? ((remainder >> 1) ^ polynomial) : (remainder >> 1));
833 else if (CRCWidth >= CHAR_BIT)
835 static crcpp_constexpr CRCType CRC_WIDTH_MINUS_ONE(CRCWidth - CRCType(1));
836#ifndef CRCPP_BRANCHLESS
837 static crcpp_constexpr CRCType CRC_HIGHEST_BIT_MASK(CRCType(1) << CRC_WIDTH_MINUS_ONE);
840 static crcpp_constexpr CRCType SHIFT((CRCWidth >= CHAR_BIT) ?
static_cast<CRCType
>(CRCWidth - CHAR_BIT) : 0);
844 remainder =
static_cast<CRCType
>(remainder ^ (
static_cast<CRCType
>(*current++) << SHIFT));
849#ifdef CRCPP_BRANCHLESS
855 remainder =
static_cast<CRCType
>((remainder << 1) ^ (((remainder >> CRC_WIDTH_MINUS_ONE) & 1) * parameters.
polynomial));
857 remainder =
static_cast<CRCType
>((remainder & CRC_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ parameters.
polynomial) : (remainder << 1));
865#ifndef CRCPP_BRANCHLESS
866 static crcpp_constexpr CRCType CHAR_BIT_HIGHEST_BIT_MASK(CRCType(1) << CHAR_BIT_MINUS_ONE);
869 static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ?
static_cast<CRCType
>(CHAR_BIT - CRCWidth) : 0);
871 CRCType polynomial =
static_cast<CRCType
>(parameters.
polynomial << SHIFT);
872 remainder =
static_cast<CRCType
>(remainder << SHIFT);
876 remainder =
static_cast<CRCType
>(remainder ^ *current++);
881#ifdef CRCPP_BRANCHLESS
887 remainder =
static_cast<CRCType
>((remainder << 1) ^ (((remainder >> CHAR_BIT_MINUS_ONE) & 1) * polynomial));
889 remainder =
static_cast<CRCType
>((remainder & CHAR_BIT_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ polynomial) : (remainder << 1));
894 remainder =
static_cast<CRCType
>(remainder >> SHIFT);
910template <
typename CRCType, crcpp_u
int16 CRCW
idth>
913 const unsigned char * current =
reinterpret_cast<const unsigned char *
>(data);
919#if defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER)
923# pragma warning (push)
924# pragma warning (disable : 4333)
926 remainder =
static_cast<CRCType
>((remainder >> CHAR_BIT) ^ lookupTable[
static_cast<unsigned char>(remainder ^ *current++)]);
927#if defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER)
928# pragma warning (pop)
932 else if (CRCWidth >= CHAR_BIT)
935 static crcpp_constexpr CRCType SHIFT((CRCWidth >= CHAR_BIT) ?
static_cast<CRCType
>(CRCWidth - CHAR_BIT) : 0);
939 remainder =
static_cast<CRCType
>((remainder << CHAR_BIT) ^ lookupTable[static_cast<unsigned char>((remainder >> SHIFT) ^ *current++)]);
945 static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ?
static_cast<CRCType
>(CHAR_BIT - CRCWidth) : 0);
947 remainder =
static_cast<CRCType
>(remainder << SHIFT);
952 remainder = lookupTable[
static_cast<unsigned char>(remainder ^ *current++)];
955 remainder =
static_cast<CRCType
>(remainder >> SHIFT);
961template <
typename CRCType, crcpp_u
int16 CRCW
idth>
969 remainder =
static_cast<CRCType
>(remainder ^ byte);
974#ifdef CRCPP_BRANCHLESS
980 remainder =
static_cast<CRCType
>((remainder >> 1) ^ ((remainder & 1) * polynomial));
982 remainder =
static_cast<CRCType
>((remainder & 1) ? ((remainder >> 1) ^ polynomial) : (remainder >> 1));
986 else if (CRCWidth >= CHAR_BIT)
988 static crcpp_constexpr CRCType CRC_WIDTH_MINUS_ONE(CRCWidth - CRCType(1));
989#ifndef CRCPP_BRANCHLESS
990 static crcpp_constexpr CRCType CRC_HIGHEST_BIT_MASK(CRCType(1) << CRC_WIDTH_MINUS_ONE);
993 static crcpp_constexpr CRCType SHIFT((CRCWidth >= CHAR_BIT) ?
static_cast<CRCType
>(CRCWidth - CHAR_BIT) : 0);
995 remainder =
static_cast<CRCType
>(remainder ^ (
static_cast<CRCType
>(byte) << SHIFT));
1000#ifdef CRCPP_BRANCHLESS
1006 remainder =
static_cast<CRCType
>((remainder << 1) ^ (((remainder >> CRC_WIDTH_MINUS_ONE) & 1) * parameters.
polynomial));
1008 remainder =
static_cast<CRCType
>((remainder & CRC_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ parameters.
polynomial) : (remainder << 1));
1015#ifndef CRCPP_BRANCHLESS
1016 static crcpp_constexpr CRCType CHAR_BIT_HIGHEST_BIT_MASK(CRCType(1) << CHAR_BIT_MINUS_ONE);
1019 static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ?
static_cast<CRCType
>(CHAR_BIT - CRCWidth) : 0);
1021 CRCType polynomial =
static_cast<CRCType
>(parameters.
polynomial << SHIFT);
1022 remainder =
static_cast<CRCType
>((remainder << SHIFT) ^ byte);
1027#ifdef CRCPP_BRANCHLESS
1033 remainder =
static_cast<CRCType
>((remainder << 1) ^ (((remainder >> CHAR_BIT_MINUS_ONE) & 1) * polynomial));
1035 remainder =
static_cast<CRCType
>((remainder & CHAR_BIT_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ polynomial) : (remainder << 1));
1039 remainder =
static_cast<CRCType
>(remainder >> SHIFT);
1045#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
1228#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
1591#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
1719#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
1830#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
2033#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
2089#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
2145#ifdef CRCPP_USE_NAMESPACE
2149#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:571
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:1440
static const Parameters< crcpp_uint32, 24 > & CRC_24_NRC()
Returns a set of parameters for CRC-24 NR-C.
Definition CRC.h:1972
static const Parameters< crcpp_uint32, 24 > & CRC_24_FLEXRAYB()
Returns a set of parameters for CRC-24 FlexRay-B.
Definition CRC.h:1915
static const Parameters< crcpp_uint32, 24 > & CRC_24_LTEB()
Returns a set of parameters for CRC-24 LTE-B/NR-B.
Definition CRC.h:1953
static const Parameters< crcpp_uint16, 10 > & CRC_10()
Returns a set of parameters for CRC-10 ITU.
Definition CRC.h:1349
static const Parameters< crcpp_uint8, 6 > & CRC_6_ITU()
Returns a set of parameters for CRC-6 ITU.
Definition CRC.h:1166
static const Parameters< crcpp_uint8, 7 > & CRC_7()
Returns a set of parameters for CRC-7 JEDEC.
Definition CRC.h:1203
static const Parameters< crcpp_uint8, 4 > & CRC_4_ITU()
Returns a set of parameters for CRC-4 ITU.
Definition CRC.h:1058
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:1076
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:1824
static CRCType CalculateRemainderBits(unsigned char byte, crcpp_size numBits, const Parameters< CRCType, CRCWidth > ¶meters, CRCType remainder)
Definition CRC.h:962
static const Parameters< crcpp_uint32, 30 > & CRC_30()
Returns a set of parameters for CRC-30 CDMA.
Definition CRC.h:1990
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:1640
static const Parameters< crcpp_uint32, 17 > & CRC_17_CAN()
Returns a set of parameters for CRC-17 CAN.
Definition CRC.h:1843
static const Parameters< crcpp_uint8, 8 > & CRC_8()
Returns a set of parameters for CRC-8 SMBus.
Definition CRC.h:1222
static const Parameters< crcpp_uint32, 24 > & CRC_24()
Returns a set of parameters for CRC-24 OPENPGP.
Definition CRC.h:1879
static const Parameters< crcpp_uint16, 15 > & CRC_15_MPT1327()
Returns a set of parameters for CRC-15 MPT1327.
Definition CRC.h:1512
static const Parameters< crcpp_uint32, 32 > & CRC_32_MPEG2()
Returns a set of parameters for CRC-32 MPEG-2.
Definition CRC.h:2065
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:767
static const Parameters< crcpp_uint32, 24 > & CRC_24_FLEXRAYA()
Returns a set of parameters for CRC-24 FlexRay-A.
Definition CRC.h:1897
static const Parameters< crcpp_uint16, 16 > & CRC_16_MAXIM()
Returns a set of parameters for CRC-16 MAXIM.
Definition CRC.h:1732
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:2046
static const Parameters< crcpp_uint16, 13 > & CRC_13_BBC()
Returns a set of parameters for CRC-13 BBC.
Definition CRC.h:1476
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:1277
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:1259
static const Parameters< crcpp_uint8, 8 > & CRC_8_WCDMA()
Returns a set of parameters for CRC-8 WCDMA.
Definition CRC.h:1295
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:1549
static CRCType CalculateRemainder(const void *data, crcpp_size size, const Parameters< CRCType, CRCWidth > ¶meters, CRCType remainder)
Computes a CRC remainder.
Definition CRC.h:794
static const Parameters< crcpp_uint8, 6 > & CRC_6_NR()
Returns a set of parameters for CRC-6 NR.
Definition CRC.h:1185
static const Parameters< crcpp_uint32, 24 > & CRC_24_LTEA()
Returns a set of parameters for CRC-24 LTE-A/NR-A.
Definition CRC.h:1934
static const Parameters< crcpp_uint16, 15 > & CRC_15()
Returns a set of parameters for CRC-15 CAN.
Definition CRC.h:1494
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:1658
static const Parameters< crcpp_uint32, 21 > & CRC_21_CAN()
Returns a set of parameters for CRC-21 CAN.
Definition CRC.h:1861
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:1458
static const Parameters< crcpp_uint16, 16 > & CRC_16_CMS()
Returns a set of parameters for CRC-16 CMS.
Definition CRC.h:1622
static const Parameters< crcpp_uint16, 10 > & CRC_10_CDMA2000()
Returns a set of parameters for CRC-10 CDMA2000.
Definition CRC.h:1367
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:1148
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:1713
static const Parameters< crcpp_uint16, 11 > & CRC_11()
Returns a set of parameters for CRC-11 FlexRay.
Definition CRC.h:1385
static const Parameters< crcpp_uint32, 32 > & CRC_32_Q()
Returns a set of parameters for CRC-32 Q.
Definition CRC.h:2102
static const Parameters< crcpp_uint16, 16 > & CRC_16_T10DIF()
Returns a set of parameters for CRC-16 T10-DIF.
Definition CRC.h:1768
static const Parameters< crcpp_uint16, 16 > & CRC_16_MCRF4XX()
Returns a set of parameters for CRC-16 MCRF4XX.
Definition CRC.h:1585
static const Parameters< crcpp_uint16, 12 > & CRC_12_CDMA2000()
Returns a set of parameters for CRC-12 CDMA2000.
Definition CRC.h:1422
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:1695
static IntegerType Reflect(IntegerType value, crcpp_uint16 numBits)
Reflects (i.e. reverses the bits within) an integer value.
Definition CRC.h:712
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:1241
static const Parameters< crcpp_uint8, 5 > & CRC_5_USB()
Returns a set of parameters for CRC-5 USB.
Definition CRC.h:1112
static const Parameters< crcpp_uint16, 16 > & CRC_16_USB()
Returns a set of parameters for CRC-16 USB.
Definition CRC.h:1786
static const Parameters< crcpp_uint16, 16 > & CRC_16_MODBUS()
Returns a set of parameters for CRC-16 MODBUS.
Definition CRC.h:1750
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:2027
static const Parameters< crcpp_uint16, 16 > & CRC_16_CDMA2000()
Returns a set of parameters for CRC-16 CDMA2000.
Definition CRC.h:1604
static const Parameters< crcpp_uint16, 16 > & CRC_16_CCITTFALSE()
Returns a set of parameters for CRC-16 CCITT FALSE.
Definition CRC.h:1567
static const Parameters< crcpp_uint32, 32 > & CRC_32_POSIX()
Returns a set of parameters for CRC-32 POSIX.
Definition CRC.h:2083
static const Parameters< crcpp_uint16, 11 > & CRC_11_NR()
Returns a set of parameters for CRC-11 NR.
Definition CRC.h:1404
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:1806
static const Parameters< crcpp_uint8, 6 > & CRC_6_CDMA2000A()
Returns a set of parameters for CRC-6 CDMA2000-A.
Definition CRC.h:1130
static const Parameters< crcpp_uint8, 5 > & CRC_5_ITU()
Returns a set of parameters for CRC-5 ITU.
Definition CRC.h:1094
static const Parameters< crcpp_uint8, 8 > & CRC_8_LTE()
Returns a set of parameters for CRC-8 LTE.
Definition CRC.h:1313
static const Parameters< crcpp_uint8, 8 > & CRC_8_NRSC5()
Returns a set of parameters for CRC-8 NRSC-5.
Definition CRC.h:1331
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:1676
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:1531
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:2009
static const Parameters< crcpp_uint64, 64 > & CRC_64()
Returns a set of parameters for CRC-64 ECMA.
Definition CRC.h:2138
static CRCType Finalize(CRCType remainder, CRCType finalXOR, bool reflectOutput)
Computes the final reflection and XOR of a CRC remainder.
Definition CRC.h:735
static const Parameters< crcpp_uint64, 40 > & CRC_40_GSM()
Returns a set of parameters for CRC-40 GSM.
Definition CRC.h:2120
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