diff --git a/src/ifcparse/IfcFile.cpp b/src/ifcparse/IfcFile.cpp index 7c964d3fda..bd312d51cb 100644 --- a/src/ifcparse/IfcFile.cpp +++ b/src/ifcparse/IfcFile.cpp @@ -46,13 +46,6 @@ namespace { template constexpr bool is_type_in_variant_v = is_type_in_variant::value; - struct InstanceReference { - int v; - operator int() const { - return v; - } - }; - template void dispatch_token(int instance_id, int attribute_id, IfcParse::Token t, IfcParse::declaration* decl, Fn fn) { if (t.type == IfcParse::Token_BINARY) { @@ -75,7 +68,7 @@ namespace { } else if (t.type == IfcParse::Token_FLOAT) { fn(IfcParse::TokenFunc::asFloat(t)); } else if (t.type == IfcParse::Token_IDENTIFIER) { - fn(IfcParse::reference_or_simple_type{ InstanceReference{ IfcParse::TokenFunc::asIdentifier(t) } }); + fn(IfcParse::reference_or_simple_type{ IfcParse::InstanceReference{ IfcParse::TokenFunc::asIdentifier(t), t.startPos } }); } else if (t.type == IfcParse::Token_INT) { fn(IfcParse::TokenFunc::asInt(t)); } else if (t.type == IfcParse::Token_STRING) { diff --git a/src/ifcparse/IfcFile.h b/src/ifcparse/IfcFile.h index a61c9f94b7..acfe6f4c89 100644 --- a/src/ifcparse/IfcFile.h +++ b/src/ifcparse/IfcFile.h @@ -66,7 +66,15 @@ class IFC_PARSE_API file_open_status { } }; -typedef boost::variant reference_or_simple_type; +struct InstanceReference { + int v; + size_t file_offset; + operator int() const { + return v; + } +}; + +typedef boost::variant reference_or_simple_type; typedef std::list, std::vector>>>> unresolved_references; struct parse_context { diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index 2eec8ea867..021b9a1099 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -1423,10 +1423,10 @@ void IfcFile::initialize_(IfcParse::IfcSpfStream* s) { const auto& ref = p.first.name_; const auto& refattr = p.first.index_; if (auto* v = boost::get(&p.second)) { - if (auto* name = boost::get(v)) { + if (auto* name = boost::get(v)) { entity_by_id_t::const_iterator it = byid_.find(*name); if (it == byid_.end()) { - Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found"); + Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset)); } else { byid_[p.first.name_]->data().storage_.set(p.first.index_, it->second); } @@ -1437,10 +1437,10 @@ void IfcFile::initialize_(IfcParse::IfcSpfStream* s) { aggregate_of_instance::ptr instances(new aggregate_of_instance); instances->reserve(v->size()); for (const auto& vi : *v) { - if (auto* name = boost::get(&vi)) { + if (auto* name = boost::get(&vi)) { entity_by_id_t::const_iterator it = byid_.find(*name); if (it == byid_.end()) { - Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found"); + Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset)); } else { instances->push(it->second); } @@ -1454,10 +1454,10 @@ void IfcFile::initialize_(IfcParse::IfcSpfStream* s) { for (const auto& vi : *v) { std::vector inner; for (const auto& vii : vi) { - if (auto* name = boost::get(&vii)) { + if (auto* name = boost::get(&vii)) { entity_by_id_t::const_iterator it = byid_.find(*name); if (it == byid_.end()) { - Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found"); + Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset)); } else { inner.push_back(it->second); }