QStringList DicomImageSet::getOrderedDcmFiles(const QString &datasetFileName, const QString & queryString) { HRESULT hr = S_OK; IXMLDOMDocument *pXMLDom = NULL; IXMLDOMNodeList *pFileNodes = NULL; VARIANT_BOOL varStatus; VARIANT varFileName; BSTR bstrQuery; QStringList fileList; CHK_HR(CreateAndInitDOM(&pXMLDom)); CHK_HR(VariantFromString(datasetFileName.toStdWString().c_str(), varFileName)); CHK_HR(pXMLDom->load(varFileName, &varStatus)); if (varStatus != VARIANT_TRUE) { CHK_HR(ReportParseError(pXMLDom, "Failed to load DOM from stocks.xml.")); } bstrQuery = SysAllocString(queryString.toStdWString().c_str()); CHK_ALLOC(bstrQuery); CHK_HR(pXMLDom->selectNodes(bstrQuery, &pFileNodes)); if (pFileNodes) { long nFiles; CHK_HR(pFileNodes->get_length(&nFiles)); for (long i=0; i<nFiles; ++i) { VARIANT varValue; IXMLDOMNode * pFile = NULL; CHK_HR(pFileNodes->get_item(i, &pFile)); CHK_HR(GetAttributeFromNode(pFile, L"path", &varValue)); fileList <<QString::fromWCharArray(_bstr_t(varValue)); SAFE_RELEASE(pFile); } } CleanUp: SAFE_RELEASE(pXMLDom); SAFE_RELEASE(pFileNodes); return fileList; }
HRESULT COFSNcDlg2::SelectChildNode(IXMLDOMNode *pNodeParent, BSTR bsSelect, IXMLDOMNode **ppNodeChild, BSTR *pbsNodeText) { HRESULT hr; IXMLDOMNodeList *pNodeList = NULL; IXMLDOMNode *pNodeChild = NULL; if(pNodeParent == NULL || (ppNodeChild == NULL && pbsNodeText == NULL)) return E_INVALIDARG; if(ppNodeChild != NULL) *ppNodeChild = NULL; DOMNodeType nt; hr = pNodeParent->get_nodeType(&nt); hr = pNodeParent->selectNodes(bsSelect, &pNodeList); if(pNodeList) { hr = pNodeList->get_item(0, &pNodeChild); if(pNodeChild != NULL) { if(pbsNodeText != NULL) { BSTR bs; hr = pNodeChild->get_text(&bs); *pbsNodeText = bs; } if(ppNodeChild == NULL) { pNodeChild->Release(); pNodeChild = NULL; } else *ppNodeChild = pNodeChild; } pNodeList->Release(); pNodeList = NULL; } return hr; }
void lvDCOMInterface::getParams(std::map<std::string,std::string>& res) { res.clear(); char control_name_xpath[MAX_PATH_LEN]; _snprintf(control_name_xpath, sizeof(control_name_xpath), "/lvinput/section[@name='%s']/vi/param", m_configSection.c_str()); IXMLDOMNodeList* pXMLDomNodeList = NULL; HRESULT hr = m_pxmldom->selectNodes(_bstr_t(control_name_xpath), &pXMLDomNodeList); if (FAILED(hr) || pXMLDomNodeList == NULL) { return; } IXMLDOMNode *pNode, *pAttrNode1, *pAttrNode2; long n = 0; pXMLDomNodeList->get_length(&n); for(long i=0; i<n; ++i) { pNode = NULL; hr = pXMLDomNodeList->get_item(i, &pNode); if (SUCCEEDED(hr) && pNode != NULL) { IXMLDOMNamedNodeMap *attributeMap = NULL; pAttrNode1 = pAttrNode2 = NULL; pNode->get_attributes(&attributeMap); hr = attributeMap->getNamedItem(_bstr_t("name"), &pAttrNode1); hr = attributeMap->getNamedItem(_bstr_t("type"), &pAttrNode2); BSTR bstrValue1 = NULL, bstrValue2 = NULL; hr=pAttrNode1->get_text(&bstrValue1); hr=pAttrNode2->get_text(&bstrValue2); res[std::string(COLE2CT(bstrValue1))] = COLE2CT(bstrValue2); SysFreeString(bstrValue1); SysFreeString(bstrValue2); pAttrNode1->Release(); pAttrNode2->Release(); attributeMap->Release(); pNode->Release(); } } pXMLDomNodeList->Release(); }
STDMETHODIMP CStrokeRecognition::put_RecognitionParam(BSTR newVal) { double Segment_Error_Threshold; double Arc_Error_Threshold; double Arc_Min_Length; double Arc_Min_Curve; double Stroke_Min_Length; double Min_Turning_Angle; double Segmentation_Penalty; VARIANT value; BSTR nodeName; long n; IXMLDOMDocument* pDoc; IXMLDOMNodeList* pNodeList; IXMLDOMNode* pNode; IXMLDOMNode* pParamNode; IXMLDOMNode* pAttrNode; IXMLDOMNamedNodeMap* pNodeMap; VARIANT_BOOL bLoaded; GetFittingParam(Segment_Error_Threshold, Arc_Error_Threshold, Arc_Min_Length, Arc_Min_Curve, Stroke_Min_Length, Min_Turning_Angle, Segmentation_Penalty); if (SUCCEEDED(CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument, (LPVOID*)&pDoc))) { pDoc->put_async(VARIANT_FALSE); pDoc->loadXML(newVal, &bLoaded); if (bLoaded == VARIANT_TRUE) { if (SUCCEEDED(pDoc->get_childNodes(&pNodeList))) { pParamNode = NULL; pNodeList->get_length(&n); for (int i = 0; i < n; i++) { if (SUCCEEDED(pNodeList->get_item(i, &pNode))) { nodeName = NULL; if (SUCCEEDED(pNode->get_nodeName(&nodeName))) { if (CComBSTR(nodeName) == L"param") { pParamNode = pNode; pParamNode->AddRef(); break; } SysFreeString(nodeName); } pNode->Release(); } } pNodeList->Release(); if (pParamNode != NULL) { if (SUCCEEDED(pParamNode->get_attributes(&pNodeMap))) { if (SUCCEEDED(pNodeMap->getNamedItem(L"Segment_Error_Threshold", &pAttrNode))) { pAttrNode->get_nodeValue(&value); Segment_Error_Threshold = _wtof(value.bstrVal); pAttrNode->Release(); } if (SUCCEEDED(pNodeMap->getNamedItem(L"Arc_Error_Threshold", &pAttrNode))) { pAttrNode->get_nodeValue(&value); Arc_Error_Threshold = _wtof(value.bstrVal); pAttrNode->Release(); } if (SUCCEEDED(pNodeMap->getNamedItem(L"Arc_Min_Length", &pAttrNode))) { pAttrNode->get_nodeValue(&value); Arc_Min_Length = _wtof(value.bstrVal); pAttrNode->Release(); } if (SUCCEEDED(pNodeMap->getNamedItem(L"Arc_Min_Curve", &pAttrNode))) { pAttrNode->get_nodeValue(&value); Arc_Min_Curve = _wtof(value.bstrVal); pAttrNode->Release(); } if (SUCCEEDED(pNodeMap->getNamedItem(L"Stroke_Min_Length", &pAttrNode))) { pAttrNode->get_nodeValue(&value); Stroke_Min_Length = _wtof(value.bstrVal); pAttrNode->Release(); } if (SUCCEEDED(pNodeMap->getNamedItem(L"Min_Turning_Angle", &pAttrNode))) { pAttrNode->get_nodeValue(&value); Min_Turning_Angle = _wtof(value.bstrVal); pAttrNode->Release(); } if (SUCCEEDED(pNodeMap->getNamedItem(L"Segmentation_Penalty", &pAttrNode))) { pAttrNode->get_nodeValue(&value); Segmentation_Penalty = _wtof(value.bstrVal); pAttrNode->Release(); } pNodeMap->Release(); } pParamNode->Release(); } } } pDoc->Release(); } SetFittingParam(Segment_Error_Threshold, Arc_Error_Threshold, Arc_Min_Length, Arc_Min_Curve, Stroke_Min_Length, Min_Turning_Angle, Segmentation_Penalty); return S_OK; }
void CStrokeRecognition::DecodePointFromXML(std::vector<POINT> &rgPoints, BSTR strXML) { IXMLDOMDocument* pDoc; IXMLDOMNodeList* pNodeList; IXMLDOMNode* pNode; IXMLDOMNode* pInputNode; IXMLDOMNode* pAttrNode; IXMLDOMNamedNodeMap* pNodeMap; VARIANT_BOOL bLoaded; VARIANT value; BSTR nodeName; POINT pt; long n; if (SUCCEEDED(CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument, (LPVOID*)&pDoc))) { pDoc->put_async(VARIANT_FALSE); pDoc->loadXML(strXML, &bLoaded); if (bLoaded == VARIANT_TRUE) { if (SUCCEEDED(pDoc->get_childNodes(&pNodeList))) { pInputNode = NULL; pNodeList->get_length(&n); for (int i = 0; i < n; i++) { if (SUCCEEDED(pNodeList->get_item(i, &pNode))) { nodeName = NULL; if (SUCCEEDED(pNode->get_nodeName(&nodeName))) { if (CComBSTR(nodeName) == L"input") { pInputNode = pNode; pInputNode->AddRef(); break; } SysFreeString(nodeName); } pNode->Release(); } } pNodeList->Release(); if (pInputNode != NULL) { if (SUCCEEDED(pInputNode->get_childNodes(&pNodeList))) { pNodeList->get_length(&n); for (int i = 0; i < n; i++) { if (SUCCEEDED(pNodeList->get_item(i, &pNode))) { pt.x = 0; pt.y = 0; if (SUCCEEDED(pNode->get_attributes(&pNodeMap))) { if (SUCCEEDED(pNodeMap->getNamedItem(L"x", &pAttrNode))) { pAttrNode->get_nodeValue(&value); pt.x = _wtoi(value.bstrVal); pAttrNode->Release(); } if (SUCCEEDED(pNodeMap->getNamedItem(L"y", &pAttrNode))) { pAttrNode->get_nodeValue(&value); pt.y = _wtoi(value.bstrVal); pAttrNode->Release(); } pNodeMap->Release(); } rgPoints.push_back(pt); pNode->Release(); } } pNodeList->Release(); } pInputNode->Release(); } } } pDoc->Release(); } }
bool CModelToolCharDataTable::LoadProperty(const char * lpszFullPathFileName) { CNtlXMLDoc doc; if(doc.Create() == false) { _ASSERT(0); return false; } if(doc.Load( const_cast<char *>(lpszFullPathFileName) ) == false) { _ASSERT(0); return false; } char szBuffer[1024]; if( !doc.GetDataWithXPath(const_cast<char *>(XML_PROP_NAME_ATTRIBUTE), szBuffer, sizeof(szBuffer)) ) { _ASSERT(0); return false; } sMODELTOOL_CHAR_TBLDAT *pModelToolCharData = new sMODELTOOL_CHAR_TBLDAT; Add(szBuffer, pModelToolCharData); IXMLDOMNodeList *pAnimDataList = doc.SelectNodeList(XML_PROP_ANIM_DATA_ELEMENT); IXMLDOMNode* pAnimDataNode = NULL; IXMLDOMNodeList *pAnimEventList = NULL; IXMLDOMNode* pAnimEventNode = NULL; long lAnimDataNodeNum = 0; long lAnimEventNodeNum = 0; int nAnimKeyID = 0; float fDurationTime = 0.f; BYTE byPushCount = 0; BYTE byKnockDownCount = 0; bool bKB2Push = false; BYTE byHitCount = 0; float aHitTime[NTL_MAX_SIZE_HIT]; pAnimDataList->get_length(&lAnimDataNodeNum); for(long m = 0; m < lAnimDataNodeNum ; ++m) { pAnimDataList->get_item(m,&pAnimDataNode); if(!doc.GetTextWithAttributeName(pAnimDataNode, XML_PROP_ANIM_DATA_ELEMENT_KEYID_ATTRIBUTE, szBuffer, sizeof(szBuffer))) { _ASSERT(0); return false; } nAnimKeyID = atoi(szBuffer); if(!doc.GetTextWithAttributeName(pAnimDataNode, XML_PROP_ANIM_DATA_ELEMENT_PLAYTIME_ATTRIBUTE, szBuffer, sizeof(szBuffer))) { _ASSERT(0); return false; } fDurationTime = (float)atof(szBuffer); pAnimDataNode->selectNodes(L"ANIM_EVENT", &pAnimEventList); pAnimEventList->get_length(&lAnimEventNodeNum); memset(aHitTime, 0, sizeof(aHitTime)); for(long n = 0; n < lAnimEventNodeNum; ++n) { pAnimEventList->get_item(n, &pAnimEventNode); if(!doc.GetTextWithAttributeName(pAnimEventNode, XML_PROP_ANIM_DATA_ELEMENT_EVENTID_ATTRIBUTE, szBuffer, sizeof(szBuffer))) { _ASSERT(0); return false; } int nAnimEventID = EVENT_ANIM_NONE; int nBehavior = TARGET_BEHAVIOR_NONE; nAnimEventID = atoi(szBuffer); if(nAnimEventID == EVENT_ANIM_HIT) { if(!doc.GetTextWithAttributeName(pAnimEventNode, XML_PROP_ANIM_DATA_ELEMENT_HITBEHAVIOR_ATTRIBUTE, szBuffer, sizeof(szBuffer))) { _ASSERT(0); return false; } nBehavior = atoi(szBuffer); if(nBehavior == TARGET_BEHAVIOR_PUSH) { byPushCount++; } else if(nBehavior == TARGET_BEHAVIOR_KNOCK_DOWN) { byKnockDownCount++; if( byKnockDownCount > 1 ) { _ASSERT(0); return false; } } // Hit time if(!doc.GetTextWithAttributeName(pAnimEventNode, XML_PROP_ANIM_DATA_ELEMENT_HITTIME_ATTRIBUTE, szBuffer, sizeof(szBuffer))) { _ASSERT(0); return false; } aHitTime[byHitCount] = (float)atof(szBuffer); byHitCount++; if(byHitCount > NTL_MAX_SIZE_HIT) _ASSERT(0); // KB2PUSH if(!doc.GetTextWithAttributeName(pAnimEventNode, XML_PROP_ANIM_DATA_ELEMENT_HITKB2PUSH_ATTRIBUTE, szBuffer, sizeof(szBuffer))) { _ASSERT(0); return false; } if(atoi(szBuffer) == 0) { bKB2Push = false; } else { bKB2Push = true; } } else if(nAnimEventID == EVENT_ANIM_SKILL_CANCEL) { // time if(!doc.GetTextWithAttributeName(pAnimEventNode, XML_PROP_ANIM_DATA_ELEMENT_HITTIME_ATTRIBUTE, szBuffer, sizeof(szBuffer))) { _ASSERT(0); return false; } pModelToolCharData->AddSkillCancelTime(nAnimKeyID, (float)atof(szBuffer)); } if(pAnimEventNode) { pAnimEventNode->Release(); pAnimEventNode = NULL; } } if( nAnimKeyID != -1 ) pModelToolCharData->Add(nAnimKeyID, fDurationTime, byPushCount, byKnockDownCount, byHitCount, aHitTime, bKB2Push); nAnimKeyID = 0; fDurationTime = 0; byPushCount = 0; byKnockDownCount = 0; byHitCount = 0; if(pAnimEventList) { pAnimEventList->Release(); pAnimEventList = NULL; } if(pAnimDataNode) { pAnimDataNode->Release(); pAnimDataNode = NULL; } } //pModelToolCharData->GetChainAttack(PC_CLASS_HUMAN_FIGHTER, ITEM_TYPE_UNKNOWN, 6); if(pAnimDataList) { pAnimDataList->Release(); pAnimDataList = NULL; } char *pTokenStart = NULL; char *pTokenEnd = NULL; char szToken[64]; if( !doc.GetDataWithXPath("MODEL_SCRIPT/HEADER/ANIM_BBOX", szBuffer, sizeof(szBuffer)) ) { _ASSERT(0); return false; } CNtlVector vTemp; pTokenStart = szBuffer; pTokenEnd = strstr( szBuffer, ";"); strncpy_s(szToken, sizeof(szToken), pTokenStart, pTokenEnd - pTokenStart); vTemp.x = (float) atof(szToken); pTokenStart = pTokenEnd + 1; pTokenEnd = strstr( pTokenStart, ";"); strncpy_s(szToken, sizeof(szToken), pTokenStart, pTokenEnd - pTokenStart); vTemp.y = (float) atof(szToken); pTokenStart = pTokenEnd + 1; strncpy_s(szToken, sizeof(szToken), pTokenStart, strlen(szBuffer)); vTemp.z = (float) atof(szToken); pModelToolCharData->m_vMin.x = -(vTemp.x / 2.0f); pModelToolCharData->m_vMin.y = 0.0f; pModelToolCharData->m_vMin.z = -(vTemp.z / 2.0f); pModelToolCharData->m_vMax.x = vTemp.x / 2.0f; pModelToolCharData->m_vMax.y = vTemp.y; pModelToolCharData->m_vMax.z = vTemp.z / 2.0f; if( !doc.GetDataWithXPath("MODEL_SCRIPT/BONE_DATA/BASE_SCALE", szBuffer, sizeof(szBuffer)) ) { _ASSERT(0); return false; } pModelToolCharData->m_fScale = (float) atof(szBuffer); return true; }
bool CModelToolCharDataTable::LoadPropertyList(const char *lpszPath, const char * lpszFileName) { CNtlXMLDoc doc; std::string strPath( lpszPath ); std::string strFileName; if(doc.Create() == false) { _ASSERT(0); return false; } strFileName = strPath; strFileName += "/"; strFileName += lpszFileName; if(doc.Load( const_cast<char *>(strFileName.c_str()) ) == false) { _ASSERT(0); return false; } IXMLDOMNodeList *pList = doc.SelectNodeList(XML_PROP_LIST_ELEMENT); IXMLDOMNode* pNode = NULL; char szBuffer[1024]; long lNum; pList->get_length(&lNum); for(long i = 0; i < lNum ; ++i) { pList->get_item(i,&pNode); if(!doc.GetTextWithAttributeName(pNode, XML_PROP_LIST_ELEMENT_NAME_ATTRIBUTE, szBuffer, sizeof(szBuffer))) { _ASSERT(0); return false; } strFileName = strPath + "/" + szBuffer; if( LoadProperty( strFileName.c_str() ) == false ) { _ASSERT(0); return false; } if(pNode) { pNode->Release(); pNode = NULL; } } if(pList) { pList->Release(); pList = NULL; } return true; }
int DicomImageSet::readDatasetFile(const QString &datasetFileName, QTreeWidget *treeWidget) { HRESULT hr = S_OK; IXMLDOMDocument *pXMLDom = NULL; IXMLDOMNodeList *pPatients = NULL; IXMLDOMNode *pPatient = NULL; DOMNodeType nodeType; VARIANT_BOOL varStatus; VARIANT varFileName; VARIANT varValue; BSTR bstrQuery; VariantInit(&varFileName); VariantInit(&varValue); QString queryPatient, queryDate, queryProtocol, queryCollection; CHK_HR(CreateAndInitDOM(&pXMLDom)); CHK_HR(VariantFromString(datasetFileName.toStdWString().c_str(), varFileName)); CHK_HR(pXMLDom->load(varFileName, &varStatus)); if (varStatus != VARIANT_TRUE) { CHK_HR(ReportParseError(pXMLDom, "Failed to load DOM from stocks.xml.")); } treeWidget->clear(); treeWidget->setColumnCount(1); CHK_HR(pXMLDom->getElementsByTagName(L"Patient", &pPatients)); if (pPatients) { long nPatients; CHK_HR(pPatients->get_length(&nPatients)); for (long i=0; i<nPatients; ++i) { CHK_HR(pPatients->get_item(i, &pPatient)); CHK_HR(GetAttributeFromNode(pPatient, L"patients_name", &varValue)); queryPatient = QString::fromWCharArray(_bstr_t(varValue)); QTreeWidgetItem * patientItem = new QTreeWidgetItem(treeWidget, QStringList(queryPatient)); patientItem->setExpanded(true); IXMLDOMNodeList * pDates = NULL; CHK_HR(pPatient->get_childNodes(&pDates)); long nDates; CHK_HR(pDates->get_length(&nDates)); for (long j=0; j<nDates; ++j) { IXMLDOMNode * pDate = NULL; CHK_HR(pDates->get_item(j, &pDate)); CHK_HR(pDate->get_nodeType(&nodeType)); if(nodeType!=NODE_ELEMENT) { continue; } CHK_HR(GetAttributeFromNode(pDate, L"acquisition_date", &varValue)); queryDate = QString::fromWCharArray(_bstr_t(varValue)); int intDate = queryDate.toInt(); QDate date = (QDate::fromString("1900-01-01", "yyyy-MM-dd")).addDays(intDate-693962); QTreeWidgetItem * dateItem = new QTreeWidgetItem(patientItem, QStringList(date.toString("yyyy-MM-dd"))); dateItem->setExpanded(true); IXMLDOMNodeList * pProtocols = NULL; CHK_HR(pDate->get_childNodes(&pProtocols)); long nProtocols; CHK_HR(pProtocols->get_length(&nProtocols)); for (long j=0; j<nProtocols; ++j) { IXMLDOMNode * pProtocol = NULL; CHK_HR(pProtocols->get_item(j, &pProtocol)); CHK_HR(pProtocol->get_nodeType(&nodeType)); if(nodeType!=NODE_ELEMENT) { continue; } CHK_HR(GetAttributeFromNode(pProtocol, L"protocol_name", &varValue)); queryProtocol = QString::fromWCharArray(_bstr_t(varValue)); QTreeWidgetItem * protocolItem = new QTreeWidgetItem(dateItem, QStringList(queryProtocol)); protocolItem->setExpanded(true); IXMLDOMNodeList * pCollections = NULL; CHK_HR(pProtocol->get_childNodes(&pCollections)); long nCollections; CHK_HR(pCollections->get_length(&nCollections)); for (long j=0; j<nCollections; ++j) { IXMLDOMNode * pCollection = NULL; CHK_HR(pCollections->get_item(j, &pCollection)); CHK_HR(pCollection->get_nodeType(&nodeType)); if(nodeType!=NODE_ELEMENT) { continue; } CHK_HR(GetAttributeFromNode(pCollection, L"acquisition_number", &varValue)); queryCollection = QString::fromWCharArray(_bstr_t(varValue)); QTreeWidgetItem * collectionItem = new QTreeWidgetItem(protocolItem); QString queryStr = QString("root/Patient[@patients_name = '%1']/Date[@acquisition_date = '%2']/Protocol[@protocol_name = '%3']/Collection[@acquisition_number = '%4']") .arg(queryPatient).arg(queryDate).arg(queryProtocol).arg(queryCollection); IXMLDOMElement * pDtiNode = NULL; bstrQuery = SysAllocString(QString(queryStr+"/DTI").toStdWString().c_str()); CHK_ALLOC(bstrQuery); CHK_HR(pXMLDom->selectSingleNode(bstrQuery, (IXMLDOMNode**)&pDtiNode)); SysFreeString(bstrQuery); if (pDtiNode) { collectionItem->setText(0,queryCollection+"*"); } else { collectionItem->setText(0, queryCollection); } collectionItem->setData(0, Qt::UserRole, queryStr); collectionItem->setExpanded(true); protocolItem->addChild(collectionItem); SAFE_RELEASE(pCollection); } dateItem->addChild(protocolItem); SAFE_RELEASE(pProtocol); } patientItem->addChild(dateItem); SAFE_RELEASE(pDate); } treeWidget->insertTopLevelItem(i, patientItem); SAFE_RELEASE(pPatient); } } CleanUp: SAFE_RELEASE(pXMLDom); SAFE_RELEASE(pPatients); SAFE_RELEASE(pPatient); VariantClear(&varFileName); return SUCCEEDED(hr); }
void Explorerplusplus::LoadDialogStatesFromXML(IXMLDOMDocument *pXMLDom) { IXMLDOMNodeList *pNodes = NULL; IXMLDOMNode *pNode = NULL; IXMLDOMNamedNodeMap *am = NULL; IXMLDOMNode *pChildNode = NULL; BSTR bstrName; BSTR bstrValue; BSTR bstr = NULL; HRESULT hr; long length; long lChildNodes; if(pXMLDom == NULL) goto clean; TCHAR tempNodeSelector[64]; StringCchPrintf(tempNodeSelector, SIZEOF_ARRAY(tempNodeSelector), _T("//%s/*"), DIALOGS_XML_KEY); bstr = SysAllocString(tempNodeSelector); pXMLDom->selectNodes(bstr,&pNodes); if(!pNodes) { goto clean; } else { pNodes->get_length(&length); for(long i = 0;i < length;i++) { /* This should never fail, as the number of nodes has already been counted (so they must exist). */ hr = pNodes->get_item(i,&pNode); if(SUCCEEDED(hr)) { hr = pNode->get_attributes(&am); if(SUCCEEDED(hr)) { /* Retrieve the total number of attributes attached to this node. */ am->get_length(&lChildNodes); if(lChildNodes >= 1) { am->get_item(0,&pChildNode); pChildNode->get_nodeName(&bstrName); pChildNode->get_text(&bstrValue); for(CDialogSettings *ds : DIALOG_SETTINGS) { TCHAR settingsKey[64]; bool success = ds->GetSettingsKey(settingsKey, SIZEOF_ARRAY(settingsKey)); assert(success); if(!success) { continue; } if(lstrcmpi(bstrValue, settingsKey) == 0) { ds->LoadXMLSettings(am, lChildNodes); } } } } } pNode->Release(); pNode = NULL; } } clean: if (bstr) SysFreeString(bstr); if (pNodes) pNodes->Release(); if (pNode) pNode->Release(); }
bool TextTable::InitializeFromXmlDoc(XMLDoc* pXmlDoc, WCHAR* pwszFileName, bool bReload) { if (NULL == pXmlDoc) { return false; } BSTR rowXPathFormat; rowXPathFormat = ::SysAllocString(L"/dataroot/%s/F%d"); WCHAR wszXPath[MAX_UNICODE_XPATH_LENGTH + 1]; DWORD dwSheetIndex = 0; WCHAR** ppwszSheetList = GetSheetListInWChar(); BSTR bstr = NULL; while (ppwszSheetList[dwSheetIndex]) { swprintf_s<_countof(wszXPath)>(wszXPath, rowXPathFormat, ppwszSheetList[dwSheetIndex], m_nField); IXMLDOMNodeList* pIndexNodeList = NULL; pIndexNodeList = pXmlDoc->SelectNodeList(wszXPath); if (!pIndexNodeList) { ::SysFreeString(rowXPathFormat); return false; } LONG nIndexLength = 0; if (FAILED(pIndexNodeList->get_length(&nIndexLength))) { pIndexNodeList->Release(); ::SysFreeString(rowXPathFormat); return false; } swprintf_s<_countof(wszXPath)>(wszXPath, rowXPathFormat, ppwszSheetList[dwSheetIndex], m_nField + 1); IXMLDOMNodeList* pTextNodeList = NULL; pTextNodeList = pXmlDoc->SelectNodeList(wszXPath); if (!pTextNodeList) { pIndexNodeList->Release(); ::SysFreeString(rowXPathFormat); return false; } LONG nTextLength = 0; if (FAILED(pTextNodeList->get_length(&nTextLength))) { pIndexNodeList->Release(); pTextNodeList->Release(); ::SysFreeString(rowXPathFormat); return false; } if (nTextLength != nIndexLength) { pIndexNodeList->Release(); pTextNodeList->Release(); ::SysFreeString(rowXPathFormat); return false; } // 제목은 버린다. for (INT j = 1; j < nIndexLength; ++j) { VOID* pvTable = AllocNewTable(ppwszSheetList[dwSheetIndex], m_dwCodePage); if (!pvTable) { pIndexNodeList->Release(); pTextNodeList->Release(); ::SysFreeString(rowXPathFormat); return false; } IXMLDOMNode* pCellNode = NULL; IXMLDOMNode* pDataNode = NULL; if (FAILED(pIndexNodeList->get_item(j, &pCellNode))) { pIndexNodeList->Release(); pTextNodeList->Release(); DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]); ::SysFreeString(rowXPathFormat); return false; } if (!pCellNode) { DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]); break; } if (FAILED(pCellNode->get_firstChild(&pDataNode))) { pCellNode->Release(); pIndexNodeList->Release(); pTextNodeList->Release(); DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]); ::SysFreeString(rowXPathFormat); return false; } if (!pDataNode) { pCellNode->Release(); DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]); break; } if (FAILED(pDataNode->get_text(&bstr))) { ::SysFreeString(bstr); pDataNode->Release(); pCellNode->Release(); pIndexNodeList->Release(); pTextNodeList->Release(); DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]); ::SysFreeString(rowXPathFormat); return false; } SetTableData(pvTable, ppwszSheetList[dwSheetIndex], INDEX, bstr); ::SysFreeString(bstr); pCellNode->Release(); pDataNode->Release(); pCellNode = NULL; pDataNode = NULL; if (FAILED(pTextNodeList->get_item(j, &pCellNode))) { pIndexNodeList->Release(); pTextNodeList->Release(); DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]); ::SysFreeString(rowXPathFormat); return false; } if (!pCellNode) { DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]); break; } if (FAILED(pCellNode->get_firstChild(&pDataNode))) { //- yoshiki : TODO!(Get the field name) Table::CallErrorCallbackFunction("[File] : %S\n[Error] : Table data is null.(Row Index : %d, Field Name = %S)", pwszFileName, j - 1, L"FIELD_NAME!"); pCellNode->Release(); pIndexNodeList->Release(); pTextNodeList->Release(); DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]); ::SysFreeString(rowXPathFormat); return false; } if (!pDataNode) { //- yoshiki : TODO!(Get the field name) Table::CallErrorCallbackFunction("[File] : %S\n[Error] : Table data is null.(Row Index : %d, Field Name = %S)", pwszFileName, j - 1, L"FIELD_NAME!"); pCellNode->Release(); DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]); _ASSERT(0); // Index는 있고 Data는 공란인경우. break; } if (FAILED(pDataNode->get_text(&bstr))) { ::SysFreeString(bstr); pDataNode->Release(); pCellNode->Release(); pIndexNodeList->Release(); pTextNodeList->Release(); DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]); ::SysFreeString(rowXPathFormat); return false; } SetTableData(pvTable, ppwszSheetList[dwSheetIndex], TEXT, bstr); ::SysFreeString(bstr); pCellNode->Release(); pDataNode->Release(); if (!AddTable(pvTable, bReload)) { DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]); } } pIndexNodeList->Release(); pTextNodeList->Release(); ++dwSheetIndex; } ::SysFreeString(rowXPathFormat); return true; }
LRESULT CAddVideoHtmlDlg::OnLoadCatalog(WPARAM wParam, LPARAM lParam) { if(wParam == NULL) { MessageBox(TEXT("获取视频分类数据失败,请检查您的网络情况。"), TEXT("错误"), MB_OK|MB_ICONERROR); return 0; } try { TSTLSTRING strCatalogHtml; int iSelectedIndex = -1; IXMLDOMDocument* pDOM = NULL; HRESULT hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument, (void**)&pDOM); if(hr != S_OK) { throw Exception(TEXT("解析视频分类数据失败。")); } VARIANT_BOOL loaded = VARIANT_FALSE; hr = pDOM->loadXML(CComBSTR((LPCOLESTR)wParam), &loaded); if(hr != S_OK || loaded == VARIANT_FALSE) { pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } IXMLDOMNodeList* pNodeList = NULL; hr = pDOM->get_childNodes(&pNodeList); if(hr != S_OK) { pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } IXMLDOMNode* pRoot = NULL; hr = pNodeList->get_item(1, &pRoot); if(hr != S_OK) { pNodeList->Release(); pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } IXMLDOMNodeList* pRootChildren = NULL; hr = pRoot->get_childNodes(&pRootChildren); if(hr != S_OK) { pRoot->Release(); pNodeList->Release(); pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } IXMLDOMNode* pResultNote = NULL; hr = pRootChildren->get_item(0, &pResultNote); if(hr != S_OK) { pRootChildren->Release(); pRoot->Release(); pNodeList->Release(); pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } IXMLDOMNodeList* pResultChildren = NULL; hr = pResultNote->get_childNodes(&pResultChildren); if(hr != S_OK) { pResultNote->Release(); pRootChildren->Release(); pRoot->Release(); pNodeList->Release(); pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } IXMLDOMNode* pResultStatusNote = NULL; hr = pRootChildren->get_item(0, &pResultStatusNote); if(hr != S_OK) { pResultChildren->Release(); pResultNote->Release(); pRootChildren->Release(); pRoot->Release(); pNodeList->Release(); pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } CComBSTR bstrResultStatus; hr = pResultStatusNote->get_text(&bstrResultStatus); if(hr != S_OK) { pResultStatusNote->Release(); pResultChildren->Release(); pResultNote->Release(); pRootChildren->Release(); pRoot->Release(); pNodeList->Release(); pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } pResultStatusNote->Release(); if(bstrResultStatus != TEXT("o")) { IXMLDOMNode* pResultMessageNote = NULL; hr = pRootChildren->get_item(1, &pResultMessageNote); if(hr != S_OK) { pResultChildren->Release(); pResultNote->Release(); pRootChildren->Release(); pRoot->Release(); pNodeList->Release(); pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } CComBSTR bstrResultMessage; hr = pResultMessageNote->get_text(&bstrResultMessage); if(hr != S_OK) { pResultMessageNote->Release(); pResultChildren->Release(); pResultNote->Release(); pRootChildren->Release(); pRoot->Release(); pNodeList->Release(); pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } pResultMessageNote->Release(); pResultChildren->Release(); pResultNote->Release(); pRootChildren->Release(); pRoot->Release(); pNodeList->Release(); pDOM->Release(); throw Exception(bstrResultMessage.m_str); } pResultChildren->Release(); pResultNote->Release(); IXMLDOMNode* pItemNote = NULL; hr = pRootChildren->get_item(1, &pItemNote); if(hr != S_OK) { pRootChildren->Release(); pRoot->Release(); pNodeList->Release(); pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } IXMLDOMNodeList* pItemChildren = NULL; hr = pItemNote->get_childNodes(&pItemChildren); if(hr != S_OK) { pItemNote->Release(); pRootChildren->Release(); pRoot->Release(); pNodeList->Release(); pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } long ItemCount = 0; pItemChildren->get_length(&ItemCount); if(hr != S_OK) { pItemChildren->Release(); pItemNote->Release(); pRootChildren->Release(); pRoot->Release(); pNodeList->Release(); pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } for(int i=0; i<ItemCount; ++i) { IXMLDOMNode* pCatalogItemNote = NULL; hr = pItemChildren->get_item(i, &pCatalogItemNote); if(hr != S_OK) { pItemChildren->Release(); pItemNote->Release(); pRootChildren->Release(); pRoot->Release(); pNodeList->Release(); pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } IXMLDOMNodeList* pCatalogItemChildren = NULL; hr = pCatalogItemNote->get_childNodes(&pCatalogItemChildren); if(hr != S_OK) { pCatalogItemNote->Release(); pItemChildren->Release(); pItemNote->Release(); pRootChildren->Release(); pRoot->Release(); pNodeList->Release(); pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } IXMLDOMNode* pCatalogIdNote = NULL; hr = pCatalogItemChildren->get_item(0, &pCatalogIdNote); if(hr != S_OK) { pCatalogItemChildren->Release(); pCatalogItemNote->Release(); pItemChildren->Release(); pItemNote->Release(); pRootChildren->Release(); pRoot->Release(); pNodeList->Release(); pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } CComBSTR bstrCatalogId; hr = pCatalogIdNote->get_text(&bstrCatalogId); if(hr != S_OK) { pCatalogIdNote->Release(); pCatalogItemChildren->Release(); pCatalogItemNote->Release(); pItemChildren->Release(); pItemNote->Release(); pRootChildren->Release(); pRoot->Release(); pNodeList->Release(); pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } pCatalogIdNote->Release(); IXMLDOMNode* pCatalogNameNote = NULL; hr = pCatalogItemChildren->get_item(1, &pCatalogNameNote); if(hr != S_OK) { pCatalogItemChildren->Release(); pCatalogItemNote->Release(); pItemChildren->Release(); pItemNote->Release(); pRootChildren->Release(); pRoot->Release(); pNodeList->Release(); pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } CComBSTR bstrCatalogName; hr = pCatalogNameNote->get_text(&bstrCatalogName); if(hr != S_OK) { pCatalogNameNote->Release(); pCatalogItemChildren->Release(); pCatalogItemNote->Release(); pItemChildren->Release(); pItemNote->Release(); pRootChildren->Release(); pRoot->Release(); pNodeList->Release(); pDOM->Release(); throw Exception(TEXT("解析视频分类数据失败。")); } pCatalogNameNote->Release(); pCatalogItemChildren->Release(); pCatalogItemNote->Release(); TSTLSTRING strCurrID = TSTLSTRING(COLE2T(bstrCatalogId)); TSTLSTRING strLastCatalog = ConfigureManager::GetInstance().GetLastCatalog(); TSTLSTRING strCurrName = TSTLSTRING(COLE2T(bstrCatalogName)); bool IsSelected = ((strLastCatalog.empty() && strCurrName == TEXT("其他")) || (!strLastCatalog.empty() && strLastCatalog.compare(strCurrID) == 0)); strCatalogHtml.append(TEXT("<div class=\"ComboxListItem\" onmouseover=\"this.className='ComboxListItemSelected';\" onclick=\"OnCatalogComboxClick();\" onmouseout=\"this.className='ComboxListItem';\" Value=\"")); strCatalogHtml.append(strCurrID); strCatalogHtml.append(TEXT("\">")); strCatalogHtml.append(strCurrName); strCatalogHtml.append(TEXT("</div>")); if(IsSelected) iSelectedIndex = i; } pItemChildren->Release(); pItemNote->Release(); pRootChildren->Release(); pRoot->Release(); pNodeList->Release(); pDOM->Release(); DISPPARAMS dp; memset(&dp, 0, sizeof(DISPPARAMS)); dp.cArgs = 2; dp.cNamedArgs = 0; VARIANTARG arg[2]; memset(arg, 0, sizeof(VARIANTARG) * 2); dp.rgvarg = arg; CComBSTR bstr(strCatalogHtml.c_str()); arg[0].vt = VT_BSTR; bstr.CopyTo(&arg[0].bstrVal); arg[1].vt = VT_INT; arg[1].intVal = iSelectedIndex; m_lpCatalogInvoke->Invoke( 0, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dp, NULL, NULL, NULL); } catch(Exception& error) { MessageBox(error.GetMessage().c_str(), TEXT("错误"), MB_OK|MB_ICONERROR); } return 0; }
void queryNodes() { HRESULT hr = S_OK; IXMLDOMDocument *pXMLDom = NULL; IXMLDOMNodeList *pNodes = NULL; IXMLDOMNode *pNode = NULL; BSTR bstrQuery1 = NULL; BSTR bstrQuery2 = NULL; BSTR bstrNodeName = NULL; BSTR bstrNodeValue = NULL; VARIANT_BOOL varStatus; VARIANT varFileName; VariantInit(&varFileName); CHK_HR(CreateAndInitDOM(&pXMLDom)); CHK_HR(VariantFromString(L"stocks.xml", varFileName)); CHK_HR(pXMLDom->load(varFileName, &varStatus)); if (varStatus != VARIANT_TRUE) { CHK_HR(ReportParseError(pXMLDom, "Failed to load DOM from stocks.xml.")); } // Query a single node. bstrQuery1 = SysAllocString(L"//stock[1]/*"); CHK_ALLOC(bstrQuery1); CHK_HR(pXMLDom->selectSingleNode(bstrQuery1, &pNode)); if (pNode) { printf("Result from selectSingleNode:\n"); CHK_HR(pNode->get_nodeName(&bstrNodeName)); printf("Node, <%S>:\n", bstrNodeName); SysFreeString(bstrNodeName); CHK_HR(pNode->get_xml(&bstrNodeValue)); printf("\t%S\n\n", bstrNodeValue); SysFreeString(bstrNodeValue); SAFE_RELEASE(pNode); } else { CHK_HR(ReportParseError(pXMLDom, "Error while calling selectSingleNode.")); } // Query a node-set. bstrQuery2 = SysAllocString(L"//stock[1]/*"); CHK_ALLOC(bstrQuery2); CHK_HR(pXMLDom->selectNodes(bstrQuery2, &pNodes)); if(pNodes) { printf("Results from selectNodes:\n"); //get the length of node-set long length; CHK_HR(pNodes->get_length(&length)); for (long i = 0; i < length; i++) { CHK_HR(pNodes->get_item(i, &pNode)); CHK_HR(pNode->get_nodeName(&bstrNodeName)); /*if(0== wcscmp(bstrNodeValue, L"symbol")) { } */ printf("Node (%d), <%S>:\n", i, bstrNodeName); SysFreeString(bstrNodeName); CHK_HR(pNode->get_xml(&bstrNodeValue)); printf("\t%S\n", bstrNodeValue); SysFreeString(bstrNodeValue); SAFE_RELEASE(pNode); } } else { CHK_HR(ReportParseError(pXMLDom, "Error while calling selectNodes.")); } CleanUp: SAFE_RELEASE(pXMLDom); SAFE_RELEASE(pNodes); SAFE_RELEASE(pNode); SysFreeString(bstrQuery1); SysFreeString(bstrQuery2); SysFreeString(bstrNodeName); SysFreeString(bstrNodeValue); VariantClear(&varFileName); }
/////////////////////////////////////////////////////// // RADEventsXML::ProcessEvents // // Method to process a list of events, either transforming XML // into RADEvents, or RADEvents into XML event nodes. // Invoked by the Populate and Persist methods. // // When transforming the RADEvent objects on the list 'rel' into // XML Event nodes, a new XML Event node is created, and appended // to the XML Events node of the XML document. // // When transforming the XML Events node with XML Event nodes, each // XML Event node is transformed to a RADEvent object, and the RADEvent // object is appended to the RADEventsList 'rel'. // // Input/Output: // rel - the RADEventsList instance // bExtract - processing toggle: // When true, run through the XML event nodes, creating // RADEvent objects on 'rel'. // When false, run through the RADEvent objects, creating // XML event nodes on the XML document. // /////////////////////////////////////////////////////// bool RADEventsXML::ProcessEvents(RADEventsList& rel, bool bExtract) { // if bExtract, we want to read the XML events and populate the list of event objects // first: get count of events nodes // second: // for each event node // get the node // create a RADEvent, using the node attributes to populate it // insert the RADEvent object into the RADEventsList 'rel' // end // else, not bExtract, we want to transform the list of RADEvent objects into an XML document // for each RADEvent on the RADEventsList 'rel, // create a new XML Event Node, using each stirng value as an attribute value // append the XML Event node to the <IR/Events> node // end HRESULT hr; _bstr_t xbstr = m_xirevsevpath; if (bExtract) // converting from XML <Event> to RADEvent { IXMLDOMNodeList* pXMLDomNodeList = NULL; HRCALL(m_pXMLDom->selectNodes(xbstr, &pXMLDomNodeList), "selectNodes"); if (pXMLDomNodeList) { long count = 0; HRCALL(pXMLDomNodeList->get_length(&count), "get_length"); IXMLDOMNode *pEventNode=NULL; for (long i=0; i<count; i++) { HRCALL(pXMLDomNodeList->get_item(i, &pEventNode), "get_item: "); if (bDebug) { BSTR dbg1str; BSTR dbg2str; HRCALL(pEventNode->get_nodeName(&dbg1str), "get_nodeName: "); dprintf("Node (%d), <%S>:\n",i, static_cast<wchar_t*>(dbg1str)); HRCALL(pEventNode->get_xml(&dbg2str), "get_xml: "); dprintf("\t%S\n", static_cast<wchar_t*>(dbg2str)); } RADEvent* p = XMLToEvent(pEventNode); rel.AddToEnd(p); if (bDebug) { dprintf(p->Image()); } if (pEventNode) pEventNode->Release(); } pXMLDomNodeList->Release(); } else { ReportParseError(m_pXMLDom, "Error while calling ProcessEvents/selectNodes "); } } else // converting from RADEvent to XML <Event> { IXMLDOMElement * pE; IXMLDOMNode *pIXMLDOMNode = NULL; long i = 0; POSITION pos = rel.GetHeadPosition(); while( pos != NULL ) { RADEvent* p = (RADEvent*)rel.GetNext( pos ); pE = ConstructEventNode(p); if (pE) { HRCALL(m_pIRNode->appendChild(pE,&pIXMLDOMNode), ""); AddWhiteSpaceToNode(bstr_wsnt, m_pIRNode); i++; } } } clean: if (FAILED(hr)) return false; else return true; }
bool CKADInfo::load( CGT_CDiagMsg* pdm, const TCHAR* pszKADFileAndPath, const TCHAR* pszTargetType, unsigned long ulTrgVer ) { long i, o; long len; long len2; long len3; IXMLDOMNodeList* pNList; IXMLDOMNodeList* pNList2; IXMLDOMNodeList* pNList3; IXMLDOMNode* pNode; IXMLDOMNode* pNode2; int nCurrErrors; FC_CString jot(MAX_PATH); bool bTargetTypeFound = false; nCurrErrors = pdm->getTotalErrors(); //clear possible old content: clear(); m_szKADFile.load(pszKADFileAndPath); CG_InitSTEdipos(&m_KADEdp, m_szKADFile, 1); pNode = CGT_XMLLoadFile(pdm, NULL, m_szKADFile, L"KAD4VM"); if(!pNode) return false; // read targets pNList = NULL; len = 0; pNode->selectNodes(L"TRGTYP", &pNList); assert(pNList); FC_RELEASE_PTR(pNode); pNList->get_length(&len); for(i=0;i<len;i++) { pNList->get_item(i, &pNode); if ( ! isCurrentTrgType(pdm, pszTargetType, pNode)) continue; bTargetTypeFound = true; // <IEC_FEATURES> : read IEC features : dadta types , languages pNList2 = NULL; pNode->selectNodes(L"IEC_FEATURES", &pNList2); assert(pNList2); ReadIecFeatures(pdm, m_szKADFile, pNList2, &m_AllowedIEClanguages, &m_AllowedIECtypes, &m_AllowedArrayIndexIECtypes, &m_lMaxTasks, &m_bLocalRetain, &m_CheckAddressSpace ); FC_RELEASE_PTR(pNList2); // <TASKIMAGE> : read task image features : segments, size, optimize pNList2 = NULL; pNode->selectNodes(L"TASKIMAGE", &pNList2); assert(pNList2); ReadTaskImageFeature(pdm, m_szKADFile, pNList2, &m_useTIforSegm, &m_optimizeTIforSegm, m_lMaxRegionsWR, m_lMaxRegionsRD, ulTrgVer); FC_RELEASE_PTR(pNList2); // <IOCOMPONENTS> pNList2 = NULL; pNode->selectNodes(L"IOCOMPONENTS", &pNList2); assert(pNList2); len2 = 0; pNList2->get_length(&len2); for(o=0;o<len2;o++) { pNList2->get_item(o, &pNode2); // <CHANNEL> pNList3 = NULL; pNode2->selectNodes(L"CHANNEL", &pNList3); ReadChannels(pdm, pNList3, &m_channels); FC_RELEASE_PTR(pNList3); } FC_RELEASE_PTR(pNList2); // <VM_SETTINGS> : read target features pNList2 = NULL; pNode->selectNodes(L"VM_SETTINGS", &pNList2); assert(pNList2); ReadVmSettings(pdm, pNList2, &m_VmSettings); FC_RELEASE_PTR(pNList2); // <CG_OPTIONS> : read target code generator features pNList2 = NULL; pNode->selectNodes(L"CG_OPTIONS", &pNList2); assert(pNList2); pNList2->get_length(&len3); if (len3 != 0) { // <CG_OPTIONS> is optional ReadCgOptions(pdm, pNList2, &m_CgOptions); FC_RELEASE_PTR(pNList2); } FC_RELEASE_PTR(pNode); } FC_RELEASE_PTR(pNList); if ( ! bTargetTypeFound) { pdm->msg1(CG_E_XML_TARGET_NOT_FOUND_IN_KAD, &m_KADEdp, pszTargetType); return false; } //finally check usage of channels if no error so far: if(nCurrErrors==pdm->getTotalErrors()) ValidateChannels(pdm, &m_KADEdp, &m_channels, &m_VmSettings); return nCurrErrors==pdm->getTotalErrors(); }