[+] Additional fnv1 helpers

This commit is contained in:
Reece Wilson 2023-01-08 17:43:16 +00:00
parent 5f81b54fe1
commit 117390825c

View File

@ -46,16 +46,56 @@ inline constexpr AuUInt AuFnv1aType(const char *type, AuUInt size, AuUInt index,
return (index == size) ? value : AuFnv1aType(type + 1, size, index + 1, (value ^ AuUInt(*type)) * kFnv1MagicPrimePlatform);
}
inline constexpr AuUInt32 AuFnv1aType32(const char *type, AuUInt size, AuUInt index, const AuUInt32 value) noexcept
{
return (index == size) ? value : AuFnv1aType32(type + 1, size, index + 1, (value ^ AuUInt32(*type)) * kFnv1MagicPrime32);
}
inline constexpr AuUInt64 AuFnv1aType64(const char *type, AuUInt size, AuUInt index, const AuUInt64 value) noexcept
{
return (index == size) ? value : AuFnv1aType64(type + 1, size, index + 1, (value ^ AuUInt64(*type)) * kFnv1MagicPrime64);
}
template <class T>
inline constexpr AuUInt AuFnv1aType(const T &type, const AuUInt value = kFnv1MagicValPlatform) noexcept
{
return AuFnv1aType(((const char *)&type) + 1, sizeof(T), 1, (value ^ (AuUInt(*(const char *)&type)) * kFnv1MagicPrimePlatform));
}
template <class T>
inline constexpr AuUInt32 AuFnv1aType32(const T &type, const AuUInt32 value = kFnv1MagicVal32) noexcept
{
return AuFnv1aType32(((const char *)&type) + 1, sizeof(T), 1, (value ^ (AuUInt(*(const char *)&type)) * kFnv1MagicPrime32));
}
template <class T>
inline constexpr AuUInt64 AuFnv1aType64(const T &type, const AuUInt64 value = kFnv1MagicVal64) noexcept
{
return AuFnv1aType64(((const char *)&type) + 1, sizeof(T), 1, (value ^ (AuUInt(*(const char *)&type)) * kFnv1MagicPrime64));
}
template <class T>
inline constexpr AuUInt AuFnv1aPtr(const T *const type, AuUInt length, const AuUInt value = kFnv1MagicValPlatform) noexcept
{
return AuFnv1aType(((const char *)type),
return AuFnv1aType((const char *)type,
length,
0,
value);
}
template <class T>
inline constexpr AuUInt32 AuFnv1aPtr32(const T *const type, AuUInt length, const AuUInt32 value = kFnv1MagicVal32) noexcept
{
return AuFnv1aType32((const char *)type,
length,
0,
value);
}
template <class T>
inline constexpr AuUInt64 AuFnv1aPtr64(const T *const type, AuUInt length, const AuUInt64 value = kFnv1MagicVal64) noexcept
{
return AuFnv1aType64((const char *)type,
length,
0,
value);