diff options
Diffstat (limited to 'modules/codec/schema_stringify.h')
-rw-r--r-- | modules/codec/schema_stringify.h | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/modules/codec/schema_stringify.h b/modules/codec/schema_stringify.h deleted file mode 100644 index a82081a..0000000 --- a/modules/codec/schema_stringify.h +++ /dev/null @@ -1,118 +0,0 @@ -#pragma once - -#include "schema.h" - -#include <sstream> -#include <type_traits> - -namespace saw { -template<typename Schema> -struct schema_stringify { - static_assert(always_false<Schema>, "Not supported"); -}; - -template<typename T, size_t Dim> -struct schema_stringify<schema::Array<T,Dim>> { - static void apply(std::stringstream& iss) { - iss << "saw::schema::Array<"; - schema_stringify<T>::apply(iss); - iss << ","; - iss << ct_convert_to_digits<Dim, 10>::literal.view(); - iss << ">"; - } -}; - -template<typename T, size_t N> -struct schema_stringify<schema::Primitive<T,N>> { - static void apply(std::stringstream& iss) { - iss << "saw::schema::Primitive<"; - schema_stringify<T>::apply(iss); - iss << ","; - iss << ct_convert_to_digits<N,10>::literal.view(); - iss << ">"; - } -}; - -template<> -struct schema_stringify<schema::SignedInteger> { - static void apply(std::stringstream& iss) { - iss << "saw:schema::SignedInteger"; - } -}; - -template<> -struct schema_stringify<schema::UnsignedInteger> { - static void apply(std::stringstream& iss) { - iss << "saw:schema::UnsignedInteger"; - } -}; - -template<> -struct schema_stringify<schema::FloatingPoint> { - static void apply(std::stringstream& iss) { - iss << "saw:schema::FloatingPoint"; - } -}; - -template<typename... T> -struct schema_stringify_member { - static void apply(std::stringstream& iss) { - (void)iss; - } -}; - -template<typename T0, string_literal Name, typename... TL> -struct schema_stringify_member<schema::Member<T0,Name>, TL...> { - - static void apply(std::stringstream& iss) { - iss << "saw::schema::Member<"; - schema_stringify<T0>::apply(iss); - iss << ",\""; - iss << Name.view(); - iss << "\">"; - if constexpr ( sizeof...(TL) > 0){ - iss << ","; - schema_stringify_member<TL...>::apply(iss); - } - } -}; - -template<typename... T, string_literal... Lits> -struct schema_stringify<schema::Struct<schema::Member<T,Lits>...>> { - static void apply(std::stringstream& iss) { - iss << "saw::schema::Struct<"; - schema_stringify_member<schema::Member<T,Lits>...>::apply(iss); - iss << ">"; - } -}; - -template<typename... T, string_literal... Lits> -struct schema_stringify<schema::Union<schema::Member<T,Lits>...>> { - static void apply(std::stringstream& iss) { - iss << "saw::schema::Union<"; - schema_stringify_member<schema::Member<T,Lits>...>::apply(iss); - iss << ">"; - } -}; - -template<typename Req, typename Resp> -struct schema_stringify<schema::Function<Req, Resp>> { - static void apply(std::stringstream& iss){ - iss << "saw::schema::Function<"; - schema_stringify<Req>::apply(iss); - iss << ","; - schema_stringify<Resp>::apply(iss); - iss << ">"; - } -}; - -template<typename... T, string_literal... Lits> -struct schema_stringify<schema::Interface<schema::Member<T,Lits>...>>{ - static void apply(std::stringstream& iss){ - iss << "saw::schema::Interface<"; - schema_stringify_member<schema::Member<T,Lits>...>::apply(iss); - iss << ">"; - } -}; - -} |