diff --git a/Include/auROXTL/auFNV1Utils.hpp b/Include/auROXTL/auFNV1Utils.hpp index 1499559..5395e44 100644 --- a/Include/auROXTL/auFNV1Utils.hpp +++ b/Include/auROXTL/auFNV1Utils.hpp @@ -46,21 +46,61 @@ 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 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 +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 +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 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 +inline constexpr AuUInt32 AuFnv1aPtr32(const T *const type, AuUInt length, const AuUInt32 value = kFnv1MagicVal32) noexcept +{ + return AuFnv1aType32((const char *)type, + length, + 0, + value); +} + +template +inline constexpr AuUInt64 AuFnv1aPtr64(const T *const type, AuUInt length, const AuUInt64 value = kFnv1MagicVal64) noexcept +{ + return AuFnv1aType64((const char *)type, + length, + 0, + value); +} + inline constexpr auto AuFnv1a(const char *const str) noexcept { return _AU_FNV1_32 ? AuFnv1a32(str) : AuFnv1a64(str);