ACF $AcfVersion:0$
CCrcCalculator.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// Qt includes
6#include <QtCore/QVector>
7#include <QtCore/QString>
8
9
10namespace istd
11{
12
13
18{
19public:
20 typedef QVector<quint8> ByteStream;
21
25 static quint32 GetCrcFromData(const quint8* dataPtr, int dataSize);
26
30 static quint32 GetCrcFromStream(const ByteStream& byteStream);
31
35 static quint32 GetCrcFromFile(const QString& fileName);
36
37protected:
41 static void UpdateCrc(const quint8& byte, quint32& dwCrc32);
42
43private:
44 static quint32 s_crcTable[256];
45};
46
47
48// protected inline methods
49
50inline void CCrcCalculator::UpdateCrc(const quint8& byte, quint32& crcValue)
51{
52 crcValue = (crcValue >> 8) ^ s_crcTable[byte ^ (crcValue & 0x000000FF)];
53}
54
55
56} // namespace istd
57
58
59
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