Home Libraries Author Links

GenCRC: Generic CRC Generation
[SysToMath Aids C++ Library]

Collaboration diagram for GenCRC: Generic CRC Generation:

Detailed Description

Declaration of the class template stm::crc used to generate cyclic redundancy check (CRC) remainder polynomials of template type RemPolT over buffers of byte-like objects.

In the following class template documentation the international standard C++ISO/IEC 14882:2003(E) is cited in the form of parenthesized expressions with the same syntax and semantics as inside this international standard itself.


Files

file  gencrc.hpp
 Declarations of generic CRC remainder polynomial generation.

Modules

 GenCRC Test
 Demonstration of the usage and tests of the implementation of the SysToMath Aids C++ Library module GenCRC.

Classes

class  stm::crc< RemPolT >
 Class template crc provides a means to generate cyclic redundancy check (CRC) remainder polynomials of type RemPolT over buffers of byte-like objects. More...

Examples of GenCRC Usage

    #include <assert.h>
    #include <string>
    #include <stm/gencrc.hpp>

    // Define CRC types.
    assert (sizeof (unsigned short) == 2);
    assert (sizeof (unsigned int) == 4);
    typedef stm::crc<unsigned short> crc16;
    typedef stm::crc<unsigned int> crc32;

    // Buffers to check.
    std::string hello = "Hello ";
    std::string world = "world!";


    // CRC16 generator polynomial as designated by CCITT (Comité Consultatif
    // International Télégraphique et Téléphonique).
    crc16 ccittcheck (0x1021, 0xffff);

    // CCITT CRC16 check sum of the concatenation of the strings hello and
    // world.
    unsigned short ccittCheckSum =
        ccittcheck
        (
            ccittcheck
            (
                hello.begin (),
                hello.end ()
            ),
            world.c_str (),
            world.size ()
        );


    // CRC16 generator polynomial as used by BISYNCH and ARC.
    crc16 crc16check (0x8005, 0, true);

    // CRC16 check sum of the concatenation of the strings hello and world.
    unsigned short crc16CheckSum =
        crc16check
        (
            crc16check
            (
                hello.begin (),
                hello.end ()
            ),
            world.c_str (),
            world.size (),
            true
        );


    // CRC16 generator polynomial as used by XMODEM.
    crc16 xmodemcheck (0x8408, 0, true);

    // XMODEM check sum of the concatenation of the strings hello and world.
    unsigned short xmodemCheckSum =
        xmodemcheck
        (
            xmodemcheck
            (
                hello.begin (),
                hello.end ()
            ),
            world.c_str (),
            world.size (),
            true
        );


    // Commonly used CRC32 generator polynomial.
    crc32 crc32check (0x04C11DB7, 0xFFFFFFFF, true);

    // CRC32 check sum of the concatenation of the strings hello and world.
    unsigned int crc32CheckSum =
        crc32check
        (
            crc32check
            (
                hello.begin (),
                hello.end ()
            ),
            world.c_str (),
            world.size (),
            true,
            0xFFFFFFFF
        );

© Copyright Tom Michaelis 2002-2007

Distributed under the SysToMath Software License (See the accompanying file license.txt or a copy at www.SysToMath.com).