1 | // |
---|
2 | // AbstractNode.h |
---|
3 | // |
---|
4 | // $Id: //poco/1.3/XML/include/Poco/DOM/AbstractNode.h#2 $ |
---|
5 | // |
---|
6 | // Library: XML |
---|
7 | // Package: DOM |
---|
8 | // Module: DOM |
---|
9 | // |
---|
10 | // Definition of the AbstractNode class. |
---|
11 | // |
---|
12 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. |
---|
13 | // and Contributors. |
---|
14 | // |
---|
15 | // Permission is hereby granted, free of charge, to any person or organization |
---|
16 | // obtaining a copy of the software and accompanying documentation covered by |
---|
17 | // this license (the "Software") to use, reproduce, display, distribute, |
---|
18 | // execute, and transmit the Software, and to prepare derivative works of the |
---|
19 | // Software, and to permit third-parties to whom the Software is furnished to |
---|
20 | // do so, all subject to the following: |
---|
21 | // |
---|
22 | // The copyright notices in the Software and this entire statement, including |
---|
23 | // the above license grant, this restriction and the following disclaimer, |
---|
24 | // must be included in all copies of the Software, in whole or in part, and |
---|
25 | // all derivative works of the Software, unless such copies or derivative |
---|
26 | // works are solely in the form of machine-executable object code generated by |
---|
27 | // a source language processor. |
---|
28 | // |
---|
29 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
30 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
31 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT |
---|
32 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE |
---|
33 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, |
---|
34 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
---|
35 | // DEALINGS IN THE SOFTWARE. |
---|
36 | // |
---|
37 | |
---|
38 | |
---|
39 | #ifndef DOM_AbstractNode_INCLUDED |
---|
40 | #define DOM_AbstractNode_INCLUDED |
---|
41 | |
---|
42 | |
---|
43 | #include "Poco/XML/XML.h" |
---|
44 | #include "Poco/DOM/Node.h" |
---|
45 | #include "Poco/DOM/MutationEvent.h" |
---|
46 | #include "Poco/XML/XMLString.h" |
---|
47 | |
---|
48 | |
---|
49 | namespace Poco { |
---|
50 | namespace XML { |
---|
51 | |
---|
52 | |
---|
53 | class AbstractContainerNode; |
---|
54 | class Attr; |
---|
55 | class EventDispatcher; |
---|
56 | |
---|
57 | |
---|
58 | class XML_API AbstractNode: public Node |
---|
59 | /// AbstractNode provides a basic implementation |
---|
60 | /// of the Node interface for all types of nodes |
---|
61 | /// that do not contain other nodes. |
---|
62 | { |
---|
63 | public: |
---|
64 | // Node |
---|
65 | const XMLString& nodeName() const; |
---|
66 | const XMLString& getNodeValue() const; |
---|
67 | void setNodeValue(const XMLString& value); |
---|
68 | Node* parentNode() const; |
---|
69 | NodeList* childNodes() const; |
---|
70 | Node* firstChild() const; |
---|
71 | Node* lastChild() const; |
---|
72 | Node* previousSibling() const; |
---|
73 | Node* nextSibling() const; |
---|
74 | NamedNodeMap* attributes() const; |
---|
75 | Document* ownerDocument() const; |
---|
76 | Node* insertBefore(Node* newChild, Node* refChild); |
---|
77 | Node* replaceChild(Node* newChild, Node* oldChild); |
---|
78 | Node* removeChild(Node* oldChild); |
---|
79 | Node* appendChild(Node* newChild); |
---|
80 | bool hasChildNodes() const; |
---|
81 | Node* cloneNode(bool deep) const; |
---|
82 | void normalize(); |
---|
83 | bool isSupported(const XMLString& feature, const XMLString& version) const; |
---|
84 | const XMLString& namespaceURI() const; |
---|
85 | XMLString prefix() const; |
---|
86 | const XMLString& localName() const; |
---|
87 | bool hasAttributes() const; |
---|
88 | |
---|
89 | // EventTarget |
---|
90 | void addEventListener(const XMLString& type, EventListener* listener, bool useCapture); |
---|
91 | void removeEventListener(const XMLString& type, EventListener* listener, bool useCapture); |
---|
92 | bool dispatchEvent(Event* evt); |
---|
93 | |
---|
94 | // Extensions |
---|
95 | XMLString innerText() const; |
---|
96 | |
---|
97 | virtual void autoRelease(); |
---|
98 | |
---|
99 | protected: |
---|
100 | AbstractNode(Document* pOwnerDocument); |
---|
101 | AbstractNode(Document* pOwnerDocument, const AbstractNode& node); |
---|
102 | ~AbstractNode(); |
---|
103 | |
---|
104 | virtual Node* copyNode(bool deep, Document* pOwnerDocument) const = 0; |
---|
105 | |
---|
106 | virtual bool events() const; |
---|
107 | virtual bool eventsSuspended() const; |
---|
108 | void captureEvent(Event* evt); |
---|
109 | void bubbleEvent(Event* evt); |
---|
110 | void dispatchSubtreeModified(); |
---|
111 | void dispatchNodeInserted(); |
---|
112 | void dispatchNodeRemoved(); |
---|
113 | virtual void dispatchNodeRemovedFromDocument(); |
---|
114 | virtual void dispatchNodeInsertedIntoDocument(); |
---|
115 | void dispatchAttrModified(Attr* pAttr, MutationEvent::AttrChangeType changeType, const XMLString& prevValue, const XMLString& newValue); |
---|
116 | void dispatchCharacterDataModified(const XMLString& prevValue, const XMLString& newValue); |
---|
117 | void setOwnerDocument(Document* pOwnerDocument); |
---|
118 | |
---|
119 | static const XMLString EMPTY_STRING; |
---|
120 | |
---|
121 | private: |
---|
122 | AbstractNode(); |
---|
123 | |
---|
124 | AbstractContainerNode* _pParent; |
---|
125 | AbstractNode* _pNext; |
---|
126 | Document* _pOwner; |
---|
127 | EventDispatcher* _pEventDispatcher; |
---|
128 | |
---|
129 | static const XMLString NODE_NAME; |
---|
130 | |
---|
131 | friend class AbstractContainerNode; |
---|
132 | friend class Document; |
---|
133 | friend class DocumentFragment; |
---|
134 | friend class Element; |
---|
135 | friend class Attr; |
---|
136 | friend class CharacterData; |
---|
137 | friend class DOMBuilder; |
---|
138 | friend class NodeAppender; |
---|
139 | }; |
---|
140 | |
---|
141 | |
---|
142 | } } // namespace Poco::XML |
---|
143 | |
---|
144 | |
---|
145 | #endif // DOM_AbstractNode_INCLUDED |
---|