diff --git a/include/rfl/flatbuf/Writer.hpp b/include/rfl/flatbuf/Writer.hpp index a904e868..79af5488 100644 --- a/include/rfl/flatbuf/Writer.hpp +++ b/include/rfl/flatbuf/Writer.hpp @@ -175,7 +175,7 @@ class Writer { template OutputVarType add_value_to_union(const size_t _index, const T& _var, OutputUnionType* _parent) const noexcept { - return OutputVarType{}; + // TODO } void end_array(OutputArrayType* _arr) const noexcept { _arr->end(); } diff --git a/src/rfl/flatbuf/FlatbufOutputArray.cpp b/src/rfl/flatbuf/FlatbufOutputArray.cpp index b11eaaa3..7547849b 100644 --- a/src/rfl/flatbuf/FlatbufOutputArray.cpp +++ b/src/rfl/flatbuf/FlatbufOutputArray.cpp @@ -71,16 +71,12 @@ flatbuffers::uoffset_t FlatbufOutputArray::build_vector( throw std::runtime_error("TODO"); // TODO } else if constexpr (std::is_same()) { - /// The type of the offset does not matter...it is not used in any way - /// by CreateVector. return do_create(TypeWrapper>{}); } else if constexpr (std::is_same()) { throw std::runtime_error("TODO"); // TODO } else if constexpr (std::is_same()) { - /// The type of the offset does not matter...it is not used in any way - /// by CreateVector. return do_create(TypeWrapper>{}); } else if constexpr (std::is_same()) { @@ -88,11 +84,9 @@ flatbuffers::uoffset_t FlatbufOutputArray::build_vector( throw std::runtime_error("type_ptr not set for '" + _t.type_name + "'."); } - build_vector(*_t.type_ptr); + return build_vector(*_t.type_ptr); } else if constexpr (std::is_same()) { - /// The type of the offset does not matter...it is not used in any way - /// by CreateVector. return do_create(TypeWrapper>{}); } else if constexpr (std::is_same()) { diff --git a/src/rfl/flatbuf/Writer.cpp b/src/rfl/flatbuf/Writer.cpp index 0ab3182d..ec5695ba 100644 --- a/src/rfl/flatbuf/Writer.cpp +++ b/src/rfl/flatbuf/Writer.cpp @@ -18,7 +18,7 @@ Writer::~Writer() = default; Writer::OutputObjectType Writer::object_as_root(const size_t _size) const { if (!schema_->root_type_.type_ptr) { - throw std::runtime_error("Root type not set."); + throw std::runtime_error("Root type ptr not set."); } return OutputObjectType( schema_->root_type_.type_ptr->convert_to(), nullptr, @@ -26,7 +26,11 @@ Writer::OutputObjectType Writer::object_as_root(const size_t _size) const { } Writer::OutputArrayType Writer::add_array_to_array( - const size_t _size, OutputArrayType* _parent) const noexcept {} + const size_t _size, OutputArrayType* _parent) const noexcept { + return OutputArrayType( + _parent->schema().type->convert_to(), _parent, + fbb_.get()); +} Writer::OutputArrayType Writer::add_array_to_map( const std::string_view& _name, const size_t _size, @@ -35,9 +39,9 @@ Writer::OutputArrayType Writer::add_array_to_map( Writer::OutputArrayType Writer::add_array_to_object( const std::string_view& _name, const size_t _size, OutputObjectType* _parent) const { - const auto schema = - _parent->get_current_schema().convert_to(); - return OutputArrayType(schema, _parent, fbb_.get()); + return OutputArrayType( + _parent->get_current_schema().convert_to(), _parent, + fbb_.get()); } Writer::OutputArrayType Writer::add_array_to_union( @@ -60,7 +64,11 @@ Writer::OutputMapType Writer::add_map_to_union( OutputUnionType* _parent) const noexcept {} Writer::OutputObjectType Writer::add_object_to_array( - const size_t _size, OutputArrayType* _parent) const noexcept {} + const size_t _size, OutputArrayType* _parent) const noexcept { + return OutputObjectType( + _parent->schema().type->convert_to(), _parent, + fbb_.get()); +} Writer::OutputObjectType Writer::add_object_to_map( const std::string_view& _name, const size_t _size, @@ -68,7 +76,11 @@ Writer::OutputObjectType Writer::add_object_to_map( Writer::OutputObjectType Writer::add_object_to_object( const std::string_view& _name, const size_t _size, - OutputObjectType* _parent) const noexcept {} + OutputObjectType* _parent) const noexcept { + return OutputObjectType( + _parent->get_current_schema().convert_to(), _parent, + fbb_.get()); +} Writer::OutputObjectType Writer::add_object_to_union( const size_t _index, const size_t _size,