hash/crc: convert to object style accumulator
This commit is contained in:
parent
8333cad8cc
commit
8824331c4b
37
hash/crc.cpp
37
hash/crc.cpp
@ -16,25 +16,32 @@
|
||||
|
||||
#include "./crc.hpp"
|
||||
|
||||
#include "../endian.hpp"
|
||||
#include "../debug.hpp"
|
||||
|
||||
using util::hash::crc32;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
uint32_t
|
||||
util::hash::crc32 (
|
||||
const uint8_t *restrict first,
|
||||
const uint8_t *restrict last
|
||||
) noexcept {
|
||||
void
|
||||
crc32::reset (void)
|
||||
{ ; }
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
crc32::update (const uint8_t *restrict first,
|
||||
const uint8_t *restrict last) noexcept
|
||||
{
|
||||
CHECK_LE (first, last);
|
||||
|
||||
return crc32 (first, last - first);
|
||||
return update (first, last - first);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
uint32_t
|
||||
util::hash::crc32 (const void *restrict, size_t) noexcept {
|
||||
void
|
||||
crc32::update (const void *restrict, size_t) noexcept
|
||||
{
|
||||
not_implemented ();
|
||||
|
||||
/*
|
||||
@ -67,3 +74,15 @@ util::hash::crc32 (const void *restrict, size_t) noexcept {
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
crc32::finish (void)
|
||||
{ not_implemented (); }
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
typename crc32::digest_t
|
||||
crc32::digest (void) const
|
||||
{ not_implemented (); }
|
||||
|
16
hash/crc.hpp
16
hash/crc.hpp
@ -23,8 +23,20 @@
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace util { namespace hash {
|
||||
uint32_t crc32 (const void *restrict data, size_t bytes) noexcept;
|
||||
uint32_t crc32 (const uint8_t *restrict first, const uint8_t *restrict last) noexcept;
|
||||
class crc32 {
|
||||
public:
|
||||
using digest_t = uint32_t;
|
||||
|
||||
void reset (void);
|
||||
|
||||
void update (const void *restrict data, size_t bytes) noexcept;
|
||||
void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept;
|
||||
|
||||
void finish (void);
|
||||
|
||||
digest_t digest (void) const;
|
||||
};
|
||||
|
||||
} }
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user