summaryrefslogtreecommitdiff
path: root/modules/codec/c++
diff options
context:
space:
mode:
Diffstat (limited to 'modules/codec/c++')
-rw-r--r--modules/codec/c++/schema_hash.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/modules/codec/c++/schema_hash.h b/modules/codec/c++/schema_hash.h
index 48e8d6c..29afa5e 100644
--- a/modules/codec/c++/schema_hash.h
+++ b/modules/codec/c++/schema_hash.h
@@ -100,6 +100,31 @@ struct schema_hash_seed<schema::Array<T,N>> {
}
};
+template<typename... T>
+struct schema_hash_seed<schema::Tuple<T...>> {
+ using Schema = schema::Tuple<T...>;
+
+ template<uint64_t i>
+ static constexpr uint32_t apply_ele(uint32_t seed){
+ using Type = typename parameter_pack_type<i,T...>::type;
+
+ seed = schema_hash_seed<Type>::apply(seed);
+ if constexpr ( (i+1) < sizeof...(T) ){
+ return apply_ele<i+1>(seed);
+ }
+ return seed;
+ }
+
+
+ static constexpr uint32_t apply(uint32_t seed){
+ seed = hash_literal<Schema::name>::apply(seed);
+ if constexpr (sizeof...(T) > 0){
+ seed = apply_ele<0>(seed);
+ }
+ 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>...>;
@@ -129,6 +154,48 @@ struct schema_hash_seed<schema::Struct<schema::Member<V,K>...>> {
}
};
+template<typename Req, typename Resp>
+struct schema_hash_seed<schema::Function<Req, Resp>> {
+ using Schema = schema::Function<Req,Resp>;
+
+ static constexpr uint32_t apply(uint32_t seed){
+ seed = hash_literal<Schema::name>::apply(seed);
+ seed = schema_hash_seed<Req>::apply(seed);
+ seed = schema_hash_seed<Resp>::apply(seed);
+ return seed;
+ }
+};
+
+template<typename... T, string_literal... Names>
+struct schema_hash_seed<schema::Interface<schema::Member<T, Names>...>> {
+ using Schema = schema::Interface<schema::Member<T,Names>...>;
+
+ template<uint64_t i>
+ static constexpr uint32_t apply_ele(uint32_t seed){
+ using Type = typename parameter_pack_type<i,T...>::type;
+ constexpr string_literal Lit = parameter_key_pack_type<i,Names...>::literal;
+ using MemberT = schema::Member<Type,Lit>;
+
+ 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...(T) ){
+ return apply_ele<i+1>(seed);
+ }
+
+ return seed;
+ }
+
+ static constexpr uint32_t apply(uint32_t seed){
+ seed = hash_literal<Schema::name>::apply(seed);
+ if constexpr ( sizeof...(T) > 0){
+ seed = apply_ele<0>(seed);
+ }
+ return seed;
+ }
+};
+
template<typename Schema>
struct schema_hash {
static constexpr uint32_t apply() {