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

Method getObjectsOfType

src/App/ProjectFile.cpp:443–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441}
442
443std::list<std::string> ProjectFile::getObjectsOfType(const Base::Type& typeId) const
444{
445 std::list<std::string> names;
446 if (!xmlDocument) {
447 return names;
448 }
449
450 DOMNodeList* nodes = xmlDocument->getElementsByTagName(XStrLiteral("Objects").unicodeForm());
451 for (XMLSize_t i = 0; i < nodes->getLength(); i++) {
452 DOMNode* node = nodes->item(i);
453 if (node->getNodeType() == DOMNode::ELEMENT_NODE) {
454 DOMNodeList* objectList = static_cast<DOMElement*>(node)->getElementsByTagName(
455 XStrLiteral("Object").unicodeForm()); // NOLINT
456 for (XMLSize_t j = 0; j < objectList->getLength(); j++) {
457 DOMNode* objectNode = objectList->item(j);
458 DOMNode* typeAttr =
459 objectNode->getAttributes()->getNamedItem(XStrLiteral("type").unicodeForm());
460 DOMNode* nameAttr =
461 objectNode->getAttributes()->getNamedItem(XStrLiteral("name").unicodeForm());
462 if (typeAttr && nameAttr) {
463 if (Base::Type::fromName(StrX(typeAttr->getNodeValue()).c_str()) == typeId) {
464 names.emplace_back(StrX(nameAttr->getNodeValue()).c_str());
465 }
466 }
467 }
468 }
469 }
470
471 return names;
472}
473
474bool ProjectFile::restoreObject(const std::string& name, App::PropertyContainer* obj, bool verbose)
475{

Callers

nothing calls this directly

Calls 6

StrXClass · 0.85
unicodeFormMethod · 0.80
itemMethod · 0.80
getAttributesMethod · 0.80
getLengthMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected