ReXGlue SDK
Toggle main menu visibility
Loading...
Searching...
No Matches
hash.h
Go to the documentation of this file.
1
12
13
#pragma once
14
15
#include <functional>
16
#include <span>
17
#include <cstddef>
18
#include <filesystem>
19
#include <string>
20
#include <string_view>
21
#include <type_traits>
22
23
#include <
rex/types.h
>
24
#include <
rex/platform.h
>
25
26
namespace
rex
{
27
33
template
<
typename
Key>
34
struct
IdentityHasher
{
38
size_t
operator()
(
const
Key& key)
const
{
return
static_cast<
size_t
>
(key); }
39
};
40
46
template
<
typename
Key>
47
struct
KeyHasher
{
51
size_t
operator()
(
const
Key& hashed_key)
const
{
52
return
std::hash<std::remove_cvref_t<
decltype
(hashed_key.key)>>{}(hashed_key.key);
53
}
54
};
55
61
REX_API
u64
HashXXH3
(std::span<const u8> data);
62
64
template
<
typename
Key>
65
struct
XXHasher
{
69
size_t
operator()
(
const
Key& key)
const
{
70
return
static_cast<
size_t
>
(
71
HashXXH3
(std::span<const u8>(
reinterpret_cast<
const
u8*
>
(&key),
sizeof
(key))));
72
}
73
};
74
81
REX_API
std::string
HashBytes
(std::string_view data);
82
89
REX_API
std::string
HashFile
(
const
std::filesystem::path& path);
90
96
inline
size_t
hash_combine
(
size_t
hash) {
97
return
hash;
98
}
99
101
template
<
typename
T,
typename
... Ts>
102
size_t
hash_combine
(
size_t
hash,
const
T& v,
const
Ts&... vs) {
103
std::hash<T> hasher;
104
hash ^= hasher(v) + 0x9E3779B9 + (hash << 6) + (hash >> 2);
105
return
hash_combine
(hash, vs...);
106
}
107
108
}
// namespace rex
rex
Definition
app.h:36
rex::HashFile
std::string HashFile(const std::filesystem::path &path)
rex::HashBytes
std::string HashBytes(std::string_view data)
rex::hash_combine
size_t hash_combine(size_t hash)
Definition
hash.h:96
rex::HashXXH3
u64 HashXXH3(std::span< const u8 > data)
platform.h
Platform flags, packing macros and export markers.
REX_API
#define REX_API
Definition
platform.h:177
rex::IdentityHasher
Definition
hash.h:34
rex::IdentityHasher::operator()
size_t operator()(const Key &key) const
Definition
hash.h:38
rex::KeyHasher
Definition
hash.h:47
rex::KeyHasher::operator()
size_t operator()(const Key &hashed_key) const
Definition
hash.h:51
rex::XXHasher
Definition
hash.h:65
rex::XXHasher::operator()
size_t operator()(const Key &key) const
Definition
hash.h:69
types.h
Integer types, byte order wrappers and size literals.
rex
hash.h
Generated by
1.18.0