From 2dd333c909748e7e735be3e302c8e7a0993bbbec Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 22 Jan 2024 19:05:23 +0100 Subject: codec: Adding more hashing cases --- modules/codec/c++/schema_hash.h | 67 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'modules/codec/c++') 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> { } }; +template +struct schema_hash_seed> { + using Schema = schema::Tuple; + + template + static constexpr uint32_t apply_ele(uint32_t seed){ + using Type = typename parameter_pack_type::type; + + seed = schema_hash_seed::apply(seed); + if constexpr ( (i+1) < sizeof...(T) ){ + return apply_ele(seed); + } + return seed; + } + + + static constexpr uint32_t apply(uint32_t seed){ + seed = hash_literal::apply(seed); + if constexpr (sizeof...(T) > 0){ + seed = apply_ele<0>(seed); + } + return seed; + } +}; + template struct schema_hash_seed...>> { using Schema = schema::Struct...>; @@ -129,6 +154,48 @@ struct schema_hash_seed...>> { } }; +template +struct schema_hash_seed> { + using Schema = schema::Function; + + static constexpr uint32_t apply(uint32_t seed){ + seed = hash_literal::apply(seed); + seed = schema_hash_seed::apply(seed); + seed = schema_hash_seed::apply(seed); + return seed; + } +}; + +template +struct schema_hash_seed...>> { + using Schema = schema::Interface...>; + + template + static constexpr uint32_t apply_ele(uint32_t seed){ + using Type = typename parameter_pack_type::type; + constexpr string_literal Lit = parameter_key_pack_type::literal; + using MemberT = schema::Member; + + seed = hash_literal::apply(seed); + seed = schema_hash_seed::apply(seed); + seed = hash_literal::apply(seed); + + if constexpr ( (i+1) < sizeof...(T) ){ + return apply_ele(seed); + } + + return seed; + } + + static constexpr uint32_t apply(uint32_t seed){ + seed = hash_literal::apply(seed); + if constexpr ( sizeof...(T) > 0){ + seed = apply_ele<0>(seed); + } + return seed; + } +}; + template struct schema_hash { static constexpr uint32_t apply() { -- cgit v1.2.3