diff options
Diffstat (limited to 'c++/codec/schema_hash.h')
-rw-r--r-- | c++/codec/schema_hash.h | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/c++/codec/schema_hash.h b/c++/codec/schema_hash.h deleted file mode 100644 index 5690166..0000000 --- a/c++/codec/schema_hash.h +++ /dev/null @@ -1,105 +0,0 @@ -#pragma once - -#include "schema.h" - -namespace saw { -struct schema_hash_combine { - static constexpr uint64_t apply(uint64_t seed, uint64_t v){ - return (seed ^ v) * 1099511628211u; - - - return seed ^( std::hash<uint64_t>{}(v) + 0x9e3779b9 + (seed<<6) + (seed >> 2)); - } -}; - -template<typename Schema> -struct schema_hash { - static_assert(always_false<Schema>, "Not schema_hashable"); -}; - -template<> -struct schema_hash<schema::Primitive<schema::SignedInteger,1>> { - static constexpr uint64_t base_value = 0u; -}; - -template<> -struct schema_hash<schema::Primitive<schema::SignedInteger,2>> { - static constexpr uint64_t base_value = 1u; -}; - -template<> -struct schema_hash<schema::Primitive<schema::SignedInteger,4>> { - static constexpr uint64_t base_value = 2u; -}; - -template<> -struct schema_hash<schema::Primitive<schema::SignedInteger,8>> { - static constexpr uint64_t base_value = 3u; -}; - -template<> -struct schema_hash<schema::Primitive<schema::UnsignedInteger,1>> { - static constexpr uint64_t base_value = 4u; -}; - -template<> -struct schema_hash<schema::Primitive<schema::UnsignedInteger,2>> { - static constexpr uint64_t base_value = 5u; -}; - -template<> -struct schema_hash<schema::Primitive<schema::UnsignedInteger,4>> { - static constexpr uint64_t base_value = 6u; -}; - -template<> -struct schema_hash<schema::Primitive<schema::UnsignedInteger,8>> { - static constexpr uint64_t base_value = 7u; -}; - -template<> -struct schema_hash<schema::Primitive<schema::FloatingPoint,4>> { - static constexpr uint64_t base_value = 8u; -}; - -template<> -struct schema_hash<schema::Primitive<schema::FloatingPoint,8>> { - static constexpr uint64_t base_value = 9u; -}; - -template<typename... T> -struct schema_hash<schema::Tuple<T...>> { - static constexpr uint64_t base_value = 10u; -}; - -template<typename... T, string_literal Literal> -struct schema_hash<schema::Struct<schema::Member<T,Literal>...>> { - static constexpr uint64_t base_value = 11u; -}; - -template<typename... T, string_literal Literal> -struct schema_hash<schema::Union<schema::Member<T,Literal>...>> { - static constexpr uint64_t base_value = 12u; -}; - -template<typename T, size_t Dim> -struct schema_hash<schema::Array<T,Dim>> { - static constexpr uint64_t base_value = 13u; -}; - -template<> -struct schema_hash<schema::String> { - static constexpr uint64_t base_value = 14u; -}; - -template<typename T, typename N> -struct schema_hash<schema::Wrapper<T,N>> { - static constexpr uint64_t base_value = 15u; -}; - -template<typename T, size_t... Dims> -struct schema_hash<schema::FixedArray<T,Dims...>> { - static constexpr uint64_t base_value = 16u; -}; - -} |