From f9a02829b6dc45aa1e01ffde9e251b60f1adc102 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Thu, 22 Aug 2024 13:35:12 +0200 Subject: [PATCH] Fixes for arrays of simple type --- src/ifcparse/IfcFile.cpp | 10 +++++----- src/ifcparse/IfcParse.cpp | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ifcparse/IfcFile.cpp b/src/ifcparse/IfcFile.cpp index 27b27c1b2e..27179defc0 100644 --- a/src/ifcparse/IfcFile.cpp +++ b/src/ifcparse/IfcFile.cpp @@ -113,7 +113,7 @@ namespace { possible_aggregation_types_t aggregate_storage; - auto append_to_aggregate_storage = [&aggregate_storage](auto v) { + auto append_to_aggregate_storage = [&aggregate_storage](const auto& v) { if constexpr (is_type_in_variant_v>>) { if (aggregate_storage.which() == 0) { aggregate_storage = std::vector>{ v }; @@ -132,17 +132,17 @@ namespace { }; for (auto& t : p.tokens_) { - boost::apply_visitor([&aggregate_storage, &append_to_aggregate_storage, aggr](auto& v) { + boost::apply_visitor([&aggregate_storage, &append_to_aggregate_storage, aggr](const auto& v) { if constexpr (std::is_same_v, IfcParse::Token>) { // @todo get aggregate of enumeration dispatch_token(v, aggr && aggr->type_of_element()->as_named_type() ? aggr->type_of_element()->as_named_type()->declared_type() : nullptr, append_to_aggregate_storage); } else if constexpr (std::is_same_v, IfcParse::parse_context*>) { + // nested list if constexpr (Depth < 3) { construct_(*v, nullptr, append_to_aggregate_storage); } - // nested list } else { - append_to_aggregate_storage(v); + append_to_aggregate_storage(IfcParse::reference_or_simple_type{ v }); } }, t); } @@ -193,7 +193,7 @@ IfcEntityInstanceData IfcParse::parse_context::construct(int name, unresolved_re auto index = (uint8_t) std::distance(tokens_.begin(), it); - boost::apply_visitor([this, &storage, name, &references_to_resolve, index, param_type](auto& v) { + boost::apply_visitor([this, &storage, name, &references_to_resolve, index, param_type](const auto& v) { if constexpr (std::is_same_v, IfcParse::Token>) { dispatch_token(v, param_type && param_type->as_named_type() ? param_type->as_named_type()->declared_type() : nullptr, [this, &storage, name, &references_to_resolve, index](auto v) { if constexpr (std::is_same_v, IfcParse::reference_or_simple_type>) { diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index a7ba6a6a4b..58a3b16897 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -1385,6 +1385,7 @@ void IfcFile::initialize_(IfcParse::IfcSpfStream* s) { boost::apply_visitor([this, &p](auto& v) { if constexpr (std::is_same_v, reference_or_simple_type>) { byid_[p.first.name_]->data().storage_.set(p.first.index_, boost::apply_visitor([this](auto inst) { + // @todo handle instance not found error IfcUtil::IfcBaseClass* ptr; if constexpr (std::is_same_v) { ptr = this->instance_by_id(inst);