feat: added context and utility headers

This commit is contained in:
2025-11-18 19:50:24 +01:00
parent bad346132d
commit efaa7f1088
2 changed files with 215 additions and 0 deletions

29
include/fxn/utility.hpp Normal file
View File

@@ -0,0 +1,29 @@
#pragma once
#include <string_view>
#include <cstdint>
namespace fxn
{
inline constexpr char ToLower(const char c) noexcept
{
return (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c;
}
inline constexpr unsigned int HashString(std::string_view str) noexcept
{
std::uint32_t hash = 0;
for (char ch : str)
{
hash += ToLower(ch);
hash += (hash << 10);
hash ^= (hash >> 6);
}
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return hash;
}
}