本文整理汇总了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);
}
}
示例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();
}
}
示例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();
}
}
示例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);
}