summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-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() {