MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / readObjects

Method readObjects

src/App/Document.cpp:1566–1762  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1564}
1565
1566std::vector<DocumentObject*> Document::readObjects(Base::XMLReader& reader)
1567{
1568 d->touchedObjs.clear();
1569 bool keepDigits = testStatus(Document::KeepTrailingDigits);
1570 setStatus(Document::KeepTrailingDigits, !reader.doNameMapping());
1571 std::vector<DocumentObject*> objs;
1572
1573
1574 // read the object types
1575 reader.readElement("Objects");
1576 int Cnt = static_cast<int>(reader.getAttribute<long>("Count"));
1577
1578 if (!reader.hasAttribute(fcAttrDependencies)) {
1579 d->partialLoadObjects.clear();
1580 }
1581 else if (!d->partialLoadObjects.empty()) {
1582 std::unordered_map<std::string, DepInfo> deps;
1583 for (int i = 0; i < Cnt; i++) {
1584 reader.readElement(fcElementObjectDeps);
1585 int dcount = static_cast<int>(reader.getAttribute<long>(fcAttrDepCount));
1586 if (dcount == 0) {
1587 continue;
1588 }
1589 auto& info = deps[reader.getAttribute<const char*>(fcAttrDepObjName)];
1590 if (reader.hasAttribute(fcAttrDepAllowPartial)) {
1591 info.canLoadPartial =
1592 static_cast<int>(reader.getAttribute<long>(fcAttrDepAllowPartial));
1593 }
1594 for (int j = 0; j < dcount; ++j) {
1595 reader.readElement(fcElementObjectDep);
1596 const char* name = reader.getAttribute<const char*>(fcAttrDepObjName);
1597 if (!Base::Tools::isNullOrEmpty(name)) {
1598 info.deps.insert(name);
1599 }
1600 }
1601 reader.readEndElement(fcElementObjectDeps);
1602 }
1603 std::vector<std::string> strings;
1604 strings.reserve(d->partialLoadObjects.size());
1605 for (auto& v : d->partialLoadObjects) {
1606 strings.emplace_back(v.first.c_str());
1607 }
1608 for (auto& name : strings) {
1609 loadDeps(name, d->partialLoadObjects, deps);
1610 }
1611 if (Cnt > static_cast<int>(d->partialLoadObjects.size())) {
1612 setStatus(Document::PartialDoc, true);
1613 }
1614 else {
1615 for (auto& v : d->partialLoadObjects) {
1616 if (!v.second) {
1617 setStatus(Document::PartialDoc, true);
1618 break;
1619 }
1620 }
1621 if (!testStatus(Document::PartialDoc)) {
1622 d->partialLoadObjects.clear();
1623 }

Callers

nothing calls this directly

Calls 15

isNullOrEmptyFunction · 0.85
loadDepsFunction · 0.85
addObjectFunction · 0.85
readElementMethod · 0.80
hasAttributeMethod · 0.80
readEndElementMethod · 0.80
reserveMethod · 0.80
substrMethod · 0.80
isErrorMethod · 0.80
addRecomputeLogMethod · 0.80
freezeMethod · 0.80

Tested by

no test coverage detected