当前位置: 首页>>代码示例>>C++>>正文


C++ IXMLDOMNode::get_previousSibling方法代码示例

本文整理汇总了C++中IXMLDOMNode::get_previousSibling方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMNode::get_previousSibling方法的具体用法?C++ IXMLDOMNode::get_previousSibling怎么用?C++ IXMLDOMNode::get_previousSibling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IXMLDOMNode的用法示例。


在下文中一共展示了IXMLDOMNode::get_previousSibling方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: insertFileItem

int DicomImageSet::insertFileItem(IXMLDOMDocument *pDom, IXMLDOMNode * pRoot, const QString &folderName, const QString &fileName)
{
	DicomImage * dicomImage = new DicomImage ();
	if (!dicomImage->readHeader((QDir(folderName).absoluteFilePath(fileName)).toStdString().c_str()))
	{
		//fail to resolve header information
		return 0;
	}
	int nElement;

	char * patientsName = dicomImage->getCharTag(DicomImage::TAG_PATIENTS_NAME, nElement);
	char * patientsId = dicomImage->getCharTag(DicomImage::TAG_PATIENT_ID, nElement);
	char * protocolName = dicomImage->getCharTag(DicomImage::TAG_PROTOCOL_NAME, nElement);
	double * pInstanceNumber = dicomImage->getNumericTag(DicomImage::TAG_INSTANCE_NUMBER, nElement);
	double * pAcquisitionNumber = dicomImage->getNumericTag(DicomImage::TAG_ACQUISITION_NUMBER, nElement);
	double * pAcquisitionDate = dicomImage->getNumericTag(DicomImage::TAG_ACQUISITION_DATE, nElement);
	int instanceNumber = pInstanceNumber?(int)pInstanceNumber[0]:-1;
	int acquisitionNumber = pAcquisitionNumber?(int)pAcquisitionNumber[0]:-1;
	int acquisitionDate = pAcquisitionDate?(int)pAcquisitionDate[0]:0;

	IXMLDOMNode * pParent = findParentNode(pDom, pRoot, patientsName, patientsId, acquisitionDate, protocolName, acquisitionNumber);

	if (!pParent)
	{
		return 0;
	}

	HRESULT hr = S_OK;
    IXMLDOMElement *pNode = NULL;
    CHK_HR(CreateElement(pDom, L"File", &pNode));
	CHK_HR(CreateAndAddAttributeNode(pDom, L"path", fileName.toStdWString().c_str(), pNode));
	CHK_HR(CreateAndAddAttributeNode(pDom, L"instance_number", QString::number(instanceNumber).toStdWString().c_str(), pNode));

	IXMLDOMNode * pSibling = NULL;
	CHK_HR(pParent->get_firstChild(&pSibling));
	int sibInstanceNumber = -1;
	VARIANT varInstanceNumber;
	DOMNodeType nodeType;
	while (pSibling && instanceNumber >= sibInstanceNumber)
	{
		CHK_HR(pSibling->get_nodeType(&nodeType));
		if(nodeType == NODE_ELEMENT)
		{
			CHK_HR(GetAttributeFromNode(pSibling, L"instance_number", &varInstanceNumber));
			sibInstanceNumber = QString::fromWCharArray(_bstr_t(varInstanceNumber)).toInt();
			if (instanceNumber < sibInstanceNumber)
			{
				break;
			}
		}
		IXMLDOMNode * tmpNode = NULL;
		CHK_HR(pSibling->get_nextSibling(&tmpNode));
		SAFE_RELEASE(pSibling);
		pSibling = tmpNode;
	}
	if (pSibling)
	{
		IXMLDOMNode * tmpNode = NULL;
		CHK_HR(pSibling->get_previousSibling(&tmpNode));
		SAFE_RELEASE(pSibling);
		pSibling = tmpNode;
	}
    CHK_HR(CreateAndAddTextNodeBefore(pDom, L"\n", pParent, pSibling));
    CHK_HR(InsertChildToParent(pNode, pSibling, pParent));

CleanUp:
    SAFE_RELEASE(pNode);

	return 1;
}
开发者ID:vcpudding,项目名称:DTI-Visualization,代码行数:70,代码来源:DicomImageSet.cpp


注:本文中的IXMLDOMNode::get_previousSibling方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。