| 1 | // |
| 2 | // NodeAppender.h |
| 3 | // |
| 4 | // Library: XML |
| 5 | // Package: DOM |
| 6 | // Module: NodeAppender |
| 7 | // |
| 8 | // Definition of the NodeAppender class. |
| 9 | // |
| 10 | // Copyright (c) 2007, Applied Informatics Software Engineering GmbH. |
| 11 | // and Contributors. |
| 12 | // |
| 13 | // SPDX-License-Identifier: BSL-1.0 |
| 14 | // |
| 15 | |
| 16 | |
| 17 | #ifndef DOM_NodeAppender_INCLUDED |
| 18 | #define DOM_NodeAppender_INCLUDED |
| 19 | |
| 20 | |
| 21 | #include "Poco/XML/XML.h" |
| 22 | #include "Poco/DOM/Node.h" |
| 23 | |
| 24 | |
| 25 | namespace Poco { |
| 26 | namespace XML { |
| 27 | |
| 28 | |
| 29 | class AbstractNode; |
| 30 | class Element; |
| 31 | |
| 32 | |
| 33 | class XML_API NodeAppender |
| 34 | /// The NodeAppender class provides a very fast way to |
| 35 | /// build larger DOM documents. |
| 36 | /// |
| 37 | /// In the DOM, child nodes are usually appended to a parent |
| 38 | /// node using the appendChild() method. For nodes containing |
| 39 | /// more than a few children, this method can be quite slow, |
| 40 | /// due to the way it's implemented, and because of the |
| 41 | /// requirements of the DOM specification. |
| 42 | /// |
| 43 | /// While the NodeAppender is being used on an Element, no |
| 44 | /// children-modifying methods of that Element must be used. |
| 45 | /// |
| 46 | /// This class is not part of the DOM specification. |
| 47 | { |
| 48 | public: |
| 49 | NodeAppender(Element* parent); |
| 50 | /// Creates the NodeAppender for the given parent node, |
| 51 | /// which must be an Element. |
| 52 | |
| 53 | ~NodeAppender(); |
| 54 | /// Destroys the NodeAppender. |
| 55 | |
| 56 | void appendChild(Node* newChild); |
| 57 | /// Appends the node newChild to the end of the list of children of |
| 58 | /// the parent node specified in the constructor. |
| 59 | /// If the newChild is already in the tree, it is first removed. |
| 60 | /// |
| 61 | /// NewChild can be a DocumentFragment. In this case, all children |
| 62 | /// of the fragment become children of the parent element. |
| 63 | /// |
| 64 | /// In order to speed up the function, no DOM events |
| 65 | /// are fired. |
| 66 | |
| 67 | private: |
| 68 | NodeAppender(); |
| 69 | NodeAppender(const NodeAppender&); |
| 70 | NodeAppender& operator = (const NodeAppender&); |
| 71 | |
| 72 | Element* _pParent; |
| 73 | AbstractNode* _pLast; |
| 74 | }; |
| 75 | |
| 76 | |
| 77 | } } // namespace Poco::XML |
| 78 | |
| 79 | |
| 80 | #endif // #include "Poco/XML/XML.h" |
| 81 | |
| 82 | |