Files
IfcOpenShell/src/ifcparse/spf_header.cpp
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

98 lines
3.1 KiB
C++
Raw Normal View History

2026-03-31 15:32:36 +02:00
#include "spf_header.h"
#include "file.h"
static const char* const ISO_10303_21 = "ISO-10303-21";
static const char* const HEADER = "HEADER";
static const char* const ENDSEC = "ENDSEC";
static const char* const DATA = "DATA";
using namespace ifcopenshell;
namespace {
shared_pointer_type make_header_entity(ifcopenshell::file* file, const ifcopenshell::entity& decl, Logger& logger) {
2026-03-31 15:32:36 +02:00
const bool in_memory = file == nullptr || std::visit([](auto& storage) {
return std::is_same_v<std::decay_t<decltype(storage)>, ifcopenshell::impl::in_memory_file_storage>;
}, file->storage_);
if (in_memory) {
return ifcopenshell::make_pointer_type<instance_data>(file, &decl, 0, in_memory_attribute_storage(decl.attribute_count()));
2026-03-31 15:32:36 +02:00
}
return ifcopenshell::make_pointer_type<instance_data>(file, &decl, 0, rocks_db_attribute_storage{});
2026-03-31 15:32:36 +02:00
}
} // namespace
ifcopenshell::spf_header::spf_header(ifcopenshell::file* file)
: file_(file) {
Header_section_schema::get_schema();
header_entities_[0] = make_header_entity(file_, Header_section_schema::file_description::Class());
header_entities_[1] = make_header_entity(file_, Header_section_schema::file_name::Class());
header_entities_[2] = make_header_entity(file_, Header_section_schema::file_schema::Class());
}
ifcopenshell::spf_header::~spf_header() = default;
void spf_header::write(std::ostream& out) const {
out << ISO_10303_21 << ";"
<< "\n";
out << HEADER << ";"
<< "\n";
file_description().to_string(out, true);
out << ";"
<< "\n";
file_name().to_string(out, true);
out << ";"
<< "\n";
file_schema().to_string(out, true);
out << ";"
<< "\n";
out << ENDSEC << ";"
<< "\n";
out << DATA << ";"
<< "\n";
}
2026-04-09 16:18:53 +02:00
void ifcopenshell::spf_header::owner_file(ifcopenshell::file* file) {
2026-03-31 15:32:36 +02:00
file_ = file;
}
void ifcopenshell::spf_header::set_file_description(const shared_pointer_type& data) {
2026-03-31 15:32:36 +02:00
header_entities_[0] = data;
}
void ifcopenshell::spf_header::set_file_name(const shared_pointer_type& data) {
2026-03-31 15:32:36 +02:00
header_entities_[1] = data;
}
void ifcopenshell::spf_header::set_file_schema(const shared_pointer_type& data) {
2026-03-31 15:32:36 +02:00
header_entities_[2] = data;
}
const Header_section_schema::file_description ifcopenshell::spf_header::file_description() const {
return Header_section_schema::file_description(header_entities_[0]);
}
const Header_section_schema::file_name ifcopenshell::spf_header::file_name() const {
return Header_section_schema::file_name(header_entities_[1]);
}
const Header_section_schema::file_schema ifcopenshell::spf_header::file_schema() const {
return Header_section_schema::file_schema(header_entities_[2]);
}
Header_section_schema::file_description ifcopenshell::spf_header::file_description() {
return Header_section_schema::file_description(header_entities_[0]);
}
Header_section_schema::file_name ifcopenshell::spf_header::file_name() {
return Header_section_schema::file_name(header_entities_[1]);
}
Header_section_schema::file_schema ifcopenshell::spf_header::file_schema() {
return Header_section_schema::file_schema(header_entities_[2]);
}