From a49a72e923fe5e33d2f76ec5666090c0769d4e65 Mon Sep 17 00:00:00 2001 From: Krzysztof Jakubowski Date: Sat, 24 Feb 2024 12:50:43 +0100 Subject: [PATCH] Improved spans support in streams loadData & saveData (#9) --- include/fwk/io/stream.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/fwk/io/stream.h b/include/fwk/io/stream.h index a0a82329..579c3f7b 100644 --- a/include/fwk/io/stream.h +++ b/include/fwk/io/stream.h @@ -47,6 +47,9 @@ template class TStream : public Base { template , EnableIf && is_flat_data>...> void loadData(TSpan &); + template >...> void saveData(Span); + template && is_flat_data>...> void loadData(Span); + // TODO: support for serializing vector< >, maybe < > of saveable ? template >...> TStream &operator<<(const T &); template >...> TStream &operator>>(T &); @@ -175,6 +178,16 @@ void TSTREAM::loadData(TSpan &data) { this->loadData(span(data).template reinterpret()); } +TEMPLATE template >...> +void TSTREAM::saveData(Span data) { + this->saveData(data.template reinterpret()); +} + +TEMPLATE template && is_flat_data>...> +void TSTREAM::loadData(Span data) { + this->loadData(data.template reinterpret()); +} + TEMPLATE template >...> TSTREAM &TSTREAM::operator<<(const T &obj) { saveData(cspan(&obj, 1).template reinterpret());