From e3836bc6ec4439cad648795515feccfb02dd4394 Mon Sep 17 00:00:00 2001 From: Claudius 'keldu' Holeksa Date: Wed, 17 Jul 2024 18:12:49 +0200 Subject: Added Ref and Ptr schema types --- modules/codec/c++/schema.hpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/modules/codec/c++/schema.hpp b/modules/codec/c++/schema.hpp index 6a69425..d3c4616 100644 --- a/modules/codec/c++/schema.hpp +++ b/modules/codec/c++/schema.hpp @@ -17,10 +17,10 @@ namespace schema { */ struct Void {}; -template struct Member { +template struct Member { static constexpr string_literal name = "Member"; - using ValueType = T; + using ValueType = Schema; static constexpr string_literal KeyLiteral = Literal; }; @@ -30,8 +30,8 @@ template struct Struct { "This schema template doesn't support this type of template argument"); }; -template -struct Struct...> { +template +struct Struct...> { static constexpr string_literal name = "Struct"; }; @@ -68,11 +68,35 @@ template struct Tuple { * * data ex_data; */ -template +template class Wrapper { static constexpr string_literal name = "Wrapper"; }; +/** + * The schema version of ref. + * See the Ptr comment on this. + */ +template +class Ref { + static constexpr string_literal name = "Ref"; +}; + +/** + * The schema version of ptr + * It has the advantage that if used in the data class + * it won't change the interface of the data instance. + * Meaning that data> acts as if it's data + * in terms of arithmetic operations. It's mostly useful for arrays of primitive types. + * In cases where Array should be translated to a double*. + * In that case we still want the data class as an accesor on the array, so we provide the + * data> type. + */ +template +class Ptr { + static constexpr string_literal name = "Ptr"; +}; + struct String { static constexpr string_literal name = "String"; }; -- cgit v1.2.3