From d92047425f0942680307a35ec2f4680775499e5a Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 17 Jan 2024 17:22:52 +0100 Subject: codec: Added More schema hash methods --- modules/codec/c++/schema_hash.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'modules/codec/c++/schema_hash.h') 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> { } }; +template +struct schema_hash_seed> { + using Schema = schema::Array; + + static constexpr uint64_t apply(uint64_t seed){ + seed = hash_literal::apply(seed); + seed = schema_hash_seed::apply(seed); + seed = schema_hash_combine::apply(seed, N); + return seed; + } +}; + +template +struct schema_hash_seed...>> { + using Schema = schema::Struct...>; + + template + static constexpr uint64_t apply_ele(uint64_t seed){ + using Type = typename parameter_pack_type::type; + constexpr string_literal Lit = parameter_key_pack_type::literal; + using MemberT = typename parameter_pack_type...>::type; + + seed = hash_literal::apply(seed); + seed = schema_hash_seed::apply(seed); + seed = hash_literal::apply(seed); + + if constexpr ( (i+1) < sizeof...(V) ){ + return apply_ele(seed); + } + return seed; + } + + static constexpr uint64_t apply(uint64_t seed){ + seed = hash_literal::apply(seed); + if constexpr (sizeof...(V) > 0){ + seed = apply_ele<0>(seed); + } + return seed; + } +}; + template struct schema_hash { static constexpr uint64_t apply() { -- cgit v1.2.3