STDMETHODIMP CXMLDOMDocument::nodeFromID(BSTR idString, IXMLDOMNode **pVal) { ATLTRACE(_T("CXMLDOMDocument::nodeFromID\n")); if (NULL == pVal) return E_POINTER; *pVal = NULL; HRESULT hr = S_OK; try { hr = wrapNode(m_pIXMLDOMDocument, m_Document->getElementById(idString),IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal)); } catch(DOMException& ex) { return MakeHRESULT(ex); } catch(...) { return E_FAIL; } return hr; }
STDMETHODIMP CXMLDOMNodeList::get_item(long index, IXMLDOMNode **pVal) { ATLTRACE(_T("CXMLDOMNodeList::get_item\n")); if (NULL == pVal) return E_POINTER; *pVal = NULL; HRESULT hr = S_OK; try { if (m_container == 0 || index < 0) return E_INVALIDARG; long length = m_container->getLength(); // // if index is beyond end // return a null object not an exception // if (index < length) hr = wrapNode(m_pIXMLDOMDocument,m_container->item(index),IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal)); } catch(DOMException& ex) { return MakeHRESULT(ex); } catch(...) { return E_FAIL; } return hr; }
STDMETHODIMP CXMLDOMNamedNodeMap::getNamedItem(BSTR name, IXMLDOMNode **pVal) { ATLTRACE(_T("CXMLDOMNamedNodeMap::getNamedItem\n")); if (NULL == pVal) return E_POINTER; *pVal = NULL; HRESULT hr = S_OK; if (m_container == 0) return S_OK; try { DOMNode* n = m_container->getNamedItem(name); if(n!=NULL) hr = wrapNode(m_pIXMLDOMDocument,n,IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal)); } catch(DOMException& ex) { return MakeHRESULT(ex); } catch(...) { return E_FAIL; } return hr; }
STDMETHODIMP CXMLDOMNamedNodeMap::removeNamedItem(BSTR name, IXMLDOMNode **pVal) { ATLTRACE(_T("CXMLDOMNamedNodeMap::removeNamedItem\n")); if (NULL == pVal) return E_POINTER; *pVal = NULL; HRESULT hr = S_OK; if (m_container == 0) return S_OK; try { DOMNode* n = m_container->removeNamedItem(name); if(n!=NULL) hr = wrapNode(m_pIXMLDOMDocument,n,IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal)); } // // if we had a failure, return success anyway // catch(...) { } return hr; }
STDMETHODIMP CXMLDOMNamedNodeMap::setNamedItem(IXMLDOMNode *newItem, IXMLDOMNode **pVal) { ATLTRACE(_T("CXMLDOMNamedNodeMap::setNamedItem\n")); if (NULL == pVal) return E_POINTER; *pVal = NULL; if (m_container == 0) return S_OK; if (NULL == newItem) return E_INVALIDARG; CComQIPtr<IIBMXMLDOMNodeIdentity,&IID_IIBMXMLDOMNodeIdentity> pNewItem(newItem); if (!pNewItem) return E_NOINTERFACE; long id = 0; HRESULT hr = pNewItem->get_NodeId(&id); if (S_OK != hr) return hr; DOMNode *pNewItemNode = reinterpret_cast<DOMNode*> (id); if (NULL == pNewItemNode) return E_INVALIDARG; try { const XMLCh* name = pNewItemNode->getNodeName(); // // returns old node // DOMNode* n = m_container->setNamedItem(pNewItemNode); if(n!=NULL) hr = wrapNode(m_pIXMLDOMDocument,n,IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal)); } catch(DOMException& ex) { return MakeHRESULT(ex); } catch(...) { return E_FAIL; } return hr; }
STDMETHODIMP CXMLDOMNodeList::nextNode(IXMLDOMNode **pVal) { ATLTRACE(_T("CXMLDOMNodeList::nextNode\n")); if (NULL == pVal) return E_POINTER; *pVal = NULL; if (m_container == 0) return S_OK; int length = m_container->getLength(); if (0 == length) return S_OK; if (m_NextNodeIndex >= length) return S_OK; HRESULT hr = S_OK; try { hr = wrapNode(m_pIXMLDOMDocument,m_container->item(m_NextNodeIndex),IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal)); } catch(DOMException& ex) { return MakeHRESULT(ex); } catch(...) { return E_FAIL; } ++m_NextNodeIndex; return hr; }
STDMETHODIMP CXMLDOMDocument::createNode(VARIANT TYPE, BSTR name, BSTR namespaceURI, IXMLDOMNode **pVal) { ATLTRACE(_T("CXMLDOMDocument::createNode\n")); HRESULT hr = S_OK; if (NULL == pVal) return E_POINTER; *pVal = NULL; VARIANT type; ::VariantInit(&type); if (V_VT(&TYPE) != VT_I4 && V_VT(&TYPE) != VT_BSTR) hr = ::VariantChangeType(&type,&TYPE,0,VT_I4); else hr = ::VariantCopy(&type,&TYPE); if (S_OK != hr) return hr; DOMNodeType nodeType = NODE_INVALID; if (VT_I4 == V_VT(&type)) nodeType = static_cast<DOMNodeType> (V_I4(&type)); else { OLECHAR* str = V_BSTR(&type); for (int i = 0; i < g_DomNodeNameSize; ++i) { if (0 == _wcsicmp(str,g_DomNodeName[i])) { nodeType = static_cast<DOMNodeType> (i); break; } } } ::VariantClear(&type); if (NODE_INVALID == nodeType || NODE_DOCUMENT == nodeType || NODE_DOCUMENT_TYPE == nodeType || NODE_ENTITY == nodeType || NODE_NOTATION == nodeType) return E_FAIL; try { switch(nodeType) { case NODE_ELEMENT: { DOMElement* node; if (SysStringLen(namespaceURI) > 0) node = m_Document->createElementNS(namespaceURI,name); else node = m_Document->createElement(name); hr = wrapNode(m_pIXMLDOMDocument,node,IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal)); break; } case NODE_ATTRIBUTE: { DOMAttr* node; if (SysStringLen(namespaceURI) > 0) node = m_Document->createAttributeNS(namespaceURI,name); else node = m_Document->createAttribute(name); hr = wrapNode(m_pIXMLDOMDocument,node,IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal)); break; } case NODE_TEXT: { DOMText* node = m_Document->createTextNode(OLESTR("")); hr = wrapNode(m_pIXMLDOMDocument,node,IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal)); break; } case NODE_CDATA_SECTION: { DOMCDATASection* node = m_Document->createCDATASection(OLESTR("")); hr = wrapNode(m_pIXMLDOMDocument,node,IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal)); break; } case NODE_ENTITY_REFERENCE: { DOMEntityReference* node = m_Document->createEntityReference(name); hr = wrapNode(m_pIXMLDOMDocument,node,IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal)); break; } case NODE_PROCESSING_INSTRUCTION: { DOMProcessingInstruction* node = m_Document->createProcessingInstruction(name,OLESTR("")); hr = wrapNode(m_pIXMLDOMDocument,node,IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal)); break; } case NODE_COMMENT: { DOMComment* node = m_Document->createComment(OLESTR("")); hr = wrapNode(m_pIXMLDOMDocument,node,IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal)); break; } case NODE_DOCUMENT_FRAGMENT: { DOMDocumentFragment* node = m_Document->createDocumentFragment(); hr = wrapNode(m_pIXMLDOMDocument,node,IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal)); break; } default: hr = E_FAIL; break; } } catch(DOMException& ex) { hr = MakeHRESULT(ex); } catch (...) { hr = E_FAIL; } return hr; }
BP::object Context_FindExistingNode_wrapped(xn::Context& self, XnProductionNodeType type) { XnNodeHandle ret = NULL; xnFindExistingRefNodeByType(self.GetUnderlyingObject(), type, &ret); return wrapNode(ret); }