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


C++ Attr::release方法代码示例

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


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

示例1:

Element::Element(Document* pOwnerDocument, const Element& element): 
	AbstractContainerNode(pOwnerDocument, element),
	_name(pOwnerDocument->namePool().insert(element._name)),
	_pFirstAttr(0)
{
	Attr* pAttr = element._pFirstAttr;
	while (pAttr)
	{
		Attr* pClonedAttr = static_cast<Attr*>(pAttr->copyNode(false, pOwnerDocument));
		setAttributeNode(pClonedAttr);
		pClonedAttr->release();
		pAttr = static_cast<Attr*>(pAttr->_pNext);
	}
}
开发者ID:119,项目名称:vdc,代码行数:14,代码来源:Element.cpp

示例2: setAttribute

void Element::setAttribute(const XMLString& name, const XMLString& value)
{
	Attr* pAttr = getAttributeNode(name);
	if (pAttr)
	{
		pAttr->setValue(value);
	}
	else
	{
		pAttr = ownerDocument()->createAttribute(name);
		pAttr->setValue(value);
		setAttributeNode(pAttr);
		pAttr->release();
	}
}
开发者ID:119,项目名称:vdc,代码行数:15,代码来源:Element.cpp

示例3: setAttributeNS

void Element::setAttributeNS(const XMLString& namespaceURI, const XMLString& qualifiedName, const XMLString& value)
{
	Attr* pAttr = getAttributeNodeNS(namespaceURI, qualifiedName);
	if (pAttr)
	{
		pAttr->setValue(value);
	}
	else
	{
		pAttr = _pOwner->createAttributeNS(namespaceURI, qualifiedName);
		pAttr->setValue(value);
		setAttributeNodeNS(pAttr);
		pAttr->release();
	}
}
开发者ID:119,项目名称:vdc,代码行数:15,代码来源:Element.cpp

示例4: testAttrMapNS

void ElementTest::testAttrMapNS()
{
	AutoPtr<Document> pDoc = new Document;
	AutoPtr<Element> pElem = pDoc->createElementNS("urn:ns1", "elem");

	AutoPtr<NamedNodeMap> pNNM = pElem->attributes();
	assert (pNNM->length() == 0);
	
	pElem->setAttributeNS("urn:ns1", "a1", "v1");
	assert (pNNM->length() == 1);
	assert (pNNM->item(0)->nodeName() == "a1");
	assert (pNNM->getNamedItemNS("urn:ns1", "a1")->nodeName() == "a1");

	pElem->setAttributeNS("urn:ns1", "a2", "v2");
	assert (pNNM->length() == 2);
	assert (pNNM->item(0)->nodeName() == "a1");
	assert (pNNM->getNamedItem("a1")->nodeName() == "a1");
	assert (pNNM->item(1)->nodeName() == "a2");
	assert (pNNM->getNamedItem("a2")->nodeName() == "a2");
	
	Attr* pAttr = pDoc->createAttributeNS("urn:ns2", "a3");
	pNNM->setNamedItem(pAttr);
	pAttr->release();
	
	assert (pNNM->length() == 3);
	assert (pNNM->item(0)->nodeName() == "a1");
	assert (pNNM->getNamedItemNS("urn:ns1", "a1")->nodeName() == "a1");
	assert (pNNM->item(1)->nodeName() == "a2");
	assert (pNNM->getNamedItemNS("urn:ns1", "a2")->nodeName() == "a2");
	assert (pNNM->item(2)->nodeName() == "a3");
	assert (pNNM->getNamedItemNS("urn:ns2", "a3")->nodeName() == "a3");

	pNNM->removeNamedItemNS("urn:ns1", "a2");
	assert (pNNM->length() == 2);
	assert (!pElem->hasAttributeNS("urn:ns1", "a2"));
	
	pNNM->removeNamedItemNS("urn:ns2", "a3");
	assert (pNNM->length() == 1);
	assert (!pElem->hasAttributeNS("urn:ns2", "a3"));
	
	pElem->removeAttributeNS("urn:ns1", "a1");
	assert (pNNM->length() == 0);
}
开发者ID:cshnick,项目名称:CommunicationModel,代码行数:43,代码来源:ElementTest.cpp


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