...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::augmented_crc — Compute the CRC of a memory block, with any augmentation provided by user.
// In header: <boost/crc.hpp> template<std::size_t Bits, typename ::boost::uint_t< Bits >::fast TruncPoly> uint_t< Bits >::fast augmented_crc(void const * buffer, std::size_t byte_count, typename uint_t< Bits >::fast initial_remainder = 0u);
Computes the polynomial remainder of a CRC run, assuming that buffer and byte_count describe a memory block representing the polynomial dividend. The first byte is considered the highest order, going down for subsequent bytes. Within a byte, the highest-order bit is read first (corresponding to RefIn = False
in the RMCA). Check the other parts of this function's documentation to see how a checksum can be gained and/or used.
Note | |
---|---|
Augmented-style CRC runs use straight-up modulo-2 polynomial division. Since data is being read byte-wise, a table of pre-computed remainder changes (as XOR masks) can be used to speed computation. |
Note | |
---|---|
Reading just a memory block will yield an interim remainder, and not the final checksum. To get that checksum, allocate Bits / |
Note | |
---|---|
Another way to perform a check is use the zero-byte extension method, but replace the zero values with your separately-given checksum. The checksum must be loaded in big-endian order. Here corruption, in either the data block or the given checksum, is confirmed if the return value is not zero. |
Note | |
---|---|
The two checksum techniques assume the CRC-run is performed bit-wise, while this function works byte-wise. That means that the techniques can be used only if |
Parameters: |
|
||||||
Template Parameters: |
|
||||||
Requires: |
0 < Bits <= |
||||||
Returns: |
The interim remainder, if no augmentation is used. A special value if augmentation is used (see the notes). No output processing is done on the value. (In RMCA terms, RefOut is |