aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/poco/XML/src/AttrMap.cpp
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/libs/poco/XML/src/AttrMap.cpp
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/libs/poco/XML/src/AttrMap.cpp')
-rw-r--r--contrib/libs/poco/XML/src/AttrMap.cpp123
1 files changed, 123 insertions, 0 deletions
diff --git a/contrib/libs/poco/XML/src/AttrMap.cpp b/contrib/libs/poco/XML/src/AttrMap.cpp
new file mode 100644
index 0000000000..cb3a24133d
--- /dev/null
+++ b/contrib/libs/poco/XML/src/AttrMap.cpp
@@ -0,0 +1,123 @@
+//
+// AttrMap.cpp
+//
+// Library: XML
+// Package: DOM
+// Module: DOM
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/DOM/AttrMap.h"
+#include "Poco/DOM/Attr.h"
+#include "Poco/DOM/Element.h"
+#include "Poco/DOM/Document.h"
+#include "Poco/DOM/DOMException.h"
+
+
+namespace Poco {
+namespace XML {
+
+
+AttrMap::AttrMap(Element* pElement):
+ _pElement(pElement)
+{
+ poco_check_ptr (pElement);
+
+ _pElement->duplicate();
+}
+
+
+AttrMap::~AttrMap()
+{
+ _pElement->release();
+}
+
+
+Node* AttrMap::getNamedItem(const XMLString& name) const
+{
+ return _pElement->getAttributeNode(name);
+}
+
+
+Node* AttrMap::setNamedItem(Node* arg)
+{
+ poco_check_ptr (arg);
+
+ if (arg->nodeType() != Node::ATTRIBUTE_NODE)
+ throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
+
+ return _pElement->setAttributeNode(static_cast<Attr*>(arg));
+}
+
+
+Node* AttrMap::removeNamedItem(const XMLString& name)
+{
+ Attr* pAttr = _pElement->getAttributeNode(name);
+ if (pAttr)
+ return _pElement->removeAttributeNode(pAttr);
+ else
+ return 0;
+}
+
+
+Node* AttrMap::item(unsigned long index) const
+{
+ AbstractNode* pAttr = _pElement->_pFirstAttr;
+ while (index-- > 0 && pAttr) pAttr = static_cast<AbstractNode*>(pAttr->nextSibling());
+ return pAttr;
+}
+
+
+unsigned long AttrMap::length() const
+{
+ unsigned long result = 0;
+ AbstractNode* pAttr = _pElement->_pFirstAttr;
+ while (pAttr)
+ {
+ pAttr = static_cast<AbstractNode*>(pAttr->nextSibling());
+ ++result;
+ }
+ return result;
+}
+
+
+Node* AttrMap::getNamedItemNS(const XMLString& namespaceURI, const XMLString& localName) const
+{
+ return _pElement->getAttributeNodeNS(namespaceURI, localName);
+}
+
+
+Node* AttrMap::setNamedItemNS(Node* arg)
+{
+ poco_check_ptr (arg);
+
+ if (arg->nodeType() != Node::ATTRIBUTE_NODE)
+ throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
+
+ return _pElement->setAttributeNodeNS(static_cast<Attr*>(arg));
+}
+
+
+Node* AttrMap::removeNamedItemNS(const XMLString& namespaceURI, const XMLString& localName)
+{
+ Attr* pAttr = _pElement->getAttributeNodeNS(namespaceURI, localName);
+ if (pAttr)
+ return _pElement->removeAttributeNode(pAttr);
+ else
+ return 0;
+}
+
+
+void AttrMap::autoRelease()
+{
+ _pElement->ownerDocument()->autoReleasePool().add(this);
+}
+
+
+} } // namespace Poco::XML
+