|
| 1 | +// |
| 2 | +// NodeAppender.h |
| 3 | +// |
| 4 | +// $Id: //poco/Main/XML/include/Poco/DOM/NodeAppender.h#1 $ |
| 5 | +// |
| 6 | +// Library: XML |
| 7 | +// Package: DOM |
| 8 | +// Module: NodeAppender |
| 9 | +// |
| 10 | +// Definition of the NodeAppender class. |
| 11 | +// |
| 12 | +// Copyright (c) 2007, 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_NodeAppender_INCLUDED |
| 40 | +#define DOM_NodeAppender_INCLUDED |
| 41 | + |
| 42 | + |
| 43 | +#include "Poco/XML/XML.h" |
| 44 | +#include "Poco/DOM/Node.h" |
| 45 | + |
| 46 | + |
| 47 | +namespace Poco { |
| 48 | +namespace XML { |
| 49 | + |
| 50 | + |
| 51 | +class AbstractNode; |
| 52 | +class Element; |
| 53 | + |
| 54 | + |
| 55 | +class XML_API NodeAppender |
| 56 | + /// The NodeAppender class provides a very fast way to |
| 57 | + /// build larger DOM documents. |
| 58 | + /// |
| 59 | + /// In the DOM, child nodes are usually appended to a parent |
| 60 | + /// node using the appendChild() method. For nodes containing |
| 61 | + /// more than a few children, this method can be quite slow, |
| 62 | + /// due to the way it's implemented, and because of the |
| 63 | + /// requirements of the DOM specification. |
| 64 | + /// |
| 65 | + /// While the NodeAppender is being used on an Element, no |
| 66 | + /// children-modifying methods of that Element must be used. |
| 67 | + /// |
| 68 | + /// This class is not part of the DOM specification. |
| 69 | +{ |
| 70 | +public: |
| 71 | + NodeAppender(Element* parent); |
| 72 | + /// Creates the NodeAppender for the given parent node, |
| 73 | + /// which must be an Element. |
| 74 | + |
| 75 | + ~NodeAppender(); |
| 76 | + /// Destroys the NodeAppender. |
| 77 | + |
| 78 | + void appendChild(Node* newChild); |
| 79 | + /// Appends the node newChild to the end of the list of children of |
| 80 | + /// the parent node specified in the constructor. |
| 81 | + /// If the newChild is already in the tree, it is first removed. |
| 82 | + /// |
| 83 | + /// NewChild can be a DocumentFragment. In this case, all children |
| 84 | + /// of the fragment become children of the parent element. |
| 85 | + /// |
| 86 | + /// In order to speed up the function, no DOM events |
| 87 | + /// are fired. |
| 88 | + |
| 89 | +private: |
| 90 | + NodeAppender(); |
| 91 | + NodeAppender(const NodeAppender&); |
| 92 | + NodeAppender& operator = (const NodeAppender&); |
| 93 | + |
| 94 | + Element* _pParent; |
| 95 | + AbstractNode* _pLast; |
| 96 | +}; |
| 97 | + |
| 98 | + |
| 99 | +} } // namespace Poco::XML |
| 100 | + |
| 101 | + |
| 102 | +#endif // #include "Poco/XML/XML.h" |
| 103 | + |
0 commit comments