|
pabigot
0.1.1
C++ support classes
|
Class encapsulating everything necessary for table-driven CRC calculations. More...
#include </mnt/devel/pabigot-cxx/include/pabigot/crc.hpp>
Data Structures | |
| struct | params |
| Rocksoft^TM model parameters for the checksum algorithm supported by this type. More... | |
Public Types | |
| using | crc_type = CRC |
| The underlying crc type. | |
| using | table_type = std::array< least_type, 256 > |
| How the CRC table elements are stored. | |
Public Member Functions | |
| uint8_t * | store (least_type crc, uint8_t *bp) const |
| Store a finalized CRC into a buffer in a way that enables crc::residue(). More... | |
| constexpr fast_type | append (uint8_t octet, fast_type crc=init) const |
| Table-driven update of a CRC given a data octet. More... | |
| template<typename InputIterator > | |
| constexpr fast_type | append (InputIterator first, InputIterator last, fast_type crc=init) const |
| Table-driven calculation of a CRC from a sequence of octet values. More... | |
| constexpr least_type | finalize (fast_type crc) const |
| Perform necessary post-processing to get the final checksum. More... | |
Data Fields | |
| const table_type | table |
| The CRC table, indexed by unreflected input octet. | |
Static Public Attributes | |
| static constexpr size_t | size = CRC::size |
| The number of bytes required to store a CRC value of #width bits. | |
| static constexpr fast_type | init = make_init() |
| The CRC initial value in the form required for table calculations. | |
| static constexpr least_type | residue = CRC::residue() |
| The value expected when calculating the finalized CRC over an aggregate of a message and its store()d checksum. | |
Class encapsulating everything necessary for table-driven CRC calculations.
The table is an instance member; everything else is a constexpr class static member. Construct these as global objects at compile-time with definitions like:
constexpr auto crc = pabigot::crc::crc<32, 0x04c11db7, true, true, -1, -1>::instantiate_tabler();
Use them like:
uint8_t* cp = prepare_message(buf); auto pre = crc.append(buf, cp); const uint8_t* ep = crc.store(crc.finalize(pre), cp); transmit(buf, ep);
On reception:
auto len = receive(buf);
if (crc.residue != crc.finalize(crc.append(buf, buf + len))) {
// error in aggregate message
}
|
inlineconstexpr |
Table-driven calculation of a CRC from a sequence of octet values.
| InputIterator | iterator over inputs. InputIterator::value_type must be convertible to an unsigned 8-bit value without changing the value content. |
| first | beginning of the range over which CRCs will be calculated. |
| last | beginning of the range over which CRCs will be calculated. |
| crc | the CRC value calculated over all previous message bits. Start with init, which is the defaulted value. |
|
inlineconstexpr |
Table-driven update of a CRC given a data octet.
| octet | the next octet of message bits. |
| crc | the CRC value calculated over all previous message bits. Start with init, which is the defaulted value. |
|
inlineconstexpr |
Perform necessary post-processing to get the final checksum.
| crc | an unreflected unmodified CRC over input bits. |
|
inline |
Store a finalized CRC into a buffer in a way that enables crc::residue().
| crc | the finalized CRC of a message. |
| bp | pointer to space of size bytes immediately following the message, into which the CRC can be stored. |
bp immediately following the stored CRC.
1.8.16