RIT VEXU Core API
Toggle main menu visibility
Loading...
Searching...
No Matches
crc32.hpp
1
#pragma once
2
#include <cstdint>
3
#include <cstddef>
4
7
class
CRC32
{
8
public
:
12
CRC32
();
16
void
reset
();
21
void
update
(
const
uint8_t &data);
27
template
<
typename
Type>
void
update
(
const
Type &data) {
update
(&data, 1); }
34
template
<
typename
Type>
void
update
(
const
Type *data, std::size_t size) {
35
std::size_t nBytes = size *
sizeof
(Type);
36
const
uint8_t *pData = (
const
uint8_t *)data;
37
38
for
(std::size_t i = 0; i < nBytes; i++) {
39
update
(pData[i]);
40
}
41
}
42
45
uint32_t
finalize
()
const
;
53
template
<
typename
Type>
static
uint32_t
calculate
(
const
Type *data, std::size_t size) {
54
CRC32
crc;
55
crc.
update
(data, size);
56
return
crc.
finalize
();
57
}
58
59
private
:
63
uint32_t _state = ~0L;
64
};
CRC32::calculate
static uint32_t calculate(const Type *data, std::size_t size)
Calculate the checksum of an arbitrary data array.
Definition
crc32.hpp:53
CRC32::CRC32
CRC32()
Initialize an empty CRC32 checksum.
Definition
crc32.cpp:9
CRC32::update
void update(const Type &data)
Update the current checksum caclulation with the given data.
Definition
crc32.hpp:27
CRC32::reset
void reset()
Reset the checksum claculation.
Definition
crc32.cpp:11
CRC32::update
void update(const uint8_t &data)
Update the current checksum caclulation with the given data.
Definition
crc32.cpp:13
CRC32::update
void update(const Type *data, std::size_t size)
Update the current checksum caclulation with the given data.
Definition
crc32.hpp:34
CRC32::finalize
uint32_t finalize() const
Definition
crc32.cpp:23
include
core
device
vdb
crc32.hpp
Generated by
1.17.0