MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / load

Method load

src/ifcparse/IfcParse.cpp:525–581  ·  view source on GitHub ↗

Reads the arguments from a list of token Aditionally, registers the ids (i.e. #[\d]+) in the inverse map

Source from the content-addressed store, hash-verified

523// Aditionally, registers the ids (i.e. #[\d]+) in the inverse map
524//
525void 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

Callers 13

qto.pyFile · 0.45
run_code_asterMethod · 0.45
write_results_to_ifcMethod · 0.45
scriptSalome.pyFile · 0.45
createMethod · 0.45
convertMethod · 0.45
createMethod · 0.45
readInstanceMethod · 0.45
read_from_spf_fileFunction · 0.45
cmdlineFunction · 0.45
cmd_foreachFunction · 0.45
__init__Method · 0.45

Calls 9

loadFunction · 0.85
MessageClass · 0.85
to_stringFunction · 0.85
instantiateMethod · 0.80
whatMethod · 0.80
NextMethod · 0.45
pushMethod · 0.45
schemaMethod · 0.45
constructMethod · 0.45

Tested by

no test coverage detected