summaryrefslogtreecommitdiff
path: root/modules/codec/c++/schema_hash.h
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2024-01-17 17:22:52 +0100
committerClaudius "keldu" Holeksa <mail@keldu.de>2024-01-17 17:22:52 +0100
commitd92047425f0942680307a35ec2f4680775499e5a (patch)
tree73e144c20200a29c5bbbb276e27959122a31ad5f /modules/codec/c++/schema_hash.h
parent06167d6ecc3c0c87e0d582ec69c55011f3eb49f1 (diff)
codec: Added More schema hash methods
Diffstat (limited to 'modules/codec/c++/schema_hash.h')
-rw-r--r--modules/codec/c++/schema_hash.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/modules/codec/c++/schema_hash.h b/modules/codec/c++/schema_hash.h
index 8f66fbf..d4312c4 100644
--- a/modules/codec/c++/schema_hash.h
+++ b/modules/codec/c++/schema_hash.h
@@ -74,6 +74,47 @@ struct schema_hash_seed<schema::Primitive<P,N>> {
}
};
+template<typename T, uint64_t N>
+struct schema_hash_seed<schema::Array<T,N>> {
+ using Schema = schema::Array<T,N>;
+
+ static constexpr uint64_t apply(uint64_t seed){
+ seed = hash_literal<Schema::name>::apply(seed);
+ seed = schema_hash_seed<T>::apply(seed);
+ seed = schema_hash_combine::apply(seed, N);
+ return seed;
+ }
+};
+
+template<typename... V, string_literal... K>
+struct schema_hash_seed<schema::Struct<schema::Member<V,K>...>> {
+ using Schema = schema::Struct<schema::Member<V,K>...>;
+
+ template<uint64_t i>
+ static constexpr uint64_t apply_ele(uint64_t seed){
+ using Type = typename parameter_pack_type<i,V...>::type;
+ constexpr string_literal Lit = parameter_key_pack_type<i,K...>::literal;
+ using MemberT = typename parameter_pack_type<i,schema::Member<V,K>...>::type;
+
+ seed = hash_literal<MemberT::name>::apply(seed);
+ seed = schema_hash_seed<Type>::apply(seed);
+ seed = hash_literal<Lit>::apply(seed);
+
+ if constexpr ( (i+1) < sizeof...(V) ){
+ return apply_ele<i+1>(seed);
+ }
+ return seed;
+ }
+
+ static constexpr uint64_t apply(uint64_t seed){
+ seed = hash_literal<Schema::name>::apply(seed);
+ if constexpr (sizeof...(V) > 0){
+ seed = apply_ele<0>(seed);
+ }
+ return seed;
+ }
+};
+
template<typename Schema>
struct schema_hash {
static constexpr uint64_t apply() {