From 3c937f233cfe4f2f22d1b0588cd3ccf58251ad2a Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 19 Mar 2020 13:13:54 -0700 Subject: [PATCH] support copyIn from Struct --- src/data.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/data.cpp b/src/data.cpp index d8d7a7d..19629e7 100644 --- a/src/data.cpp +++ b/src/data.cpp @@ -695,6 +695,35 @@ void Value::copyIn(const void *ptr, StoreType type) } throw NoConvert(); case StoreType::Null: + if(type==StoreType::Compound) { + auto& src = *reinterpret_cast(ptr); + if(src.type()==TypeCode::Struct) { + // copy struct to struct + // all marked source field may be mapped to destination fields + + for(auto& sfld : src.imarked()) { + if(sfld.type()==TypeCode::Struct) { + // entire sub-struct marked + + for(auto& sfld2 : sfld.iall()) { + + if(auto dfld = (*this)[src.nameOf(sfld2)]) { + dfld.copyIn(&sfld2.store->store, sfld2.store->code); + } else { + throw NoField(); + } + } + + } else { + if(auto dfld = (*this)[src.nameOf(sfld)]) { + dfld.copyIn(&sfld.store->store, sfld.store->code); + } else { + throw NoField(); + } + } + } + } + } throw NoConvert(); }