From 78976675150e427efd3aef7c140bb4c308469b90 Mon Sep 17 00:00:00 2001 From: Claudius 'keldu' Holeksa Date: Mon, 29 Jul 2024 15:08:11 +0200 Subject: added Bool --- modules/codec/c++/data.hpp | 25 ++++++++++++++++++++++++- modules/codec/c++/schema.hpp | 11 ++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) (limited to 'modules/codec') 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 { +class data { public: using Schema = schema::Void; using MetaSchema = schema::Void; }; +template<> +class data { +public: + using Schema = schema::Bool; + using MetaSchema = schema::Void; +private: + bool value_; +public: + data():value_{false}{} + data(data):value_{false}{} + + SAW_DEFAULT_COPY(data); + SAW_DEFAULT_MOVE(data); + + void set(bool val){ + value_ = val; + } + + bool get() const { + return value_; + } +}; + template class data, 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 struct Member { static constexpr string_literal name = "Member"; -- cgit v1.2.3