Reads the arguments from a list of token Aditionally, registers the ids (i.e. #[\d]+) in the inverse map
| 523 | // Aditionally, registers the ids (i.e. #[\d]+) in the inverse map |
| 524 | // |
| 525 | void IfcParse::impl::in_memory_file_storage::load(boost::optional<size_t> entity_instance_name, const IfcParse::entity* entity, parse_context& context, int attribute_index) { |
| 526 | Token next = tokens->Next(); |
| 527 | |
| 528 | /* |
| 529 | if (TokenFunc::isOperator(next, '(')) { |
| 530 | next = tokens->Next(); |
| 531 | } |
| 532 | */ |
| 533 | |
| 534 | size_t attribute_index_within_data = 0; |
| 535 | size_t return_value = 0; |
| 536 | |
| 537 | while ((next.startPos != 0U) || (next.lexer != nullptr)) { |
| 538 | if (TokenFunc::isOperator(next, ',')) { |
| 539 | if (attribute_index == -1) { |
| 540 | attribute_index_within_data += 1; |
| 541 | } |
| 542 | } else if (TokenFunc::isOperator(next, ')')) { |
| 543 | break; |
| 544 | } else if (TokenFunc::isOperator(next, '(')) { |
| 545 | return_value++; |
| 546 | load(entity_instance_name, entity, context.push(), attribute_index == -1 ? (int) attribute_index_within_data : attribute_index); |
| 547 | } else { |
| 548 | return_value++; |
| 549 | if (TokenFunc::isIdentifier(next) && entity && entity_instance_name) { |
| 550 | register_inverse(*entity_instance_name, entity, next.value_int, attribute_index == -1 ? (int) attribute_index_within_data : attribute_index); |
| 551 | } |
| 552 | |
| 553 | if (TokenFunc::isKeyword(next)) { |
| 554 | try { |
| 555 | const auto* decl = (schema ? schema : file->schema())->declaration_by_name(TokenFunc::asStringRef(next)); |
| 556 | parse_context ps; |
| 557 | tokens->Next(); |
| 558 | // The only case we know where a defined type contains entity |
| 559 | // instance references is IfcPropertySetDefinitionSet. For |
| 560 | // that purpose we propagate the entity_instance_name to |
| 561 | // register inverses to the host entity (and not the defined |
| 562 | // type) and to be able to actually register the references in |
| 563 | // the 2nd pass. |
| 564 | load(entity_instance_name, entity, ps, attribute_index == -1 ? (int)attribute_index_within_data : attribute_index); |
| 565 | auto* simple_type_instance = (schema ? schema : file->schema())->instantiate(decl, ps.construct(entity_instance_name, *references_to_resolve, decl, boost::none, attribute_index == -1 ? (int)attribute_index_within_data : attribute_index)); |
| 566 | read_simple_type_instances.emplace_back(simple_type_instance); |
| 567 | //@todo decide addEntity(((IfcUtil::IfcBaseClass*)*entity)); |
| 568 | context.push(simple_type_instance); |
| 569 | simple_type_instance->file_ = file; |
| 570 | } catch (IfcException& e) { |
| 571 | Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + " at offset " + std::to_string(next.startPos)); |
| 572 | // #4070 We didn't actually capture an aggregate entry, undo length increment. |
| 573 | return_value--; |
| 574 | } |
| 575 | } else { |
| 576 | context.push(next); |
| 577 | } |
| 578 | } |
| 579 | next = tokens->Next(); |
| 580 | } |
| 581 | } |
| 582 |
no test coverage detected