diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-12-04 12:18:14 +0100 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-12-04 12:18:14 +0100 |
commit | a14896f9ed209dd3f9597722e5a5697bd7dbf531 (patch) | |
tree | 089ca5cbbd206d1921f8f6b53292f5bc1902ca5c /c++/codec/schema_stringify.h | |
parent | 84ecdcbca9e55b1f57fbb832e12ff4fdbb86e7c9 (diff) |
meta: Renamed folder containing source
Diffstat (limited to 'c++/codec/schema_stringify.h')
-rw-r--r-- | c++/codec/schema_stringify.h | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/c++/codec/schema_stringify.h b/c++/codec/schema_stringify.h deleted file mode 100644 index a82081a..0000000 --- a/c++/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 << ">"; - } -}; - -} |