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
276#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
285#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
293#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
306#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
311#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
317#ifdef CRCPP_USE_CPP11
326#ifndef CRCPP_USE_CPP11
332 template <
typename IntegerType>
335 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
336 static CRCType
Finalize(CRCType remainder, CRCType finalXOR,
bool reflectOutput);
338 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
339 static CRCType
UndoFinalize(CRCType remainder, CRCType finalXOR,
bool reflectOutput);
341 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
344 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
347 template <
typename CRCType, crcpp_u
int16 CRCW
idth>
359template <
typename CRCType, crcpp_u
int16 CRCW
idth>
372template <
typename CRCType, crcpp_u
int16 CRCW
idth>
379#ifdef CRCPP_USE_CPP11
386template <
typename CRCType, crcpp_u
int16 CRCW
idth>
400template <
typename CRCType, crcpp_u
int16 CRCW
idth>
412template <
typename CRCType, crcpp_u
int16 CRCW
idth>
425template <
typename CRCType, crcpp_u
int16 CRCW
idth>
436template <
typename CRCType, crcpp_u
int16 CRCW
idth>
440 static crcpp_constexpr CRCType BIT_MASK((CRCType(1) << (CRCWidth - CRCType(1))) |
441 ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1)));
444 static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ?
static_cast<CRCType
>(CHAR_BIT - CRCWidth) : 0);
447 unsigned char byte = 0;
459 if (!
parameters.reflectInput && CRCWidth < CHAR_BIT)
463 crc =
static_cast<CRCType
>(crc << SHIFT);
480template <
typename CRCType, crcpp_u
int16 CRCW
idth>
500template <
typename CRCType, crcpp_u
int16 CRCW
idth>
521template <
typename CRCType, crcpp_u
int16 CRCW
idth>
544template <
typename CRCType, crcpp_u
int16 CRCW
idth>
567template <
typename CRCType, crcpp_u
int16 CRCW
idth>
574 crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
575 if (wholeNumberOfBytes > 0)
580 crcpp_size remainingNumberOfBits = size % CHAR_BIT;
581 if (remainingNumberOfBits != 0)
583 unsigned char lastByte = *(
reinterpret_cast<const unsigned char *
>(data) + wholeNumberOfBytes);
602template <
typename CRCType, crcpp_u
int16 CRCW
idth>
609 crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
610 if (wholeNumberOfBytes > 0)
615 crcpp_size remainingNumberOfBits = size % CHAR_BIT;
616 if (remainingNumberOfBits != 0)
618 unsigned char lastByte = *(
reinterpret_cast<const unsigned char *
>(data) + wholeNumberOfBytes);
636template <
typename CRCType, crcpp_u
int16 CRCW
idth>
645 crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
646 if (wholeNumberOfBytes > 0)
651 crcpp_size remainingNumberOfBits = size % CHAR_BIT;
652 if (remainingNumberOfBits != 0)
654 unsigned char lastByte = *(
reinterpret_cast<const unsigned char *
>(data) + wholeNumberOfBytes);
674template <
typename CRCType, crcpp_u
int16 CRCW
idth>
683 crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
684 if (wholeNumberOfBytes > 0)
689 crcpp_size remainingNumberOfBits = size % CHAR_BIT;
690 if (remainingNumberOfBits > 0)
692 unsigned char lastByte = *(
reinterpret_cast<const unsigned char *
>(data) + wholeNumberOfBytes);
708template <
typename IntegerType>
711 IntegerType reversedValue(0);
715 reversedValue =
static_cast<IntegerType
>((reversedValue << 1) | (value & 1));
716 value =
static_cast<IntegerType
>(value >> 1);
719 return reversedValue;
731template <
typename CRCType, crcpp_u
int16 CRCW
idth>
732inline CRCType
CRC::Finalize(CRCType remainder, CRCType finalXOR,
bool reflectOutput)
735 static crcpp_constexpr CRCType BIT_MASK = (CRCType(1) << (CRCWidth - CRCType(1))) |
736 ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1));
740 remainder =
Reflect(remainder, CRCWidth);
743 return (remainder ^ finalXOR) & BIT_MASK;
763template <
typename CRCType, crcpp_u
int16 CRCW
idth>
767 static crcpp_constexpr CRCType BIT_MASK = (CRCType(1) << (CRCWidth - CRCType(1))) |
768 ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1));
770 crc = (crc & BIT_MASK) ^ finalXOR;
790template <
typename CRCType, crcpp_u
int16 CRCW
idth>
793#ifdef CRCPP_USE_CPP11
796 static_assert(::std::numeric_limits<CRCType>::digits >= CRCWidth,
"CRCType is too small to contain a CRC of width CRCWidth.");
800 enum { static_assert_failed_CRCType_is_too_small_to_contain_a_CRC_of_width_CRCWidth = 1 / (::std::numeric_limits<CRCType>::digits >= CRCWidth ? 1 : 0) };
803 const unsigned char * current =
reinterpret_cast<const unsigned char *
>(data);
812 remainder =
static_cast<CRCType
>(remainder ^ *current++);
817#ifdef CRCPP_BRANCHLESS
823 remainder =
static_cast<CRCType
>((remainder >> 1) ^ ((remainder & 1) * polynomial));
825 remainder =
static_cast<CRCType
>((remainder & 1) ? ((remainder >> 1) ^ polynomial) : (remainder >> 1));
830 else if (CRCWidth >= CHAR_BIT)
832 static crcpp_constexpr CRCType CRC_WIDTH_MINUS_ONE(CRCWidth - CRCType(1));
833#ifndef CRCPP_BRANCHLESS
834 static crcpp_constexpr CRCType CRC_HIGHEST_BIT_MASK(CRCType(1) << CRC_WIDTH_MINUS_ONE);
837 static crcpp_constexpr CRCType SHIFT((CRCWidth >= CHAR_BIT) ?
static_cast<CRCType
>(CRCWidth - CHAR_BIT) : 0);
841 remainder =
static_cast<CRCType
>(remainder ^ (
static_cast<CRCType
>(*current++) << SHIFT));
846#ifdef CRCPP_BRANCHLESS
852 remainder =
static_cast<CRCType
>((remainder << 1) ^ (((remainder >> CRC_WIDTH_MINUS_ONE) & 1) * parameters.
polynomial));
854 remainder =
static_cast<CRCType
>((remainder & CRC_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ parameters.
polynomial) : (remainder << 1));
862#ifndef CRCPP_BRANCHLESS
863 static crcpp_constexpr CRCType CHAR_BIT_HIGHEST_BIT_MASK(CRCType(1) << CHAR_BIT_MINUS_ONE);
866 static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ?
static_cast<CRCType
>(CHAR_BIT - CRCWidth) : 0);
868 CRCType polynomial =
static_cast<CRCType
>(parameters.
polynomial << SHIFT);
869 remainder =
static_cast<CRCType
>(remainder << SHIFT);
873 remainder =
static_cast<CRCType
>(remainder ^ *current++);
878#ifdef CRCPP_BRANCHLESS
884 remainder =
static_cast<CRCType
>((remainder << 1) ^ (((remainder >> CHAR_BIT_MINUS_ONE) & 1) * polynomial));
886 remainder =
static_cast<CRCType
>((remainder & CHAR_BIT_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ polynomial) : (remainder << 1));
891 remainder =
static_cast<CRCType
>(remainder >> SHIFT);
907template <
typename CRCType, crcpp_u
int16 CRCW
idth>
910 const unsigned char * current =
reinterpret_cast<const unsigned char *
>(data);
916#if defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER)
920# pragma warning (push)
921# pragma warning (disable : 4333)
923 remainder =
static_cast<CRCType
>((remainder >> CHAR_BIT) ^ lookupTable[
static_cast<unsigned char>(remainder ^ *current++)]);
924#if defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER)
925# pragma warning (pop)
929 else if (CRCWidth >= CHAR_BIT)
932 static crcpp_constexpr CRCType SHIFT((CRCWidth >= CHAR_BIT) ?
static_cast<CRCType
>(CRCWidth - CHAR_BIT) : 0);
936 remainder =
static_cast<CRCType
>((remainder << CHAR_BIT) ^ lookupTable[static_cast<unsigned char>((remainder >> SHIFT) ^ *current++)]);
942 static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ?
static_cast<CRCType
>(CHAR_BIT - CRCWidth) : 0);
944 remainder =
static_cast<CRCType
>(remainder << SHIFT);
949 remainder = lookupTable[
static_cast<unsigned char>(remainder ^ *current++)];
952 remainder =
static_cast<CRCType
>(remainder >> SHIFT);
958template <
typename CRCType, crcpp_u
int16 CRCW
idth>
966 remainder =
static_cast<CRCType
>(remainder ^ byte);
971#ifdef CRCPP_BRANCHLESS
977 remainder =
static_cast<CRCType
>((remainder >> 1) ^ ((remainder & 1) * polynomial));
979 remainder =
static_cast<CRCType
>((remainder & 1) ? ((remainder >> 1) ^ polynomial) : (remainder >> 1));
983 else if (CRCWidth >= CHAR_BIT)
985 static crcpp_constexpr CRCType CRC_WIDTH_MINUS_ONE(CRCWidth - CRCType(1));
986#ifndef CRCPP_BRANCHLESS
987 static crcpp_constexpr CRCType CRC_HIGHEST_BIT_MASK(CRCType(1) << CRC_WIDTH_MINUS_ONE);
990 static crcpp_constexpr CRCType SHIFT((CRCWidth >= CHAR_BIT) ?
static_cast<CRCType
>(CRCWidth - CHAR_BIT) : 0);
992 remainder =
static_cast<CRCType
>(remainder ^ (
static_cast<CRCType
>(byte) << SHIFT));
997#ifdef CRCPP_BRANCHLESS
1003 remainder =
static_cast<CRCType
>((remainder << 1) ^ (((remainder >> CRC_WIDTH_MINUS_ONE) & 1) * parameters.
polynomial));
1005 remainder =
static_cast<CRCType
>((remainder & CRC_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ parameters.
polynomial) : (remainder << 1));
1012#ifndef CRCPP_BRANCHLESS
1013 static crcpp_constexpr CRCType CHAR_BIT_HIGHEST_BIT_MASK(CRCType(1) << CHAR_BIT_MINUS_ONE);
1016 static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ?
static_cast<CRCType
>(CHAR_BIT - CRCWidth) : 0);
1018 CRCType polynomial =
static_cast<CRCType
>(parameters.
polynomial << SHIFT);
1019 remainder =
static_cast<CRCType
>((remainder << SHIFT) ^ byte);
1024#ifdef CRCPP_BRANCHLESS
1030 remainder =
static_cast<CRCType
>((remainder << 1) ^ (((remainder >> CHAR_BIT_MINUS_ONE) & 1) * polynomial));
1032 remainder =
static_cast<CRCType
>((remainder & CHAR_BIT_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ polynomial) : (remainder << 1));
1036 remainder =
static_cast<CRCType
>(remainder >> SHIFT);
1042#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
1225#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
1570#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
1698#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
1809#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
2012#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
2068#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
2124#ifdef CRCPP_USE_NAMESPACE
2128#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:568
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:1419
static const Parameters< crcpp_uint32, 24 > & CRC_24_NRC()
Returns a set of parameters for CRC-24 NR-C.
Definition CRC.h:1951
static const Parameters< crcpp_uint32, 24 > & CRC_24_FLEXRAYB()
Returns a set of parameters for CRC-24 FlexRay-B.
Definition CRC.h:1894
static const Parameters< crcpp_uint32, 24 > & CRC_24_LTEB()
Returns a set of parameters for CRC-24 LTE-B/NR-B.
Definition CRC.h:1932
static const Parameters< crcpp_uint16, 10 > & CRC_10()
Returns a set of parameters for CRC-10 ITU.
Definition CRC.h:1328
static const Parameters< crcpp_uint8, 6 > & CRC_6_ITU()
Returns a set of parameters for CRC-6 ITU.
Definition CRC.h:1163
static const Parameters< crcpp_uint8, 7 > & CRC_7()
Returns a set of parameters for CRC-7 JEDEC.
Definition CRC.h:1200
static const Parameters< crcpp_uint8, 4 > & CRC_4_ITU()
Returns a set of parameters for CRC-4 ITU.
Definition CRC.h:1055
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:1073
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:1803
static CRCType CalculateRemainderBits(unsigned char byte, crcpp_size numBits, const Parameters< CRCType, CRCWidth > ¶meters, CRCType remainder)
Definition CRC.h:959
static const Parameters< crcpp_uint32, 30 > & CRC_30()
Returns a set of parameters for CRC-30 CDMA.
Definition CRC.h:1969
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:1619
static const Parameters< crcpp_uint32, 17 > & CRC_17_CAN()
Returns a set of parameters for CRC-17 CAN.
Definition CRC.h:1822
static const Parameters< crcpp_uint8, 8 > & CRC_8()
Returns a set of parameters for CRC-8 SMBus.
Definition CRC.h:1219
static const Parameters< crcpp_uint32, 24 > & CRC_24()
Returns a set of parameters for CRC-24 OPENPGP.
Definition CRC.h:1858
static const Parameters< crcpp_uint16, 15 > & CRC_15_MPT1327()
Returns a set of parameters for CRC-15 MPT1327.
Definition CRC.h:1491
static const Parameters< crcpp_uint32, 32 > & CRC_32_MPEG2()
Returns a set of parameters for CRC-32 MPEG-2.
Definition CRC.h:2044
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:764
static const Parameters< crcpp_uint32, 24 > & CRC_24_FLEXRAYA()
Returns a set of parameters for CRC-24 FlexRay-A.
Definition CRC.h:1876
static const Parameters< crcpp_uint16, 16 > & CRC_16_MAXIM()
Returns a set of parameters for CRC-16 MAXIM.
Definition CRC.h:1711
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:2025
static const Parameters< crcpp_uint16, 13 > & CRC_13_BBC()
Returns a set of parameters for CRC-13 BBC.
Definition CRC.h:1455
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:1274
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:1256
static const Parameters< crcpp_uint8, 8 > & CRC_8_WCDMA()
Returns a set of parameters for CRC-8 WCDMA.
Definition CRC.h:1292
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:1528
static CRCType CalculateRemainder(const void *data, crcpp_size size, const Parameters< CRCType, CRCWidth > ¶meters, CRCType remainder)
Computes a CRC remainder.
Definition CRC.h:791
static const Parameters< crcpp_uint8, 6 > & CRC_6_NR()
Returns a set of parameters for CRC-6 NR.
Definition CRC.h:1182
static const Parameters< crcpp_uint32, 24 > & CRC_24_LTEA()
Returns a set of parameters for CRC-24 LTE-A/NR-A.
Definition CRC.h:1913
static const Parameters< crcpp_uint16, 15 > & CRC_15()
Returns a set of parameters for CRC-15 CAN.
Definition CRC.h:1473
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:1637
static const Parameters< crcpp_uint32, 21 > & CRC_21_CAN()
Returns a set of parameters for CRC-21 CAN.
Definition CRC.h:1840
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:1437
static const Parameters< crcpp_uint16, 16 > & CRC_16_CMS()
Returns a set of parameters for CRC-16 CMS.
Definition CRC.h:1601
static const Parameters< crcpp_uint16, 10 > & CRC_10_CDMA2000()
Returns a set of parameters for CRC-10 CDMA2000.
Definition CRC.h:1346
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:1145
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:1692
static const Parameters< crcpp_uint16, 11 > & CRC_11()
Returns a set of parameters for CRC-11 FlexRay.
Definition CRC.h:1364
static const Parameters< crcpp_uint32, 32 > & CRC_32_Q()
Returns a set of parameters for CRC-32 Q.
Definition CRC.h:2081
static const Parameters< crcpp_uint16, 16 > & CRC_16_T10DIF()
Returns a set of parameters for CRC-16 T10-DIF.
Definition CRC.h:1747
static const Parameters< crcpp_uint16, 16 > & CRC_16_MCRF4XX()
Returns a set of parameters for CRC-16 MCRF4XX.
Definition CRC.h:1564
static const Parameters< crcpp_uint16, 12 > & CRC_12_CDMA2000()
Returns a set of parameters for CRC-12 CDMA2000.
Definition CRC.h:1401
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:1674
static IntegerType Reflect(IntegerType value, crcpp_uint16 numBits)
Reflects (i.e. reverses the bits within) an integer value.
Definition CRC.h:709
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:1238
static const Parameters< crcpp_uint8, 5 > & CRC_5_USB()
Returns a set of parameters for CRC-5 USB.
Definition CRC.h:1109
static const Parameters< crcpp_uint16, 16 > & CRC_16_USB()
Returns a set of parameters for CRC-16 USB.
Definition CRC.h:1765
static const Parameters< crcpp_uint16, 16 > & CRC_16_MODBUS()
Returns a set of parameters for CRC-16 MODBUS.
Definition CRC.h:1729
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:2006
static const Parameters< crcpp_uint16, 16 > & CRC_16_CDMA2000()
Returns a set of parameters for CRC-16 CDMA2000.
Definition CRC.h:1583
static const Parameters< crcpp_uint16, 16 > & CRC_16_CCITTFALSE()
Returns a set of parameters for CRC-16 CCITT FALSE.
Definition CRC.h:1546
static const Parameters< crcpp_uint32, 32 > & CRC_32_POSIX()
Returns a set of parameters for CRC-32 POSIX.
Definition CRC.h:2062
static const Parameters< crcpp_uint16, 11 > & CRC_11_NR()
Returns a set of parameters for CRC-11 NR.
Definition CRC.h:1383
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:1785
static const Parameters< crcpp_uint8, 6 > & CRC_6_CDMA2000A()
Returns a set of parameters for CRC-6 CDMA2000-A.
Definition CRC.h:1127
static const Parameters< crcpp_uint8, 5 > & CRC_5_ITU()
Returns a set of parameters for CRC-5 ITU.
Definition CRC.h:1091
static const Parameters< crcpp_uint8, 8 > & CRC_8_LTE()
Returns a set of parameters for CRC-8 LTE.
Definition CRC.h:1310
static CRCType Calculate(const void *data, crcpp_size size, const Parameters< CRCType, CRCWidth > ¶meters)
Computes a CRC.
Definition CRC.h:481
static const Parameters< crcpp_uint16, 16 > & CRC_16_DNP()
Returns a set of parameters for CRC-16 DNP.
Definition CRC.h:1655
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:1510
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:1988
static const Parameters< crcpp_uint64, 64 > & CRC_64()
Returns a set of parameters for CRC-64 ECMA.
Definition CRC.h:2117
static CRCType Finalize(CRCType remainder, CRCType finalXOR, bool reflectOutput)
Computes the final reflection and XOR of a CRC remainder.
Definition CRC.h:732
static const Parameters< crcpp_uint64, 40 > & CRC_40_GSM()
Returns a set of parameters for CRC-40 GSM.
Definition CRC.h:2099
CRC parameters.
Definition CRC.h:178
Table< CRCType, CRCWidth > MakeTable() const
Returns a CRC lookup table construct using these CRC parameters.
Definition CRC.h:360
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:413
const Parameters< CRCType, CRCWidth > & GetParameters() const
Gets the CRC parameters used to construct the CRC table.
Definition CRC.h:401
CRCType operator[](unsigned char index) const
Gets an entry in the CRC table.
Definition CRC.h:426
Table(const Parameters< CRCType, CRCWidth > ¶meters)
Constructs a CRC table from a set of CRC parameters.
Definition CRC.h:373
CRCType table[1<< CHAR_BIT]
CRC lookup table.
Definition CRC.h:212
void InitTable()
Initializes a CRC table.
Definition CRC.h:437
Parameters< CRCType, CRCWidth > parameters
CRC parameters used to construct the table.
Definition CRC.h:211