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

Method parseMetadata

src/App/ProjectFile.cpp:361–398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359}
360
361ProjectFile::Metadata ProjectFile::parseMetadata() const
362{
363 auto project = ZipTools::open(stdFile);
364 if (!project) {
365 return {};
366 }
367
368 ProjectFile::Metadata meta;
369 std::unique_ptr<std::istream> str(project->getInputStream("Document.xml"));
370 if (str) {
371 static const std::array gLS = { chLatin_L, chLatin_S, chNull };
372
373 DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(gLS.data());
374 DOMLSParser* domBuilder = impl->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS, nullptr);
375 DOMLSInput* input = impl->createLSInput();
376
377 try {
378 Base::StdInputSource inputSource(*str, stdFile.c_str());
379
380 input->setByteStream(&inputSource);
381 MetaDataParser filter(meta);
382 domBuilder->setFilter(&filter);
383 domBuilder->getDomConfig()->setParameter(XMLUni::fgDOMEntities, false);
384 domBuilder->parse(input);
385 }
386 catch (const XMLException&) {
387 // Do nothing
388 }
389 catch (const DOMException&) {
390 // Do nothing
391 }
392
393 input->release();
394 domBuilder->release();
395 }
396
397 return meta;
398}
399
400ProjectFile::Metadata ProjectFile::getMetadata() const
401{

Callers

nothing calls this directly

Calls 8

openFunction · 0.50
getInputStreamMethod · 0.45
dataMethod · 0.45
c_strMethod · 0.45
setFilterMethod · 0.45
setParameterMethod · 0.45
parseMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected