mirror of
https://github.com/TomHarte/CLK.git
synced 2026-04-26 03:29:40 +00:00
Implements write support for WOZ files.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#define CRC_hpp
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace CRC {
|
||||
|
||||
@@ -58,6 +59,19 @@ template <typename T, T reset_value, T xor_output, bool reflect_input, bool refl
|
||||
/// Sets the current value of the CRC.
|
||||
inline void set_value(T value) { value_ = value; }
|
||||
|
||||
/*!
|
||||
A compound for:
|
||||
|
||||
reset()
|
||||
[add all data from @c data]
|
||||
get_value()
|
||||
*/
|
||||
T compute_crc(const std::vector<uint8_t> &data) {
|
||||
reset();
|
||||
for(const auto &byte: data) add(byte);
|
||||
return get_value();
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr int multibyte_shift = (sizeof(T) * 8) - 8;
|
||||
T xor_table[256];
|
||||
|
||||
Reference in New Issue
Block a user