diff options
-rw-r--r-- | modules/codec/c++/data.hpp | 25 | ||||
-rw-r--r-- | modules/codec/c++/schema.hpp | 11 |
2 files changed, 34 insertions, 2 deletions
diff --git a/modules/codec/c++/data.hpp b/modules/codec/c++/data.hpp index 8e92622..1cd474c 100644 --- a/modules/codec/c++/data.hpp +++ b/modules/codec/c++/data.hpp @@ -90,12 +90,35 @@ private: }; template<> -class data<schema::Void> { +class data<schema::Void, encode::Native> { public: using Schema = schema::Void; using MetaSchema = schema::Void; }; +template<> +class data<schema::Bool, encode::Native> { +public: + using Schema = schema::Bool; + using MetaSchema = schema::Void; +private: + bool value_; +public: + data():value_{false}{} + data(data<MetaSchema, encode::Native>):value_{false}{} + + SAW_DEFAULT_COPY(data); + SAW_DEFAULT_MOVE(data); + + void set(bool val){ + value_ = val; + } + + bool get() const { + return value_; + } +}; + template<typename T, size_t N, typename Storage> class data<schema::Primitive<T,N>, encode::Native, Storage> { public: diff --git a/modules/codec/c++/schema.hpp b/modules/codec/c++/schema.hpp index d3c4616..7df47b3 100644 --- a/modules/codec/c++/schema.hpp +++ b/modules/codec/c++/schema.hpp @@ -15,7 +15,16 @@ namespace schema { /** * Void Type used for function schemas */ -struct Void {}; +struct Void { + static constexpr string_literal name = "Void"; +}; + +/** + * Boolean type + */ +struct Bool { + static constexpr string_literal name = "Bool"; +}; template <typename Schema, string_literal Literal> struct Member { static constexpr string_literal name = "Member"; |