From f659b9bb7b90092763012de75946e28ff78f2fbb Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Fri, 19 Sep 2025 13:23:04 +0200 Subject: [PATCH] Fix exception in file.from_string() --- src/ifcparse/IfcFile.h | 4 ++-- src/ifcparse/IfcParse.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ifcparse/IfcFile.h b/src/ifcparse/IfcFile.h index e09b147b57..961c56f3fe 100644 --- a/src/ifcparse/IfcFile.h +++ b/src/ifcparse/IfcFile.h @@ -318,9 +318,9 @@ private: const IfcSpfHeader& header() const { return _header; } IfcSpfHeader& header() { return _header; } - static std::string createTimestamp() ; + static std::string createTimestamp(); - const IfcParse::schema_definition* schema() const { return schema_; } + const IfcParse::schema_definition* schema() const; std::pair getUnit(const std::string& unit_type); diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index 0b0191993f..cdcdfc8f64 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -1404,6 +1404,7 @@ IfcFile::IfcFile(std::istream& stream, int length) IfcSpfStream s(stream, length); storage_.emplace<1>(this); std::get(storage_).read_from_stream(&s, schema_, max_id_); + good_ = std::get(storage_).good_; ifcroot_type_ = schema_ ? schema_->declaration_by_name("IfcRoot") : nullptr; byid_ = decltype(byid_)(&std::get(storage_).byid_); @@ -1418,6 +1419,7 @@ IfcFile::IfcFile(void* data, int length) IfcSpfStream s(data, length); storage_.emplace<1>(this); std::get(storage_).read_from_stream(&s, schema_, max_id_); + good_ = std::get(storage_).good_; ifcroot_type_ = schema_ ? schema_->declaration_by_name("IfcRoot") : nullptr; byid_ = decltype(byid_)(&std::get(storage_).byid_); @@ -1431,6 +1433,7 @@ IfcFile::IfcFile(IfcParse::IfcSpfStream* s) { storage_.emplace<1>(this); std::get(storage_).read_from_stream(s, schema_, max_id_); + good_ = std::get(storage_).good_; ifcroot_type_ = schema_ ? schema_->declaration_by_name("IfcRoot") : nullptr; byid_ = decltype(byid_)(&std::get(storage_).byid_); @@ -2512,6 +2515,13 @@ std::string IfcFile::createTimestamp() { return result; } +const IfcParse::schema_definition* IfcFile::schema() const { + if (schema_ == nullptr) { + throw IfcException("No schema loaded"); + } + return schema_; +} + std::vector IfcFile::get_inverse_indices(int instance_id) { std::vector return_value;