NodeAppender.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #ifndef DOM_NodeAppender_INCLUDED
  16. #define DOM_NodeAppender_INCLUDED
  17. #include "Poco/XML/XML.h"
  18. #include "Poco/DOM/Node.h"
  19. namespace Poco {
  20. namespace XML {
  21. class AbstractNode;
  22. class Element;
  23. class XML_API NodeAppender
  24. /// The NodeAppender class provides a very fast way to
  25. /// build larger DOM documents.
  26. ///
  27. /// In the DOM, child nodes are usually appended to a parent
  28. /// node using the appendChild() method. For nodes containing
  29. /// more than a few children, this method can be quite slow,
  30. /// due to the way it's implemented, and because of the
  31. /// requirements of the DOM specification.
  32. ///
  33. /// While the NodeAppender is being used on an Element, no
  34. /// children-modifying methods of that Element must be used.
  35. ///
  36. /// This class is not part of the DOM specification.
  37. {
  38. public:
  39. NodeAppender(Element* parent);
  40. /// Creates the NodeAppender for the given parent node,
  41. /// which must be an Element.
  42. ~NodeAppender();
  43. /// Destroys the NodeAppender.
  44. void appendChild(Node* newChild);
  45. /// Appends the node newChild to the end of the list of children of
  46. /// the parent node specified in the constructor.
  47. /// If the newChild is already in the tree, it is first removed.
  48. ///
  49. /// NewChild can be a DocumentFragment. In this case, all children
  50. /// of the fragment become children of the parent element.
  51. ///
  52. /// In order to speed up the function, no DOM events
  53. /// are fired.
  54. private:
  55. NodeAppender();
  56. NodeAppender(const NodeAppender&);
  57. NodeAppender& operator = (const NodeAppender&);
  58. Element* _pParent;
  59. AbstractNode* _pLast;
  60. };
  61. } } // namespace Poco::XML
  62. #endif // #include "Poco/XML/XML.h"