本文整理汇总了C++中IXMLDOMNode::AddRef方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMNode::AddRef方法的具体用法?C++ IXMLDOMNode::AddRef怎么用?C++ IXMLDOMNode::AddRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IXMLDOMNode
的用法示例。
在下文中一共展示了IXMLDOMNode::AddRef方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PreviousSibling
/*
Function name : CXML::PreviousSibling
Description : This will move the current node to the previous sibling of the current node.
Return type : bool
Tested : Ok
*/
bool CXML::PreviousSibling()
{
if(!m_pICurrentNode)
return false;
IXMLDOMNode * pITempNode = m_pICurrentNode;
IXMLDOMNode * pNode = NULL;
pITempNode->AddRef();
m_hr = pITempNode ->get_previousSibling(&pNode);
pITempNode->Release();
if (!SUCCEEDED(m_hr) || !pNode)
return false;
if(m_pICurrentNode)
{
m_pICurrentNode->Release();
m_pICurrentNode= NULL;
}
m_pICurrentNode = pNode;
m_pICurrentNode->AddRef();
pNode->Release();
return true;
}
示例2: GetNextNode
HRESULT CEnumData::GetNextNode(IXMLDOMNode **ppNextNode)
// gets the next node of the enumeration
{
HRESULT hrResult;
IXMLDOMNode *pNextSubNode;
*ppNextNode = NULL;
if (m_bReset) {
m_bReset = FALSE;
hrResult = kadAccess.GetFirstSubNode(m_sSubNodeName,m_pNode,
&pNextSubNode);
} else {
if (m_pActualSubNode != NULL) {
hrResult = kadAccess.GetNextSiblingNode(m_pActualSubNode,
m_sSubNodeName,&pNextSubNode);
} else {
hrResult = E_POINTER;
}
}
if (m_pActualSubNode != NULL) {
m_pActualSubNode->Release();
m_pActualSubNode = NULL;
}
if (hrResult == S_OK) {
m_pActualSubNode = pNextSubNode;
*ppNextNode = pNextSubNode;
pNextSubNode->AddRef();
}
return hrResult;
}
示例3: MoveToParentNode
/*
Function name : CXML::MoveToParentNode
Description : This function will move to the n th parent the current node.
Return type : bool
Argument : UINT nNthParent
Tested : Ok
*/
bool CXML::MoveToParentNode(UINT nNthParent)
{
if(!m_pICurrentNode)
return false;
IXMLDOMNode * pITempNode = m_pICurrentNode;
IXMLDOMNode * pNode = NULL;
pITempNode->AddRef();
for(UINT i=0;i<nNthParent;++i)
{
if(pNode)
{
pNode ->Release();
pNode = NULL;
}
m_hr = pITempNode ->get_parentNode(&pNode);
if (!SUCCEEDED(m_hr) || !pNode)
{
pITempNode->Release();
return false;
}
if(pITempNode)
{
pITempNode->Release();
pITempNode = NULL;
}
pITempNode = pNode;
pITempNode->AddRef();
}
if(pNode)
{
pITempNode->Release();
m_pICurrentNode->Release();
m_pICurrentNode = pNode;
m_pICurrentNode->AddRef();
pNode->Release();
pNode= NULL;
}
return true;
}
示例4: GoToNodeEx
/*
Function name : CXML::GoToNode
Description : Moves to the node having the specified text
Return type : bool
Argument : CString csPathToNode
Argument : CString csNodeText
Argument : bool bCurrentNodeAsBase
Tested : Not working
*/
bool CXML::GoToNodeEx(CString csPathToNode,CString csNodeText,bool bCurrentNodeAsBase)
{
CString csPath;
IXMLDOMNode *pBaseNode = NULL;
if(bCurrentNodeAsBase)
{
if(!m_pICurrentNode) return false;
pBaseNode = m_pICurrentNode;
pBaseNode->AddRef();
csPath.Format("./%s[.= \"%s\"]",csPathToNode,csNodeText);
}
else
{
if(!m_pIRootNode) return false;
pBaseNode = m_pIRootNode;
pBaseNode->AddRef();
csPath.Format("/%s[.= \"%s\"]",csPathToNode,csNodeText);
}
BSTR bstrPath = csPath.AllocSysString();
IXMLDOMNode * pNode = NULL;
m_hr = pBaseNode->selectSingleNode(bstrPath,&pNode);
pBaseNode->Release();
SysFreeString(bstrPath);
if(!SUCCEEDED(m_hr) || !pNode)
return false;
if(m_pICurrentNode)
{
m_pICurrentNode->Release();
m_pICurrentNode = NULL;
}
m_pICurrentNode = pNode;
m_pICurrentNode->AddRef();
pNode->Release();
return true;
}
示例5: GetNodesList
/*
Function name : CXML::GetNodesList
Description : retrieves the list of nodes with the given name
Return type : bool
Argument : CString csPathToNode
Argument : bool bCurrentNodeAsBase
*/
bool CXML::GetNodesList(CString csPathToNode,bool bCurrentNodeAsBase)
{
CString csPath;
IXMLDOMNode *pBaseNode = NULL;
if(bCurrentNodeAsBase)
{
if(!m_pICurrentNode) return false;
pBaseNode = m_pICurrentNode;
pBaseNode->AddRef();
csPath.Format("./%s",csPathToNode);
}
else
{
if(!m_pIRootNode) return false;
pBaseNode = m_pIRootNode;
pBaseNode->AddRef();
csPath.Format("/%s",csPathToNode);
}
_bstr_t bstrPath(csPath);
if(m_pNodeList)
{
m_pNodeList->Release();
m_pNodeList = NULL;
}
m_hr = pBaseNode->selectNodes(bstrPath,&m_pNodeList);
pBaseNode->Release();
if(!SUCCEEDED(m_hr) || !m_pNodeList)
return false;
return true;
}
示例6: GetNode
/*
Function name : CXML::GetNode
Description : This is a helper function which, gives the pointer to node.
: searching for node can be started either from the current node
: or it may be started from the Root Node depending on the value of
: bCurrentNodeAsBase.
Return type : bool
Argument : CString csPathToNode
Argument : LPCTSTR lpszAttribute
Argument : LPCTSTR lpszValue
Argument : bool bCurrentNodeAsBase
Tested : Ok
*/
bool CXML::GetNode(IXMLDOMNode ** pNode,CString &rcsPathToNode,LPCTSTR lpszAttribute,LPCTSTR lpszValue,bool bCurrentNodeAsBase )
{
IXMLDOMNode * pBaseNode = NULL;
CString csPath("");
if(bCurrentNodeAsBase)
{
if(!m_pICurrentNode)
return false;
pBaseNode = m_pICurrentNode;
if(lpszAttribute)
csPath.Format("./%s[@%s = \"%s\"]",rcsPathToNode,lpszAttribute,lpszValue);
else
csPath.Format("./%s",rcsPathToNode);
}
else
{
if(!m_pIRootNode)
return false;
pBaseNode = m_pIRootNode;
if(lpszAttribute)
csPath.Format("/%s[@%s = \"%s\"]",rcsPathToNode,lpszAttribute,lpszValue);
else
csPath.Format("/%s",rcsPathToNode);
}
pBaseNode->AddRef();
BSTR bsPathToNode = csPath.AllocSysString();
m_hr = pBaseNode->selectSingleNode(bsPathToNode,pNode);
SysFreeString(bsPathToNode);
pBaseNode ->Release();
if (!SUCCEEDED(m_hr) || !(*pNode))
return false;
return true;
}
示例7: put_RecognitionParam
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);
//.........这里部分代码省略.........
示例8: DecodePointFromXML
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();
}
}
示例9: GetNodePath
/*
Function name : CXML::GetNodePath
Description : This function will return the full path of the xml file. (Max up to
: 100 Nodes)
Return type : bool
Argument : CString &rcsPath
Tested : Ok
*/
bool CXML::GetNodePath(CString &rcsPath)
{
if(!m_pICurrentNode)
return false;
char * path[100] = {0};
IXMLDOMNode * pCurNode = m_pICurrentNode;
IXMLDOMNode * pParentNode = NULL;
pCurNode->AddRef();
CString csNodeText;
int i = 0;
try
{
do
{
m_hr = pCurNode->get_parentNode(&pParentNode);
if(!SUCCEEDED(m_hr))
{
pCurNode->Release();
throw 1;
}
else if(!pParentNode)
break;
BSTR bstrNodeText;
m_hr = pParentNode->get_nodeName(&bstrNodeText);
pCurNode->Release();
pCurNode = pParentNode;
pCurNode->AddRef();
pParentNode->Release();
if(!SUCCEEDED(m_hr))
{
throw 1;
}
long nLen = wcslen(bstrNodeText)+1;
path[i] = new char[nLen];
WideCharToMultiByte(CP_ACP,0,bstrNodeText,-1,path[i],nLen,NULL,NULL);
SysFreeString(bstrNodeText);
i++;
}
while(true);
delete [] path[--i];
for(--i;i>=0;--i)
{
rcsPath += path[i];
rcsPath +="/";
delete [] path[i];
}
GetCurrentNodeName(csNodeText);
rcsPath +=csNodeText;
return true;
}
catch(...)
{
rcsPath = "";
for(--i;i>=0;--i)
delete [] path[i];
return false;
}
}
示例10: NextChildNode
bool CXML::NextChildNode()
{
if(!m_pICurrentNode)
return false;
IXMLDOMNode * pNode = NULL;
IXMLDOMNode * pITempNode = m_pICurrentNode;
pITempNode->AddRef();
IXMLDOMNodeList * pChildList = NULL;
// Get the list of child nodes of the current node
m_hr = pITempNode->get_childNodes(&pChildList);
pITempNode->Release();
if (!SUCCEEDED(m_hr))
return false;
// loop through the childs
DOMNodeType nodeType;
while(true)
{
// Get the node type of each child, if it is of NODE_ELEMENT type set it as current node
m_hr = pChildList->nextNode(&pNode);
if(!SUCCEEDED(m_hr))
{
pChildList->Release();
return false;
}
if(!pNode) break;
m_hr = pNode->get_nodeType(&nodeType);
if(!SUCCEEDED(m_hr))
{
pChildList->Release();
pNode->Release();
return false;
}
if(nodeType == NODE_ELEMENT)
break;
if(pNode)
pNode->Release();
}
if(pChildList)
pChildList->Release();
if(pNode)
{
if(m_pICurrentNode)
{
m_pICurrentNode->Release();
m_pICurrentNode = NULL;
}
m_pICurrentNode = pNode;
m_pICurrentNode->AddRef();
pNode->Release();
return true;
}
return false;
}