From bd40b7a3ef56bd813b0049cbd2f8e320b193516b Mon Sep 17 00:00:00 2001 From: Patrick Urbanke Date: Sat, 9 Nov 2024 14:52:34 +0100 Subject: [PATCH] Fixed failed array test --- include/rfl/ubjson/Reader.hpp | 11 ++++++----- src/rfl/ubjson/Reader.cpp | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/rfl/ubjson/Reader.hpp b/include/rfl/ubjson/Reader.hpp index 2c9b9120..b0a4fe38 100644 --- a/include/rfl/ubjson/Reader.hpp +++ b/include/rfl/ubjson/Reader.hpp @@ -87,13 +87,14 @@ class Reader { } } - rfl::Result to_array(InputVarType _var) const noexcept; + rfl::Result to_array(const InputVarType& _var) const noexcept; - rfl::Result to_object(InputVarType _var) const noexcept; + rfl::Result to_object( + const InputVarType& _var) const noexcept; template - std::optional read_array(ArrayReader _array_reader, - InputArrayType _arr) const noexcept { + std::optional read_array(const ArrayReader& _array_reader, + const InputArrayType& _arr) const noexcept { for (auto& val : _arr.val_->array_range()) { const auto err = _array_reader.read(InputVarType{&val}); if (err) { @@ -105,7 +106,7 @@ class Reader { template std::optional read_object(const ObjectReader& _object_reader, - InputObjectType _obj) const noexcept { + const InputObjectType& _obj) const noexcept { for (auto& kv : _obj.val_->object_range()) { _object_reader.read(kv.key(), InputVarType{&kv.value()}); } diff --git a/src/rfl/ubjson/Reader.cpp b/src/rfl/ubjson/Reader.cpp index a01a8b3a..17d82e71 100644 --- a/src/rfl/ubjson/Reader.cpp +++ b/src/rfl/ubjson/Reader.cpp @@ -25,7 +25,7 @@ bool Reader::is_empty(const InputVarType& _var) const noexcept { } rfl::Result Reader::to_array( - InputVarType _var) const noexcept { + const InputVarType& _var) const noexcept { if (!_var.val_->is_array()) { return Error("Could not cast to an array."); } @@ -33,7 +33,7 @@ rfl::Result Reader::to_array( } rfl::Result Reader::to_object( - InputVarType _var) const noexcept { + const InputVarType& _var) const noexcept { if (!_var.val_->is_object()) { return Error("Could not cast to an object."); }