| 548 | } // ~unnamed namespace |
| 549 | |
| 550 | void POSTFIX_SCHEMA(XmlSerializer)::finalize() { |
| 551 | POSTFIX_SCHEMA(argument_name_map).insert(std::make_pair("GlobalId", "id")); |
| 552 | |
| 553 | IfcSchema::IfcProject::list::ptr projects = file->instances_by_type<IfcSchema::IfcProject>(); |
| 554 | if (projects->size() != 1) { |
| 555 | Logger::Message(Logger::LOG_ERROR, "Expected a single IfcProject"); |
| 556 | return; |
| 557 | } |
| 558 | IfcSchema::IfcProject* project = *projects->begin(); |
| 559 | |
| 560 | ptree root, header, units, decomposition, properties, quantities, types, layers, materials, work, calendars, connections, groups; |
| 561 | |
| 562 | auto catch_exceptions = [this](const auto& fn) { |
| 563 | try { |
| 564 | return fn(); |
| 565 | } catch(const std::exception& e) { |
| 566 | Logger::Error(e); |
| 567 | static std::invoke_result_t<decltype(fn)> v; |
| 568 | return v; |
| 569 | } |
| 570 | }; |
| 571 | |
| 572 | // Write the SPF header as XML nodes. |
| 573 | BOOST_FOREACH(const std::string & s, catch_exceptions([this]() { return file->header().file_description()->description(); })) { |
| 574 | header.add_child("file_description.description", ptree(s)); |
| 575 | } |
| 576 | BOOST_FOREACH(const std::string& s, catch_exceptions([this]() { return file->header().file_name()->author(); })) { |
| 577 | header.add_child("file_name.author", ptree(s)); |
| 578 | } |
| 579 | BOOST_FOREACH(const std::string& s, catch_exceptions([this]() { return file->header().file_name()->organization(); })) { |
| 580 | header.add_child("file_name.organization", ptree(s)); |
| 581 | } |
| 582 | BOOST_FOREACH(const std::string& s, catch_exceptions([this]() { return file->header().file_schema()->schema_identifiers(); })) { |
| 583 | header.add_child("file_schema.schema_identifiers", ptree(s)); |
| 584 | } |
| 585 | try { |
| 586 | header.put("file_description.implementation_level", file->header().file_description()->implementation_level()); |
| 587 | } |
| 588 | catch (const IfcParse::IfcException& ex) { |
| 589 | std::stringstream ss; |
| 590 | ss << "Failed to get ifc file header file_description implementation_level, error: '" << ex.what() << "'"; |
| 591 | Logger::Message(Logger::LOG_ERROR, ss.str()); |
| 592 | } |
| 593 | try { |
| 594 | header.put("file_name.name", file->header().file_name()->name()); |
| 595 | } |
| 596 | catch (const IfcParse::IfcException& ex) { |
| 597 | std::stringstream ss; |
| 598 | ss << "Failed to get ifc file header file_name name, error: '" << ex.what() << "'"; |
| 599 | Logger::Message(Logger::LOG_ERROR, ss.str()); |
| 600 | } |
| 601 | try { |
| 602 | header.put("file_name.time_stamp", file->header().file_name()->time_stamp()); |
| 603 | } |
| 604 | catch (const IfcParse::IfcException& ex) { |
| 605 | std::stringstream ss; |
| 606 | ss << "Failed to get ifc file header file_name time_stamp, error: '" << ex.what() << "'"; |
| 607 | Logger::Message(Logger::LOG_ERROR, ss.str()); |
nothing calls this directly
no test coverage detected