summaryrefslogtreecommitdiff
path: root/forstio/codec/schema.h
blob: 915e4eb8423732378c9e19d7ed217f6096e7f238 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#pragma once

#include <forstio/common.h>
#include <forstio/string_literal.h>

namespace saw {
namespace schema {
// NOLINTBEGIN
template <typename T, string_literal Literal> struct NamedMember {};

template <typename... T> struct Struct {
	static_assert(
		always_false<T...>,
		"This schema template doesn't support this type of template argument");
};

template <typename... V, string_literal... K>
struct Struct<NamedMember<V, K>...> {};

template <typename... T> struct Union {
	static_assert(
		always_false<T...>,
		"This schema template doesn't support this type of template argument");
};

template <typename... V, string_literal... K>
struct Union<NamedMember<V, K>...> {};

template <typename T> struct Array {};

template <typename... T> struct Tuple {};

struct String {};

struct SignedInteger {};
struct UnsignedInteger {};
struct FloatingPoint {};

template <class T, size_t N> struct Primitive {
	static_assert(((std::is_same_v<T, SignedInteger> ||
					std::is_same_v<T, UnsignedInteger>)&&(N == 1 || N == 2 ||
														  N == 4 || N == 8)) ||
					  (std::is_same_v<T, FloatingPoint> && (N == 4 || N == 8)),
				  "Primitive Type is not supported");
};

using Int8 = Primitive<SignedInteger, 1>;
using Int16 = Primitive<SignedInteger, 2>;
using Int32 = Primitive<SignedInteger, 4>;
using Int64 = Primitive<SignedInteger, 8>;

using UInt8 = Primitive<UnsignedInteger, 1>;
using UInt16 = Primitive<UnsignedInteger, 2>;
using UInt32 = Primitive<UnsignedInteger, 4>;
using UInt64 = Primitive<UnsignedInteger, 8>;

using Float32 = Primitive<FloatingPoint, 4>;
using Float64 = Primitive<FloatingPoint, 8>;

/**
 * Classes enabling Rpc calls
 */
template <class Request, class Response, string_literal Literal>
struct Function {};

template <class... T> struct Interface {
	static_assert(
		always_false<T...>,
		"This schema template doesn't support this type of template argument");
};

template <class... Request, class... Response, string_literal... Literal>
struct Interface<Function<Request, Response, Literal>...> {};

// NOLINTEND
} // namespace schema
} // namespace saw