header.assign() helper

This commit is contained in:
Thomas Krijnen
2026-06-24 11:12:21 +02:00
parent 1057f794f6
commit a9d6776875
2 changed files with 24 additions and 0 deletions
+22
View File
@@ -181,6 +181,28 @@ bool IfcSpfHeader::tryRead() {
}
}
void IfcParse::IfcSpfHeader::assign(const IfcSpfHeader& other) {
if (this != &other) {
auto copy_inst = [](IfcUtil::IfcBaseEntity* new_entity, IfcUtil::IfcBaseEntity* entity, const IfcParse::entity* decl, IfcParse::impl::in_memory_file_storage* own_storage, IfcParse::impl::in_memory_file_storage* other_storage) {
for (size_t i = 0; i < decl->attribute_count(); ++i) {
entity->data().apply_visitor(other_storage, decl, entity->identity(), [i, decl, new_entity, own_storage](const auto& v) {
using U = std::decay_t<decltype(v)>;
if constexpr (std::is_same_v<U, IfcUtil::IfcBaseClass*>) {
} else if constexpr (std::is_same_v<U, aggregate_of_instance::ptr>) {
} else if constexpr (std::is_same_v<U, aggregate_of_aggregate_of_instance::ptr>) {
} else {
new_entity->set_attribute_value(i, v);
}
}, i);
}
};
copy_inst(file_description_, other.file_description_, &Header_section_schema::file_description::Class(), storage_, other.storage_);
copy_inst(file_name_, other.file_name_, &Header_section_schema::file_name::Class(), storage_, other.storage_);
copy_inst(file_schema_, other.file_schema_, &Header_section_schema::file_schema::Class(), storage_, other.storage_);
}
}
void IfcSpfHeader::write(std::ostream& out) const {
out << ISO_10303_21 << ";"
<< "\n";
+2
View File
@@ -60,6 +60,8 @@ class IFC_PARSE_API IfcSpfHeader {
void read();
bool tryRead();
void assign(const IfcSpfHeader& other);
void write(std::ostream& out) const;
const Header_section_schema::file_description* file_description() const;