ICF 3.0.5.47
Technical documentation of ICF Libraries
CCrcCalculator.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#pragma once
7
8
9// Qt includes
10#include <QtCore/QVector>
11#include <QtCore/QString>
12
13
14namespace istd
15{
16
17
22{
23public:
24 typedef QVector<quint8> ByteStream;
25
29 static quint32 GetCrcFromData(const quint8* dataPtr, int dataSize);
30
34 static quint32 GetCrcFromStream(const ByteStream& byteStream);
35
39 static quint32 GetCrcFromFile(const QString& fileName);
40
41protected:
45 static void UpdateCrc(const quint8& byte, quint32& dwCrc32);
46
47private:
48 static quint32 s_crcTable[256];
49};
50
51
52// protected inline methods
53
54inline void CCrcCalculator::UpdateCrc(const quint8& byte, quint32& crcValue)
55{
56 crcValue = (crcValue >> 8) ^ s_crcTable[byte ^ (crcValue & 0x000000FF)];
57}
58
59
60} // namespace istd
61
62
Helper class for CRC-32 checksum calculation.
static quint32 GetCrcFromFile(const QString &fileName)
Get 32-bit CRC value for a given file.
QVector< quint8 > ByteStream
static quint32 GetCrcFromStream(const ByteStream &byteStream)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static quint32 GetCrcFromData(const quint8 *dataPtr, int dataSize)
Get 32-bit CRC value for the given memory block.
static void UpdateCrc(const quint8 &byte, quint32 &dwCrc32)
Update CRC value for the new input.
Standard library.
Definition IComponent.h:17

© Witold Gantzke and Kirill Lepskiy