Fix exception in file.from_string()

This commit is contained in:
Thomas Krijnen
2025-09-19 13:23:04 +02:00
parent 488dee82d7
commit f659b9bb7b
2 changed files with 12 additions and 2 deletions
+2 -2
View File
@@ -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<IfcUtil::IfcBaseClass*, double> getUnit(const std::string& unit_type);
+10
View File
@@ -1404,6 +1404,7 @@ IfcFile::IfcFile(std::istream& stream, int length)
IfcSpfStream s(stream, length);
storage_.emplace<1>(this);
std::get<impl::in_memory_file_storage>(storage_).read_from_stream(&s, schema_, max_id_);
good_ = std::get<impl::in_memory_file_storage>(storage_).good_;
ifcroot_type_ = schema_ ? schema_->declaration_by_name("IfcRoot") : nullptr;
byid_ = decltype(byid_)(&std::get<impl::in_memory_file_storage>(storage_).byid_);
@@ -1418,6 +1419,7 @@ IfcFile::IfcFile(void* data, int length)
IfcSpfStream s(data, length);
storage_.emplace<1>(this);
std::get<impl::in_memory_file_storage>(storage_).read_from_stream(&s, schema_, max_id_);
good_ = std::get<impl::in_memory_file_storage>(storage_).good_;
ifcroot_type_ = schema_ ? schema_->declaration_by_name("IfcRoot") : nullptr;
byid_ = decltype(byid_)(&std::get<impl::in_memory_file_storage>(storage_).byid_);
@@ -1431,6 +1433,7 @@ IfcFile::IfcFile(IfcParse::IfcSpfStream* s)
{
storage_.emplace<1>(this);
std::get<impl::in_memory_file_storage>(storage_).read_from_stream(s, schema_, max_id_);
good_ = std::get<impl::in_memory_file_storage>(storage_).good_;
ifcroot_type_ = schema_ ? schema_->declaration_by_name("IfcRoot") : nullptr;
byid_ = decltype(byid_)(&std::get<impl::in_memory_file_storage>(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<int> IfcFile::get_inverse_indices(int instance_id) {
std::vector<int> return_value;