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

Method getObjects

src/App/ProjectFile.cpp:411–441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

409}
410
411std::list<ProjectFile::Object> ProjectFile::getObjects() const
412{
413 std::list<Object> names;
414 if (!xmlDocument) {
415 return names;
416 }
417
418 DOMNodeList* nodes = xmlDocument->getElementsByTagName(XStrLiteral("Objects").unicodeForm());
419 for (XMLSize_t i = 0; i < nodes->getLength(); i++) {
420 DOMNode* node = nodes->item(i);
421 if (node->getNodeType() == DOMNode::ELEMENT_NODE) {
422 DOMNodeList* objectList = static_cast<DOMElement*>(node)->getElementsByTagName(
423 XStrLiteral("Object").unicodeForm()); // NOLINT
424 for (XMLSize_t j = 0; j < objectList->getLength(); j++) {
425 DOMNode* objectNode = objectList->item(j);
426 DOMNode* typeAttr =
427 objectNode->getAttributes()->getNamedItem(XStrLiteral("type").unicodeForm());
428 DOMNode* nameAttr =
429 objectNode->getAttributes()->getNamedItem(XStrLiteral("name").unicodeForm());
430 if (typeAttr && nameAttr) {
431 Object obj;
432 obj.name = StrX(nameAttr->getNodeValue()).c_str();
433 obj.type = Base::Type::fromName(StrX(typeAttr->getNodeValue()).c_str());
434 names.push_back(obj);
435 }
436 }
437 }
438 }
439
440 return names;
441}
442
443std::list<std::string> ProjectFile::getObjectsOfType(const Base::Type& typeId) const
444{

Callers 4

syncCopyOnChangeMethod · 0.45
getDocumentObjectMethod · 0.45
openDocumentPrivateMethod · 0.45

Calls 7

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

Tested by

no test coverage detected