From c1c2f367d3adaa0df80cf9ad11674cf21fc00077 Mon Sep 17 00:00:00 2001 From: Patrick Urbanke Date: Sun, 21 Jan 2024 15:06:13 +0100 Subject: [PATCH] Implemented the read function --- include/rfl/cbor/read.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/rfl/cbor/read.hpp b/include/rfl/cbor/read.hpp index 81a6405a..ac0ee0bd 100644 --- a/include/rfl/cbor/read.hpp +++ b/include/rfl/cbor/read.hpp @@ -1,7 +1,7 @@ #ifndef RFL_CBOR_READ_HPP_ #define RFL_CBOR_READ_HPP_ -#include +#include #include #include @@ -23,14 +23,14 @@ auto read(const InputVarType& _obj) { return Parser::read(r, _obj); } -/// Parses an object from flexbuf using reflection. +/// Parses an object from CBOR using reflection. template -Result> read(char* _bytes, +Result> read(const char* _bytes, const size_t _size) { - Reader::CBORValue value; - value.val_.value.v_doc.data_len = static_cast(_size); - value.val_.value.v_doc.data = reinterpret_cast(_bytes); - value.val_.value_type = CBOR_TYPE_DOCUMENT; + CborParser parser; + CborValue value; + cbor_parser_init(reinterpret_cast(_bytes), _size, 0, &parser, + &value); auto doc = InputVarType{&value}; auto result = read(doc); return result;