diff --git a/source/forstio/message.h b/source/forstio/message.h index 2001a60..475d32c 100644 --- a/source/forstio/message.h +++ b/source/forstio/message.h @@ -106,7 +106,7 @@ public: SchemaIsArray< typename MessageParameterPackType::Type>::Value, typename Container::template ElementType::Builder>::type - init(size_t size) { + init(size_t size = 0) { auto array_builder = typename Container::template ElementType::Builder{ message.container.template get(), size}; @@ -234,7 +234,7 @@ public: SchemaIsArray< typename MessageParameterPackType::Type>::Value, typename Container::template ElementType::Builder>::type - init(size_t size) { + init(size_t size = 0) { return typename Container::template ElementType::Builder{ message.container.template get(), size}; } @@ -332,6 +332,8 @@ public: } size_t size() const { return message.container.size(); } + + void resize(size_t size) { message.container.resize(size); } }; class Reader { @@ -394,7 +396,7 @@ public: SchemaIsArray< typename MessageParameterPackType::Type>::Value, typename Container::template ElementType::Builder>::type - init(size_t size) { + init(size_t size = 0) { return typename Container::template ElementType::Builder{ message.container.template get(), size}; } diff --git a/source/forstio/proto_kel.h b/source/forstio/proto_kel.h index 1f79d19..51e25c7 100644 --- a/source/forstio/proto_kel.h +++ b/source/forstio/proto_kel.h @@ -4,8 +4,6 @@ #include "message.h" #include "stream_endian.h" -#include - namespace saw { /// @todo replace types with these /* @@ -493,6 +491,8 @@ struct ProtoKelDecodeImpl, Container>> { } } + data.resize(array_length); + for (size_t i = 0; i < array_length; ++i) { Error error = ProtoKelDecodeImpl::decode(