| 1497 | } |
| 1498 | |
| 1499 | void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileReader* s, const IfcParse::schema_definition*& schema, unsigned int& max_id, const std::set<std::string>& typed_to_bypass) { |
| 1500 | // Initialize a "C" locale for locale-independent |
| 1501 | // number parsing. See comment above on line 41. |
| 1502 | init_locale(); |
| 1503 | |
| 1504 | tokens = nullptr; |
| 1505 | |
| 1506 | if (!s->size() || s->eof()) { |
| 1507 | // @todo set good on parent file |
| 1508 | good_ = file_open_status::READ_ERROR; |
| 1509 | return; |
| 1510 | } |
| 1511 | |
| 1512 | tokens = new IfcSpfLexer(s); |
| 1513 | |
| 1514 | std::vector<std::string> schemas; |
| 1515 | |
| 1516 | // @todo this line makes no sense |
| 1517 | file->header().file(file); |
| 1518 | |
| 1519 | if (file->header().tryRead()) { |
| 1520 | try { |
| 1521 | schemas = file->header().file_schema()->schema_identifiers(); |
| 1522 | } catch (...) { |
| 1523 | // Purposely empty catch block |
| 1524 | } |
| 1525 | } else { |
| 1526 | good_ = file_open_status::NO_HEADER; |
| 1527 | } |
| 1528 | |
| 1529 | if (schemas.size() == 1) { |
| 1530 | try { |
| 1531 | schema = IfcParse::schema_by_name(schemas.front()); |
| 1532 | } catch (const IfcParse::IfcException& e) { |
| 1533 | good_ = file_open_status::UNSUPPORTED_SCHEMA; |
| 1534 | Logger::Error(e); |
| 1535 | } |
| 1536 | } |
| 1537 | |
| 1538 | if (schema == nullptr) { |
| 1539 | Logger::Message(Logger::LOG_ERROR, "No support for file schema encountered (" + boost::algorithm::join(schemas, ", ") + ")"); |
| 1540 | return; |
| 1541 | } |
| 1542 | |
| 1543 | auto ifcroot_type_ = schema->declaration_by_name("IfcRoot"); |
| 1544 | |
| 1545 | InstanceStreamer streamer(schema, tokens); |
| 1546 | streamer.bypassTypes(typed_to_bypass); |
| 1547 | |
| 1548 | Logger::Status("Scanning file..."); |
| 1549 | |
| 1550 | while (streamer) { |
| 1551 | |
| 1552 | auto inst = streamer.readInstance(); |
| 1553 | |
| 1554 | if (!inst) { |
| 1555 | // No more instances to read |
| 1556 | break; |
no test coverage detected