summaryrefslogtreecommitdiff
path: root/modules/codec/c++/schema.h
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2024-01-15 17:04:16 +0100
committerClaudius "keldu" Holeksa <mail@keldu.de>2024-01-15 17:04:16 +0100
commitd94c31fee53c3c7df981cf44a54dd722d7fc122c (patch)
tree4f74d240d8db6dc12a8ec1832dfac13eb96dc21b /modules/codec/c++/schema.h
parent830e341a9357556dd15a62b1ce1c74056a506987 (diff)
codec: hash functionality added
Diffstat (limited to 'modules/codec/c++/schema.h')
-rw-r--r--modules/codec/c++/schema.h59
1 files changed, 45 insertions, 14 deletions
diff --git a/modules/codec/c++/schema.h b/modules/codec/c++/schema.h
index 576f378..4549916 100644
--- a/modules/codec/c++/schema.h
+++ b/modules/codec/c++/schema.h
@@ -6,7 +6,9 @@
namespace saw {
namespace schema {
// NOLINTBEGIN
-template <typename T, string_literal Literal> struct Member {};
+template <typename T, string_literal Literal> struct Member {
+ static constexpr string_literal name = "Member";
+};
template <typename... T> struct Struct {
static_assert(
@@ -15,7 +17,9 @@ template <typename... T> struct Struct {
};
template <typename... V, string_literal... K>
-struct Struct<Member<V, K>...> {};
+struct Struct<Member<V, K>...> {
+ static constexpr string_literal name = "Struct";
+};
template <typename... T> struct Union {
static_assert(
@@ -24,13 +28,21 @@ template <typename... T> struct Union {
};
template <typename... V, string_literal... K>
-struct Union<Member<V, K>...> {};
+struct Union<Member<V, K>...> {
+ static constexpr string_literal name = "Union";
+};
-template <typename T, size_t Dim = 1> struct Array {};
+template <typename T, size_t Dim = 1> struct Array {
+ static constexpr string_literal name = "Array";
+};
-template<typename T, size_t... S> struct FixedArray {};
+template<typename T, size_t... S> struct FixedArray {
+ static constexpr string_literal name = "FixedArray";
+};
-template <typename... T> struct Tuple {};
+template <typename... T> struct Tuple {
+ static constexpr string_literal name = "Tuple";
+};
/**
* This acts as a separator of different encodings being mashed together
@@ -43,14 +55,24 @@ template <typename... T> struct Tuple {};
* data<WrappedExample, encode::Json> ex_data;
*/
template <typename T, typename Enc>
-class Wrapper {};
+class Wrapper {
+ static constexpr string_literal name = "Wrapper";
+};
-struct String {};
+struct String {
+ static constexpr string_literal name = "String";
+};
-struct SignedInteger {};
-struct UnsignedInteger {};
-struct FloatingPoint {};
+struct SignedInteger {
+ static constexpr string_literal name = "SignedInteger";
+};
+struct UnsignedInteger {
+ static constexpr string_literal name = "UnsignedInteger";
+};
+struct FloatingPoint {
+ static constexpr string_literal name = "FloatingPoint";
+};
template <class T, size_t N> struct Primitive {
static_assert(((std::is_same_v<T, SignedInteger> ||
@@ -58,6 +80,7 @@ template <class T, size_t N> struct Primitive {
N == 4 || N == 8)) ||
(std::is_same_v<T, FloatingPoint> && (N == 4 || N == 8)),
"Primitive Type is not supported");
+ static constexpr string_literal name = "Primitive";
};
using Int8 = Primitive<SignedInteger, 1>;
@@ -77,7 +100,9 @@ using Float64 = Primitive<FloatingPoint, 8>;
* Classes allowing to distinguish Ints from VarInts
*/
template<typename T, std::size_t MaxLen>
-struct VariableLengthPrimitive {};
+struct VariableLengthPrimitive {
+ static constexpr string_literal name = "VariableLengthPrimitive";
+};
using VarInt = VariableLengthPrimitive<SignedInteger, 5>;
using VarLong = VariableLengthPrimitive<SignedInteger, 10>;
@@ -86,16 +111,22 @@ using VarLong = VariableLengthPrimitive<SignedInteger, 10>;
* Classes enabling Rpc calls
*/
template <class Request, class Response>
-struct Function {};
+struct Function {
+ static constexpr string_literal name = "Function";
+};
template <class... T> struct Interface {
static_assert(
always_false<T...>,
"This schema template doesn't support this type of template argument");
+
+ static constexpr string_literal name = "Interface";
};
template <class... Requests, class... Responses, string_literal... Names>
-struct Interface<Member<Function<Requests, Responses>,Names>...> {};
+struct Interface<Member<Function<Requests, Responses>,Names>...> {
+ static constexpr string_literal name = "Interface";
+};
// NOLINTEND
} // namespace schema