From 8dad985328e2183b224300aa992951131956fdb3 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Tue, 23 Jan 2024 13:12:11 +0100 Subject: core,codec-json,codec-minecraft,codec-netcdf,codec,io-tls,io,io_codec,window,window-opengl: Renamed file endings and changed includes --- modules/codec/c++/schema_hash.h | 207 ---------------------------------------- 1 file changed, 207 deletions(-) delete mode 100644 modules/codec/c++/schema_hash.h (limited to 'modules/codec/c++/schema_hash.h') diff --git a/modules/codec/c++/schema_hash.h b/modules/codec/c++/schema_hash.h deleted file mode 100644 index 29afa5e..0000000 --- a/modules/codec/c++/schema_hash.h +++ /dev/null @@ -1,207 +0,0 @@ -#pragma once - -#include -#include "schema.h" -#include "crc32.h" - -namespace saw { -template -struct hash_literal { - static constexpr uint32_t apply(uint32_t seed){ - constexpr std::string_view view = lit.view(); - return hash::update(seed, view); - } -}; - -template -struct schema_hash_seed { - static_assert(always_false, "Not schema_hashable"); -}; - -template<> -struct schema_hash_seed { - using Schema = schema::SignedInteger; - - static constexpr uint32_t apply(uint32_t seed){ - return hash_literal::apply(seed); - } -}; - -template<> -struct schema_hash_seed { - using Schema = schema::UnsignedInteger; - - static constexpr uint32_t apply(uint32_t seed){ - return hash_literal::apply(seed); - } -}; - -template<> -struct schema_hash_seed { - using Schema = schema::FloatingPoint; - - static constexpr uint32_t apply(uint32_t seed){ - return hash_literal::apply(seed); - } -}; - -template<> -struct schema_hash_seed { - using Schema = schema::String; - - static constexpr uint32_t apply(uint32_t seed){ - return hash_literal::apply(seed); - } -}; - -template -struct schema_hash_seed> { - using Schema = schema::Primitive; - - static constexpr uint32_t apply(uint32_t seed){ - seed = hash_literal::apply(seed); - seed = schema_hash_seed

::apply(seed); - uint64_t val = N; - std::array dat{ - static_cast(val >> 0), - static_cast(val >> 8), - static_cast(val >> 16), - static_cast(val >> 24), - static_cast(val >> 32), - static_cast(val >> 40), - static_cast(val >> 48), - static_cast(val >> 56) - }; - seed = hash::update(seed, &dat[0], dat.size()); - return seed; - } -}; - -template -struct schema_hash_seed> { - using Schema = schema::Array; - - static constexpr uint32_t apply(uint32_t seed){ - seed = hash_literal::apply(seed); - seed = schema_hash_seed::apply(seed); - uint64_t val = N; - std::array dat{ - static_cast(val >> 0), - static_cast(val >> 8), - static_cast(val >> 16), - static_cast(val >> 24), - static_cast(val >> 32), - static_cast(val >> 40), - static_cast(val >> 48), - static_cast(val >> 56) - }; - seed = hash::update(seed, &dat[0], dat.size()); - return 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...>; - - 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 = 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 uint32_t apply(uint32_t seed){ - seed = hash_literal::apply(seed); - if constexpr (sizeof...(V) > 0){ - seed = apply_ele<0>(seed); - } - return 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() { - constexpr uint32_t seed = 0; - return schema_hash_seed::apply(seed); - } -}; - -} -- cgit v1.2.3