MCPcopy Create free account
hub / github.com/baldurk/renderdoc / XML2Structured

Function XML2Structured

renderdoc/serialise/codecs/xml_codec.cpp:645–933  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

643}
644
645static RDResult XML2Structured(const rdcstr &xml, const ThumbTypeAndData &thumb,
646 const ThumbTypeAndData &extThumb,
647 const std::map<SectionType, bytebuf> &literalFiles,
648 const StructuredBufferList &buffers, RDCFile *rdc, uint64_t &version,
649 StructuredChunkList &chunks, RENDERDOC_ProgressCallback progress)
650{
651 pugi::xml_document doc;
652 doc.load_string(xml.c_str());
653
654 pugi::xml_node root = doc.child("rdc");
655
656 if(!root)
657 RETURN_ERROR_RESULT(ResultCode::FileCorrupted,
658 "Malformed xml document, couldn't get root <rdc> node");
659
660 pugi::xml_node xHeader = root.first_child();
661
662 if(strcmp(xHeader.name(), "header") != 0)
663 RETURN_ERROR_RESULT(ResultCode::FileCorrupted,
664 "Malformed xml document, expected <header> node got <%s>", xHeader.name());
665
666 // process the header and push meta-data into RDC
667 {
668 pugi::xml_node xDriver = xHeader.first_child();
669
670 if(strcmp(xDriver.name(), "driver") != 0)
671 RETURN_ERROR_RESULT(ResultCode::FileCorrupted,
672 "Malformed xml document, expected <driver> node got <%s>", xDriver.name());
673
674 RDCDriver driver = (RDCDriver)xDriver.attribute("id").as_uint();
675 rdcstr driverName = xDriver.text().as_string();
676
677 pugi::xml_node xIdent = xDriver.next_sibling();
678
679 uint64_t machineIdent = xIdent.text().as_ullong();
680
681 pugi::xml_node xThumbnail = xIdent.next_sibling();
682
683 if(strcmp(xThumbnail.name(), "thumbnail") != 0)
684 RETURN_ERROR_RESULT(ResultCode::FileCorrupted,
685 "Malformed xml document, expected <thumbnail> node got <%s>",
686 xThumbnail.name());
687
688 pugi::xml_node xTimebase = xThumbnail.next_sibling();
689
690 uint64_t timeBase = 0;
691 double timeFreq = 1.0;
692
693 // newer XML documents have the timebase here, allow conversion without it
694 if(xTimebase)
695 {
696 if(strcmp(xTimebase.name(), "timebase") != 0)
697 RETURN_ERROR_RESULT(ResultCode::FileCorrupted,
698 "Malformed xml document, expected <timebase> node got <%s>",
699 xTimebase.name());
700
701 timeBase = xTimebase.attribute("base").as_ullong();
702 timeFreq = xTimebase.attribute("frequency").as_double();

Callers 1

importXMLZFunction · 0.85

Calls 15

progressFunction · 0.85
StructuredProgressFunction · 0.85
isLiteralFileChunkNameFunction · 0.85
HexDecodeFunction · 0.85
rdcstrClass · 0.85
XML2ObjFunction · 0.85
load_stringMethod · 0.80
first_childMethod · 0.80
as_uintMethod · 0.80
attributeMethod · 0.80
as_stringMethod · 0.80
next_siblingMethod · 0.80

Tested by

no test coverage detected