⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 crc.h

📁 c+++ game uploading now
💻 H
字号:
/**
 @file
 Crc related classes.
*/

#if !defined _CRC__H_
#define _CRC__H_

//CREDIT www.relisoft.com 

/**
 Crc class provides CRC cheking services*/ 
class Crc
{
public:
    typedef unsigned long Type;

    /**
     @param key is the polynominal used */
    Crc(Type key) 
      :_key(key),
       _register(0) 
    {
        Init();
    }

    /**
     call this when all input has been processed
     @return the crc value */
    Type Done()
    {
        Type tmp = _register;
        _register = 0;
        return tmp;
    }

    /**
     runs a byte through */
    void PutByte(unsigned byte)
    {
        unsigned top = _register >> 24;
        top ^= byte;
        _register = (_register << 8) ^ _table[top];
    }

    /**
     runs a 32 bit word through */
    void Put32Bit(unsigned t);

private:
    /**
     initializes the precomputed table*/
    void Init();

    /** precomputed table */
    Type _table[256];

    /** the polynominal used*/
    Type _key;

    /** curent value */
    Type _register;
};

/**
 EthernetCrc class with the ethernet polynominal 0x04c11db7*/
class EthernetCrc: public Crc
{
public:
    explicit EthernetCrc()
      :Crc(0x04c11db7)
    {}
};

#endif //_CRC__H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -