AbstractNode.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. //
  2. // AbstractNode.h
  3. //
  4. // Library: XML
  5. // Package: DOM
  6. // Module: DOM
  7. //
  8. // Definition of the AbstractNode class.
  9. //
  10. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #ifndef DOM_AbstractNode_INCLUDED
  16. #define DOM_AbstractNode_INCLUDED
  17. #include "Poco/XML/XML.h"
  18. #include "Poco/DOM/Node.h"
  19. #include "Poco/DOM/MutationEvent.h"
  20. #include "Poco/XML/XMLString.h"
  21. namespace Poco {
  22. namespace XML {
  23. class AbstractContainerNode;
  24. class Attr;
  25. class EventDispatcher;
  26. class XML_API AbstractNode: public Node
  27. /// AbstractNode provides a basic implementation
  28. /// of the Node interface for all types of nodes
  29. /// that do not contain other nodes.
  30. {
  31. public:
  32. // Node
  33. const XMLString& nodeName() const;
  34. const XMLString& getNodeValue() const;
  35. void setNodeValue(const XMLString& value);
  36. Node* parentNode() const;
  37. NodeList* childNodes() const;
  38. Node* firstChild() const;
  39. Node* lastChild() const;
  40. Node* previousSibling() const;
  41. Node* nextSibling() const;
  42. NamedNodeMap* attributes() const;
  43. Document* ownerDocument() const;
  44. Node* insertBefore(Node* newChild, Node* refChild);
  45. Node* replaceChild(Node* newChild, Node* oldChild);
  46. Node* removeChild(Node* oldChild);
  47. Node* appendChild(Node* newChild);
  48. bool hasChildNodes() const;
  49. Node* cloneNode(bool deep) const;
  50. void normalize();
  51. bool isSupported(const XMLString& feature, const XMLString& version) const;
  52. const XMLString& namespaceURI() const;
  53. XMLString prefix() const;
  54. const XMLString& localName() const;
  55. bool hasAttributes() const;
  56. // EventTarget
  57. void addEventListener(const XMLString& type, EventListener* listener, bool useCapture);
  58. void removeEventListener(const XMLString& type, EventListener* listener, bool useCapture);
  59. bool dispatchEvent(Event* evt);
  60. // Extensions
  61. XMLString innerText() const;
  62. Node* getNodeByPath(const XMLString& path) const;
  63. Node* getNodeByPathNS(const XMLString& path, const NSMap& nsMap) const;
  64. virtual void autoRelease();
  65. protected:
  66. AbstractNode(Document* pOwnerDocument);
  67. AbstractNode(Document* pOwnerDocument, const AbstractNode& node);
  68. ~AbstractNode();
  69. virtual Node* copyNode(bool deep, Document* pOwnerDocument) const = 0;
  70. virtual bool events() const;
  71. virtual bool eventsSuspended() const;
  72. void captureEvent(Event* evt);
  73. void bubbleEvent(Event* evt);
  74. void dispatchSubtreeModified();
  75. void dispatchNodeInserted();
  76. void dispatchNodeRemoved();
  77. virtual void dispatchNodeRemovedFromDocument();
  78. virtual void dispatchNodeInsertedIntoDocument();
  79. void dispatchAttrModified(Attr* pAttr, MutationEvent::AttrChangeType changeType, const XMLString& prevValue, const XMLString& newValue);
  80. void dispatchCharacterDataModified(const XMLString& prevValue, const XMLString& newValue);
  81. void setOwnerDocument(Document* pOwnerDocument);
  82. static const XMLString EMPTY_STRING;
  83. private:
  84. AbstractNode();
  85. AbstractContainerNode* _pParent;
  86. AbstractNode* _pNext;
  87. Document* _pOwner;
  88. EventDispatcher* _pEventDispatcher;
  89. static const XMLString NODE_NAME;
  90. friend class AbstractContainerNode;
  91. friend class Document;
  92. friend class DocumentFragment;
  93. friend class Element;
  94. friend class Attr;
  95. friend class CharacterData;
  96. friend class DOMBuilder;
  97. friend class NodeAppender;
  98. };
  99. } } // namespace Poco::XML
  100. #endif // DOM_AbstractNode_INCLUDED