/** Static method that sets the data inside this BoxController from an XML string * * @param xml :: string generated by BoxController::toXMLString() */ void BoxController::fromXMLString(const std::string & xml) { using namespace Poco::XML; Poco::XML::DOMParser pParser; Poco::AutoPtr<Poco::XML::Document> pDoc = pParser.parseString(xml); Poco::XML::Element* pBoxElement = pDoc->documentElement(); std::string s; s = pBoxElement->getChildElement("NumDims")->innerText(); Strings::convert(s, nd); if (nd <= 0 || nd > 20) throw std::runtime_error("BoxController::fromXMLString(): Bad number of dimensions found."); size_t ival; Strings::convert(pBoxElement->getChildElement("MaxId")->innerText(), ival); this->setMaxId(ival); Strings::convert(pBoxElement->getChildElement("SplitThreshold")->innerText(), ival); this->setSplitThreshold(ival); Strings::convert(pBoxElement->getChildElement("MaxDepth")->innerText(), ival); this->setMaxDepth(ival); s = pBoxElement->getChildElement("SplitInto")->innerText(); this->m_splitInto = splitStringIntoVector<size_t>(s); s = pBoxElement->getChildElement("NumMDBoxes")->innerText(); this->m_numMDBoxes = splitStringIntoVector<size_t>(s); s = pBoxElement->getChildElement("NumMDGridBoxes")->innerText(); this->m_numMDGridBoxes = splitStringIntoVector<size_t>(s); this->calcNumSplit(); }
/**Set the xml string from which the dimension will be generated. @param dimensionXMLString : xml string to generate the dimension from. */ void IMDDimensionFactory::setXMLString(const std::string& dimensionXMLString) { Poco::XML::DOMParser pParser; Poco::XML::Document* pDoc = pParser.parseString(dimensionXMLString); Poco::XML::Element* pDimensionElement = pDoc->documentElement(); m_dimensionXML = pDimensionElement; }
/** Execution method to run the extraction. @return implicit function if one could be found, or a NullImplicitFunction. */ Mantid::Geometry::MDImplicitFunction* vtkDataSetToImplicitFunction::execute() { using Mantid::Geometry::NullImplicitFunction; using Mantid::Geometry::MDGeometryXMLDefinitions; std::unique_ptr<Mantid::Geometry::MDImplicitFunction> function = Mantid::Kernel::make_unique<NullImplicitFunction>(); FieldDataToMetadata convert; std::string xmlString = convert(m_dataset->GetFieldData(), XMLDefinitions::metaDataId()); if (false == xmlString.empty()) { Poco::XML::DOMParser pParser; Poco::AutoPtr<Poco::XML::Document> pDoc = pParser.parseString(xmlString); Poco::XML::Element* pRootElem = pDoc->documentElement(); Poco::XML::Element* functionElem = pRootElem->getChildElement(MDGeometryXMLDefinitions::functionElementName()); if(NULL != functionElem) { auto existingFunction = std::unique_ptr<Mantid::Geometry::MDImplicitFunction>( Mantid::API::ImplicitFunctionFactory::Instance() .createUnwrapped(functionElem)); function.swap(existingFunction); } } return function.release(); }
//--------------------------------------------------------- bool ofXml::loadFromBuffer( const string& buffer ) { Poco::XML::DOMParser parser; // release and nullptr out if we already have a document if(document) { document->release(); } try { document = parser.parseString(buffer); element = (Poco::XML::Element*) document->firstChild(); document->normalize(); return true; } catch( const Poco::XML::SAXException & e ) { ofLogError("ofXml") << "parse error: " << e.message(); document = new Poco::XML::Document; element = document->documentElement(); return false; } catch( const exception & e ) { short msg = atoi(e.what()); ofLogError("ofXml") << "parse error: " << DOMErrorMessage(msg); document = new Poco::XML::Document; element = document->documentElement(); return false; } }
const bool BoardListXML::ParseXML(const std::string &xml) { bool parsed=false; Poco::XML::DOMParser dp; dp.setEntityResolver(0); Initialize(); try { Poco::AutoPtr<Poco::XML::Document> doc=dp.parseString(FixCDATA(xml)); Poco::XML::Element *root=XMLGetFirstChild(doc,"BoardList"); Poco::XML::Element *boardel=NULL; boardel=XMLGetFirstChild(root,"Board"); while(boardel) { std::string name=""; std::string description=""; Poco::XML::Element *txt=XMLGetFirstChild(boardel,"Name"); if(txt && txt->firstChild()) { name=SanitizeSingleString(txt->firstChild()->getNodeValue()); StringFunctions::LowerCase(name,name); } txt=XMLGetFirstChild(boardel,"Description"); if(txt && txt->firstChild()) { description=SanitizeSingleString(txt->firstChild()->getNodeValue()); } if(name!="" && description!="") { m_boards.push_back(board(name,description)); } boardel=XMLGetNextSibling(boardel,"Board"); } parsed=true; } catch(...) { } return parsed; }
/** Execution method to run the extraction. @return location string */ std::string vtkDataSetToWsLocation::execute() { using Mantid::Geometry::MDGeometryXMLDefinitions; FieldDataToMetadata convert; std::string xmlString = convert(m_dataset->GetFieldData(), XMLDefinitions::metaDataId()); Poco::XML::DOMParser pParser; Poco::XML::Document* pDoc = pParser.parseString(xmlString); Poco::XML::Element* pRootElem = pDoc->documentElement(); Poco::XML::Element* wsLocationElem = pRootElem->getChildElement(MDGeometryXMLDefinitions::workspaceLocationElementName()); if(wsLocationElem == NULL) { throw std::runtime_error("The element containing the workspace location must be present."); } return wsLocationElem->innerText(); }
/* * Initalize Poco XML Parser */ void LoadGroupXMLFile::initializeXMLParser(const std::string &filename) { const std::string xmlText = Kernel::Strings::loadFile(filename); // Set up the DOM parser and parse xml file Poco::XML::DOMParser pParser; try { m_pDoc = pParser.parseString(xmlText); } catch (Poco::Exception &exc) { throw Kernel::Exception::FileError( exc.displayText() + ". Unable to parse File:", filename); } catch (...) { throw Kernel::Exception::FileError("Unable to parse File:", filename); } // Get pointer to root element m_pRootElem = m_pDoc->documentElement(); if (!m_pRootElem->hasChildNodes()) { throw Kernel::Exception::InstrumentDefinitionError( "No root element in XML instrument file", filename); } }
/** Execution method to run the extraction. @return implicit function if one could be found, or a NullImplicitFunction. */ Mantid::Geometry::MDImplicitFunction* vtkDataSetToImplicitFunction::execute() { using Mantid::MDAlgorithms::NullImplicitFunction; using Mantid::Geometry::MDGeometryXMLDefinitions; Mantid::Geometry::MDImplicitFunction* function = new NullImplicitFunction; FieldDataToMetadata convert; std::string xmlString = convert(m_dataset->GetFieldData(), XMLDefinitions::metaDataId()); if (false == xmlString.empty()) { Poco::XML::DOMParser pParser; Poco::XML::Document* pDoc = pParser.parseString(xmlString); Poco::XML::Element* pRootElem = pDoc->documentElement(); Poco::XML::Element* functionElem = pRootElem->getChildElement(MDGeometryXMLDefinitions::functionElementName()); if(NULL != functionElem) { delete function; function = Mantid::API::ImplicitFunctionFactory::Instance().createUnwrapped(functionElem); } } return function; }
const bool IdentityIntroductionXML::ParseXML(const std::string &xml) { FreenetSSKKey ssk; bool parsed=false; Poco::XML::DOMParser dp; dp.setEntityResolver(0); Initialize(); try { Poco::AutoPtr<Poco::XML::Document> doc=dp.parseString(FixCDATA(xml)); Poco::XML::Element *root=XMLGetFirstChild(doc,"IdentityIntroduction"); Poco::XML::Element *txt=NULL; txt=XMLGetFirstChild(root,"Identity"); if(txt) { if(txt->firstChild()) { m_identity=SanitizeSingleString(txt->firstChild()->getNodeValue()); if(ssk.TryParse(m_identity)==false) { return false; } m_identity=ssk.GetBaseKey(); } } parsed=true; } catch(...) { } return parsed; }
svgtiny_code svgtiny_parse(struct svgtiny_diagram *diagram, const char *buffer, size_t size, const char *url, int viewport_width, int viewport_height) { Poco::XML::Document *document; //Poco::XML::Element *svg; Poco::XML::Element *svg; struct svgtiny_parse_state state; float x, y, width, height; svgtiny_code code; assert(diagram); assert(buffer); assert(url); std::string str(buffer); Poco::XML::DOMParser parser; document = parser.parseString(str); svg = document->documentElement(); //std::cout << svg->localName() << std::endl; if (!svg) return svgtiny_NOT_SVG; if (svg->localName().compare("svg") != 0) return svgtiny_NOT_SVG; /* get graphic dimensions */ state.diagram = diagram; state.document = document; state.viewport_width = viewport_width; state.viewport_height = viewport_height; svgtiny_parse_position_attributes(svg, state, &x, &y, &width, &height); diagram->width = width; diagram->height = height; /* set up parsing state */ state.viewport_width = width; state.viewport_height = height; state.ctm.a = 1; /*(float) viewport_width / (float) width;*/ state.ctm.b = 0; state.ctm.c = 0; state.ctm.d = 1; /*(float) viewport_height / (float) height;*/ state.ctm.e = 0; /*x;*/ state.ctm.f = 0; /*y;*/ /*state.style = css_base_style; state.style.font_size.value.length.value = option_font_size * 0.1;*/ state.fill = 0x000000; state.stroke = svgtiny_TRANSPARENT; state.stroke_width = 1; state.linear_gradient_stop_count = 0; /* parse tree */ code = svgtiny_parse_svg(svg, state, diagram); /* free XML tree */ //xmlFreeDoc(document); return code; }
const bool MessageXML::ParseXML(const std::string &xml) { bool parsed=false; Poco::XML::DOMParser dp; dp.setEntityResolver(0); Initialize(); try { Poco::AutoPtr<Poco::XML::Document> doc=dp.parseString(FixCDATA(xml)); Poco::XML::Element *root=XMLGetFirstChild(doc,"Message"); Poco::XML::Element *txt=NULL; txt=XMLGetFirstChild(root,"Date"); if(txt) { if(txt->firstChild()) { m_date=SanitizeSingleString(txt->firstChild()->getNodeValue()); } } txt=XMLGetFirstChild(root,"Time"); if(txt) { if(txt->firstChild()) { m_time=SanitizeSingleString(txt->firstChild()->getNodeValue()); } } txt=XMLGetFirstChild(root,"Subject"); if(txt) { if(txt->firstChild()) { m_subject=SanitizeSingleString(txt->firstChild()->getNodeValue()); } } txt=XMLGetFirstChild(root,"MessageID"); if(txt) { if(txt->firstChild()) { m_messageid=SanitizeSingleString(txt->firstChild()->getNodeValue()); } } txt=XMLGetFirstChild(root,"ReplyBoard"); if(txt) { if(txt->firstChild()) { m_replyboard=SanitizeSingleString(txt->firstChild()->getNodeValue()); // strip off everything after , in board name if(m_replyboard.find(',')!=std::string::npos) { m_replyboard.erase(m_replyboard.find(',')); } m_replyboard=Board::FixBoardName(m_replyboard); } } txt=XMLGetFirstChild(root,"Body"); if(txt) { if(txt->firstChild()) { m_body=txt->firstChild()->getNodeValue(); } } Poco::XML::Element *boards=XMLGetFirstChild(root,"Boards"); if(boards) { Poco::XML::Element *board=XMLGetFirstChild(boards,"Board"); while(board) { if(board->firstChild()) { std::string boardname=SanitizeSingleString(board->firstChild()->getNodeValue()); // strip off everything after , in board name if(boardname.find(',')!=std::string::npos) { boardname.erase(boardname.find(',')); } boardname=Board::FixBoardName(boardname); m_boards.push_back(boardname); } board=XMLGetNextSibling(board,"Board"); } } Poco::XML::Element *inreplyto=XMLGetFirstChild(root,"InReplyTo"); if(inreplyto) { Poco::XML::Element *message=XMLGetFirstChild(inreplyto,"Message"); while(message) { Poco::XML::Element *orderel=XMLGetFirstChild(message,"Order"); Poco::XML::Element *messageidel=XMLGetFirstChild(message,"MessageID"); if(orderel && orderel->firstChild() && messageidel && messageidel->firstChild()) { int order=-1; std::string messageid=""; StringFunctions::Convert(orderel->firstChild()->getNodeValue(),order); messageid=messageidel->firstChild()->getNodeValue(); if(order!=-1 && messageid!="") { m_inreplyto[order]=messageid; } } message=XMLGetNextSibling(message,"Message"); } } Poco::XML::Element *attachments=XMLGetFirstChild(root,"Attachments"); if(attachments) { Poco::XML::Element *file=XMLGetFirstChild(attachments,"File"); while(file) { Poco::XML::Element *keyel=XMLGetFirstChild(file,"Key"); Poco::XML::Element *sizeel=XMLGetFirstChild(file,"Size"); if(keyel && keyel->firstChild() && sizeel && sizeel->firstChild()) { int size=-1; std::string key=""; StringFunctions::Convert(sizeel->firstChild()->getNodeValue(),size); key=keyel->firstChild()->getNodeValue(); if(size!=-1 && key!="") { m_fileattachments.push_back(fileattachment(key,size)); } } file=XMLGetNextSibling(file,"File"); } } parsed=true; } catch(Poco::Exception &e) { m_lasterror="Caught exception - "+e.displayText(); } catch(...) { } return parsed; }
svgtiny_code svgtiny_parse(svgInfo &info,struct svgtiny_diagram *diagram, const char *buffer,int viewport_width, int viewport_height){ Poco::XML::Document *document; Poco::XML::Element *svg; struct svgtiny_parse_state state; float x, y, width, height; svgtiny_code code; assert(diagram); assert(buffer); string rawXMLstring(buffer); //info.rawXML = rawXMLstring; //parser is statically allocated Poco::XML::DOMParser parser; /* Why does this upset the internal SVG parser? */ //parser.setFeature(Poco::XML::XMLReader::FEATURE_NAMESPACES, false); document = parser.parseString(rawXMLstring); svg = document->documentElement(); //std::cout << svg->localName() << std::endl; if (!svg){ code = svgtiny_NOT_SVG; return code; }else if(svg->localName().compare("svg") != 0){ code= svgtiny_NOT_SVG; return code; }else{ /* get graphic dimensions */ state.diagram = diagram; state.document = document; state.viewport_width = viewport_width; state.viewport_height = viewport_height; svgtiny_parse_position_attributes(svg, state, &x, &y, &width, &height); diagram->width = width; diagram->height = height; /* set up parsing state */ state.viewport_width = width; state.viewport_height = height; state.ctm.a = 1; /*(float) viewport_width / (float) width;*/ state.ctm.b = 0; state.ctm.c = 0; state.ctm.d = 1; /*(float) viewport_height / (float) height;*/ state.ctm.e = 0; /*x;*/ state.ctm.f = 0; /*y;*/ /*state.style = css_base_style; state.style.font_size.value.length.value = option_font_size * 0.1;*/ state.fill = 0x000000; state.stroke = svgtiny_TRANSPARENT; state.stroke_width = 1; state.linear_gradient_stop_count = 0; //borg state.info = &info; /* parse tree */ ofPtr<svgNode> rootnode(new svgNode()); rootnode->type = SVG_TAG_TYPE_DOCUMENT; info.rootnode = rootnode; //store root svg info info.width = ofToString(svg->getAttribute("width").c_str()); info.height = ofToString(svg->getAttribute("height").c_str()); info.x = ofToString(svg->getAttribute("x").c_str()); info.y = ofToString(svg->getAttribute("y").c_str()); info.viewbox = ofToString(svg->getAttribute("viewBox").c_str()); info.id = ofToString(svg->getAttribute("id").c_str()); info.xmlns = ofToString(svg->getAttribute("xmlns").c_str()); info.version = ofToString(svg->getAttribute("version").c_str()); info.preserveAspectRatio = ofToString(svg->getAttribute("preserveAspectRatio").c_str()); code = svgtiny_parse_svg(info,svg, state,rootnode); } /* free XML tree */ //xmlFreeDoc(document); //return without namespace //parser.setFeature(Poco::XML::XMLReader::FEATURE_NAMESPACES, false); //document = parser.parseString(rawXMLstring); return code; }
const bool SoneXML::ParseXML(const std::string &xml) { bool parsed=false; Poco::XML::DOMParser dp; dp.setEntityResolver(0); Initialize(); try { Poco::AutoPtr<Poco::XML::Document> doc=dp.parseString(FixCDATA(xml)); Poco::XML::Element *root=XMLGetFirstChild(doc,"sone"); Poco::XML::Element *posts=NULL; Poco::XML::Element *replies=NULL; Poco::XML::Element *txt=NULL; Poco::XML::Element *profile=NULL; Poco::XML::Element *albums=NULL; if(root) { posts=XMLGetFirstChild(root,"posts"); replies=XMLGetFirstChild(root,"replies"); profile=XMLGetFirstChild(root,"profile"); albums=XMLGetFirstChild(root,"albums"); } if(posts) { txt=XMLGetFirstChild(posts,"post"); while(txt) { std::string id(""); std::string timestr(""); Poco::Timestamp::TimeVal timeval; Poco::DateTime messagetime; std::string messagetext(""); Poco::XML::Element *el; el=XMLGetFirstChild(txt,"id"); if(el && el->firstChild()) { id=el->firstChild()->getNodeValue(); } el=XMLGetFirstChild(txt,"time"); if(el && el->firstChild()) { timestr=el->firstChild()->getNodeValue(); StringFunctions::Convert(timestr,timeval); messagetime=Poco::Timestamp(timeval*static_cast<Poco::Timestamp::TimeVal>(1000)); } el=XMLGetFirstChild(txt,"text"); if(el && el->firstChild()) { messagetext=el->firstChild()->getNodeValue(); } if(id!="" && messagetext!="") { m_messages.push_back(message(messagetime,id,std::string(""),messagetext)); } txt=XMLGetNextSibling(txt,"post"); } } if(replies) { txt=XMLGetFirstChild(replies,"reply"); while(txt) { std::string id(""); std::string replyto(""); std::string timestr(""); Poco::Timestamp::TimeVal timeval; Poco::DateTime messagetime; std::string messagetext(""); Poco::XML::Element *el; el=XMLGetFirstChild(txt,"id"); if(el && el->firstChild()) { id=el->firstChild()->getNodeValue(); } el=XMLGetFirstChild(txt,"post-id"); if(el && el->firstChild()) { replyto=el->firstChild()->getNodeValue(); } el=XMLGetFirstChild(txt,"time"); if(el && el->firstChild()) { timestr=el->firstChild()->getNodeValue(); StringFunctions::Convert(timestr,timeval); messagetime=Poco::Timestamp(timeval*static_cast<Poco::Timestamp::TimeVal>(1000)); } el=XMLGetFirstChild(txt,"text"); if(el && el->firstChild()) { messagetext=el->firstChild()->getNodeValue(); } if(id!="" && messagetext!="") { m_messages.push_back(message(messagetime,id,replyto,messagetext)); } txt=XMLGetNextSibling(txt,"reply"); } } if(profile) { std::string avatarid(""); Poco::XML::Element *avatar=XMLGetFirstChild(profile,"avatar"); if(avatar && avatar->firstChild() && avatar->firstChild()->getNodeValue()!="") { std::string avatarid=avatar->firstChild()->getNodeValue(); if(albums) { Poco::XML::Element *album=XMLGetFirstChild(albums,"album"); while(album) { Poco::XML::Element *images=XMLGetFirstChild(album,"images"); if(images) { Poco::XML::Element *image=XMLGetFirstChild(images,"image"); while(image) { Poco::XML::Element *imid=XMLGetFirstChild(image,"id"); if(imid && imid->firstChild()) { if(imid->firstChild()->getNodeValue()==avatarid) { Poco::XML::Element *key=XMLGetFirstChild(image,"key"); if(key && key->firstChild()) { m_avatar=key->firstChild()->getNodeValue(); } } } image=XMLGetNextSibling(image,"image"); } } album=XMLGetNextSibling(album,"album"); } } } } parsed=true; } catch(...) { } return parsed; }
void TskPipeline::initialize(const std::string & pipelineConfig) { if (pipelineConfig.empty()) { throw TskException("TskPipeline::initialize: Pipeline configuration string is empty."); } try { Poco::XML::DOMParser parser; Poco::AutoPtr<Poco::XML::Document> xmlDoc = parser.parseString(pipelineConfig); // Get all Module elements Poco::AutoPtr<Poco::XML::NodeList> modules = xmlDoc->getElementsByTagName(TskPipeline::MODULE_ELEMENT); if (modules->length() == 0) { LOGWARN(L"TskPipeline::initialize - No modules found in config file."); return; } // Size our list based on the number of modules m_modules.resize(modules->length()); // Iterate through the module elements, make sure they are increasing order // we now allow for gaps to make it easier to comment things out. int prevOrder = -1; for (unsigned int i = 0; i < modules->length(); i++) { Poco::XML::Node * pNode = modules->item(i); Poco::XML::Element* pElem = dynamic_cast<Poco::XML::Element*>(pNode); Poco::XML::XMLString orderStr = pElem->getAttribute(TskPipeline::MODULE_ORDER_ATTR); if (orderStr == "") { throw TskException("TskPipeline::initialize: Module order missing."); } int order; try { order = Poco::NumberParser::parse(orderStr); } catch (Poco::SyntaxException ex) { std::stringstream msg; msg << "TskPipeline::initialize - Module order must a decimal number. Got " << orderStr.c_str(); throw TskException(msg.str()); } if (order <= prevOrder) { std::stringstream msg; msg << "TskPipeline::initialize - Expecting order bigger than " << prevOrder << ", got " << order; throw TskException(msg.str()); } prevOrder = order; } // Iterate through the module elements creating a new Module for each one m_modules.clear(); for (unsigned int i = 0; i < modules->length(); i++) { Poco::XML::Node * pNode = modules->item(i); Poco::XML::Element* pElem = dynamic_cast<Poco::XML::Element*>(pNode); if (!pElem) continue; // Create a new module TskModule * pModule = createModule(pElem); if (pModule == NULL) { throw TskException("TskPipeline::initialize - Module creation failed."); } if (m_loadDll) { TskImgDB& imgDB = TskServices::Instance().getImgDB(); // Insert into Modules table int moduleId = 0; if (imgDB.addModule(pModule->getName(), pModule->getDescription(), moduleId)) { std::stringstream errorMsg; errorMsg << "TskPipeline::initialize - Failed to insert into Modules table. " << " module name=" << pModule->getName() ; throw TskException(errorMsg.str()); } else { pModule->setModuleId(moduleId); m_moduleNames.insert(std::make_pair(moduleId, pModule->getName())); m_moduleExecTimes.insert(std::make_pair(moduleId, Poco::Timespan())); } bool duplicate = false; for (std::vector<TskModule*>::iterator it = m_modules.begin(); it != m_modules.end(); it++) { if ((*it)->getModuleId() == pModule->getModuleId()) { duplicate = true; std::stringstream msg; msg << "TskPipeline::initialize - " << pModule->getName() << " is a duplicate module. " << "The duplicate will not be added to the pipeline"; throw TskException(msg.str()); } } if (!duplicate) m_modules.push_back(pModule); } } } // rethrow this, otherwise it is caught by std::exception and we lose the detail. catch (TskException& ex) { throw(ex); } catch (std::exception& ex) { std::stringstream errorMsg; errorMsg << "TskPipeline::initialize - Pipeline initialization failed: " <<ex.what() ; throw TskException(errorMsg.str()); } }
/** Peforms the processing associated with these transformations. */ void MDGeometryXMLParser::execute() { Poco::XML::DOMParser pParser; Poco::AutoPtr<Poco::XML::Document> pDoc = pParser.parseString(m_xmlToProcess); Poco::XML::Element *pRootElem = pDoc->documentElement(); // Apply root node checking if supplied. Poco::XML::Element *geometryXMLElement = nullptr; if (!m_rootNodeName.empty()) { Poco::XML::Element *temp = pRootElem->getChildElement(m_rootNodeName); geometryXMLElement = temp; if (geometryXMLElement == nullptr) { std::string message = "Root node was not found to be the expected value of " + m_rootNodeName; throw std::runtime_error(message); } } else { // The default is to take the root node to be the geometry xml element. geometryXMLElement = pRootElem; } Poco::AutoPtr<Poco::XML::NodeList> dimensionsXML = geometryXMLElement->getElementsByTagName( MDGeometryXMLDefinitions::workspaceDimensionElementName()); size_t nDimensions = dimensionsXML->length(); VecIMDDimension_sptr vecAllDims(nDimensions); ////Extract dimensions for (size_t i = 0; i < nDimensions; i++) { Poco::XML::Element *dimensionXML = static_cast<Poco::XML::Element *>( dimensionsXML->item(static_cast<unsigned long>(i))); vecAllDims[i] = createDimension(*dimensionXML); } VecIMDDimension_sptr vecNonMappedDims = vecAllDims; Poco::XML::Element *xDimensionElement = geometryXMLElement->getChildElement( MDGeometryXMLDefinitions::workspaceXDimensionElementName()); std::string xDimId = xDimensionElement ->getChildElement( MDGeometryXMLDefinitions::workspaceRefDimensionElementName()) ->innerText(); if (!xDimId.empty()) { auto xDimensionIt = find_if(vecAllDims.begin(), vecAllDims.end(), findID(xDimId)); if (xDimensionIt == vecAllDims.end()) { throw std::invalid_argument("Cannot determine x-dimension mapping."); } m_xDimension = *xDimensionIt; vecNonMappedDims.erase(std::remove_if(vecNonMappedDims.begin(), vecNonMappedDims.end(), findID(xDimId)), vecNonMappedDims.end()); } Poco::XML::Element *yDimensionElement = geometryXMLElement->getChildElement( MDGeometryXMLDefinitions::workspaceYDimensionElementName()); std::string yDimId = yDimensionElement ->getChildElement( MDGeometryXMLDefinitions::workspaceRefDimensionElementName()) ->innerText(); if (!yDimId.empty()) { auto yDimensionIt = find_if(vecAllDims.begin(), vecAllDims.end(), findID(yDimId)); if (yDimensionIt == vecAllDims.end()) { throw std::invalid_argument("Cannot determine y-dimension mapping."); } m_yDimension = *yDimensionIt; vecNonMappedDims.erase(std::remove_if(vecNonMappedDims.begin(), vecNonMappedDims.end(), findID(yDimId)), vecNonMappedDims.end()); } Poco::XML::Element *zDimensionElement = geometryXMLElement->getChildElement( MDGeometryXMLDefinitions::workspaceZDimensionElementName()); std::string zDimId = zDimensionElement ->getChildElement( MDGeometryXMLDefinitions::workspaceRefDimensionElementName()) ->innerText(); if (!zDimId.empty()) { auto zDimensionIt = find_if(vecAllDims.begin(), vecAllDims.end(), findID(zDimId)); if (zDimensionIt == vecAllDims.end()) { throw std::invalid_argument("Cannot determine z-dimension mapping."); } m_zDimension = *zDimensionIt; vecNonMappedDims.erase(std::remove_if(vecNonMappedDims.begin(), vecNonMappedDims.end(), findID(zDimId)), vecNonMappedDims.end()); } Poco::XML::Element *tDimensionElement = geometryXMLElement->getChildElement( MDGeometryXMLDefinitions::workspaceTDimensionElementName()); std::string tDimId = tDimensionElement ->getChildElement( MDGeometryXMLDefinitions::workspaceRefDimensionElementName()) ->innerText(); if (!tDimId.empty()) { auto tDimensionIt = find_if(vecAllDims.begin(), vecAllDims.end(), findID(tDimId)); if (tDimensionIt == vecAllDims.end()) { throw std::invalid_argument("Cannot determine t-dimension mapping."); } m_tDimension = *tDimensionIt; if (!vecNonMappedDims.empty()) { vecNonMappedDims.erase(std::remove_if(vecNonMappedDims.begin(), vecNonMappedDims.end(), findID(tDimId)), vecNonMappedDims.end()); } } m_vecNonMappedDims = vecNonMappedDims; // Copy with strong guarantee. m_vecAllDims = vecAllDims; m_executed = true; }