From 44f6a2ec37e35cf96419885be27afeab9ea84ec5 Mon Sep 17 00:00:00 2001 From: Claudius 'keldu' Holeksa Date: Mon, 29 Jul 2024 14:53:48 +0200 Subject: wip --- modules/codec/c++/data.hpp | 4 +++- modules/codec/c++/schema_hash.hpp | 27 ++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'modules/codec/c++') diff --git a/modules/codec/c++/data.hpp b/modules/codec/c++/data.hpp index a17f123..8e92622 100644 --- a/modules/codec/c++/data.hpp +++ b/modules/codec/c++/data.hpp @@ -21,7 +21,9 @@ struct Default {}; } namespace encode { -struct Native {}; +struct Native { + static constexpr string_literal name = "encode::Native"; +}; } template class codec; diff --git a/modules/codec/c++/schema_hash.hpp b/modules/codec/c++/schema_hash.hpp index 4b537e1..d653bf4 100644 --- a/modules/codec/c++/schema_hash.hpp +++ b/modules/codec/c++/schema_hash.hpp @@ -15,7 +15,9 @@ struct hash_literal { template struct schema_hash_seed { - static_assert(always_false, "Not schema_hashable"); + static constexpr uint32_t apply(uint32_t seed){ + return hash_literal::apply(seed); + } }; template<> @@ -125,6 +127,29 @@ struct schema_hash_seed> { } }; +template +struct schema_hash_seed> { + 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+1u) < sizeof...(T) ){ + return apply_ele(seed); + } + + return seed; + } + + static constexpr uint32_t apply(uint32_t seed){ + seed = hash_literal::name>::apply(seed); + if constexpr (sizeof...(T)>0u){ + seed = apply_ele<0u>(seed); + } + return seed; + } +}; + template struct schema_hash_seed> { using Schema = schema::Member; -- cgit v1.2.3