/src/poco/XML/src/Attr.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | // |
2 | | // Attr.cpp |
3 | | // |
4 | | // Library: XML |
5 | | // Package: DOM |
6 | | // Module: DOM |
7 | | // |
8 | | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. |
9 | | // and Contributors. |
10 | | // |
11 | | // SPDX-License-Identifier: BSL-1.0 |
12 | | // |
13 | | |
14 | | |
15 | | #include "Poco/DOM/Attr.h" |
16 | | #include "Poco/DOM/Document.h" |
17 | | #include "Poco/XML/NamePool.h" |
18 | | |
19 | | |
20 | | namespace Poco { |
21 | | namespace XML { |
22 | | |
23 | | |
24 | | Attr::Attr(Document* pOwnerDocument, Element* pOwnerElement, const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& value, bool specified): |
25 | 102k | AbstractNode(pOwnerDocument), |
26 | 102k | _name(pOwnerDocument->namePool().insert(qname, namespaceURI, localName)), |
27 | 102k | _value(value), |
28 | 102k | _specified(specified) |
29 | 102k | { |
30 | 102k | } |
31 | | |
32 | | |
33 | | Attr::Attr(Document* pOwnerDocument, const Attr& attr): |
34 | 0 | AbstractNode(pOwnerDocument, attr), |
35 | 0 | _name(pOwnerDocument->namePool().insert(attr._name)), |
36 | 0 | _value(attr._value), |
37 | 0 | _specified(attr._specified) |
38 | 0 | { |
39 | 0 | } |
40 | | |
41 | | |
42 | | Attr::~Attr() |
43 | 102k | { |
44 | 102k | } |
45 | | |
46 | | |
47 | | void Attr::setValue(const XMLString& value) |
48 | 0 | { |
49 | 0 | XMLString oldValue = _value; |
50 | 0 | _value = value; |
51 | 0 | _specified = true; |
52 | 0 | if (_pParent && !_pOwner->eventsSuspended()) |
53 | 0 | _pParent->dispatchAttrModified(this, MutationEvent::MODIFICATION, oldValue, value); |
54 | 0 | } |
55 | | |
56 | | |
57 | | Node* Attr::parentNode() const |
58 | 0 | { |
59 | 0 | return 0; |
60 | 0 | } |
61 | | |
62 | | |
63 | | Node* Attr::previousSibling() const |
64 | 0 | { |
65 | 0 | if (_pParent) |
66 | 0 | { |
67 | 0 | Attr* pSibling = static_cast<Element*>(_pParent)->_pFirstAttr; |
68 | 0 | while (pSibling) |
69 | 0 | { |
70 | 0 | if (pSibling->_pNext == const_cast<Attr*>(this)) return pSibling; |
71 | 0 | pSibling = static_cast<Attr*>(pSibling->_pNext); |
72 | 0 | } |
73 | 0 | return pSibling; |
74 | 0 | } |
75 | 0 | return 0; |
76 | 0 | } |
77 | | |
78 | | |
79 | | const XMLString& Attr::nodeName() const |
80 | 0 | { |
81 | 0 | return _name.qname(); |
82 | 0 | } |
83 | | |
84 | | |
85 | | const XMLString& Attr::getNodeValue() const |
86 | 0 | { |
87 | 0 | return _value; |
88 | 0 | } |
89 | | |
90 | | |
91 | | void Attr::setNodeValue(const XMLString& value) |
92 | 0 | { |
93 | 0 | setValue(value); |
94 | 0 | } |
95 | | |
96 | | |
97 | | unsigned short Attr::nodeType() const |
98 | 0 | { |
99 | 0 | return ATTRIBUTE_NODE; |
100 | 0 | } |
101 | | |
102 | | |
103 | | const XMLString& Attr::namespaceURI() const |
104 | 0 | { |
105 | 0 | return _name.namespaceURI(); |
106 | 0 | } |
107 | | |
108 | | |
109 | | XMLString Attr::prefix() const |
110 | 0 | { |
111 | 0 | return _name.prefix(); |
112 | 0 | } |
113 | | |
114 | | |
115 | | const XMLString& Attr::localName() const |
116 | 0 | { |
117 | 0 | return _name.localName(); |
118 | 0 | } |
119 | | |
120 | | |
121 | | XMLString Attr::innerText() const |
122 | 0 | { |
123 | 0 | return nodeValue(); |
124 | 0 | } |
125 | | |
126 | | |
127 | | Node* Attr::copyNode(bool deep, Document* pOwnerDocument) const |
128 | 0 | { |
129 | 0 | return new Attr(pOwnerDocument, *this); |
130 | 0 | } |
131 | | |
132 | | |
133 | | } } // namespace Poco::XML |