[2674] | 1 | /* |
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
| 3 | * contributor license agreements. See the NOTICE file distributed with |
---|
| 4 | * this work for additional information regarding copyright ownership. |
---|
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
| 6 | * (the "License"); you may not use this file except in compliance with |
---|
| 7 | * the License. You may obtain a copy of the License at |
---|
| 8 | * |
---|
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 10 | * |
---|
| 11 | * Unless required by applicable law or agreed to in writing, software |
---|
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 14 | * See the License for the specific language governing permissions and |
---|
| 15 | * limitations under the License. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | /* |
---|
| 19 | * $Id: DOM_DocumentFragment.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #ifndef DOM_DocumentFragment_HEADER_GUARD_ |
---|
| 23 | #define DOM_DocumentFragment_HEADER_GUARD_ |
---|
| 24 | |
---|
| 25 | #include <xercesc/util/XercesDefs.hpp> |
---|
| 26 | #include "DOM_Node.hpp" |
---|
| 27 | |
---|
| 28 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | class DocumentFragmentImpl; |
---|
| 32 | |
---|
| 33 | /** |
---|
| 34 | * <code>DocumentFragment</code> is a "lightweight" or "minimal" |
---|
| 35 | * <code>Document</code> object. |
---|
| 36 | * |
---|
| 37 | * It is very common to want to be able to |
---|
| 38 | * extract a portion of a document's tree or to create a new fragment of a |
---|
| 39 | * document. Imagine implementing a user command like cut or rearranging a |
---|
| 40 | * document by moving fragments around. It is desirable to have an object |
---|
| 41 | * which can hold such fragments and it is quite natural to use a Node for |
---|
| 42 | * this purpose. While it is true that a <code>Document</code> object could |
---|
| 43 | * fulfil this role, a <code>Document</code> object can potentially be a |
---|
| 44 | * heavyweight object, depending on the underlying implementation. What is |
---|
| 45 | * really needed for this is a very lightweight object. |
---|
| 46 | * <code>DocumentFragment</code> is such an object. |
---|
| 47 | * <p>Furthermore, various operations -- such as inserting nodes as children |
---|
| 48 | * of another <code>Node</code> -- may take <code>DocumentFragment</code> |
---|
| 49 | * objects as arguments; this results in all the child nodes of the |
---|
| 50 | * <code>DocumentFragment</code> being moved to the child list of this node. |
---|
| 51 | * <p>The children of a <code>DocumentFragment</code> node are zero or more |
---|
| 52 | * nodes representing the tops of any sub-trees defining the structure of the |
---|
| 53 | * document. <code>DocumentFragment</code> nodes do not need to be |
---|
| 54 | * well-formed XML documents (although they do need to follow the rules |
---|
| 55 | * imposed upon well-formed XML parsed entities, which can have multiple top |
---|
| 56 | * nodes). For example, a <code>DocumentFragment</code> might have only one |
---|
| 57 | * child and that child node could be a <code>Text</code> node. Such a |
---|
| 58 | * structure model represents neither an HTML document nor a well-formed XML |
---|
| 59 | * document. |
---|
| 60 | * <p>When a <code>DocumentFragment</code> is inserted into a |
---|
| 61 | * <code>Document</code> (or indeed any other <code>Node</code> that may take |
---|
| 62 | * children) the children of the <code>DocumentFragment</code> and not the |
---|
| 63 | * <code>DocumentFragment</code> itself are inserted into the |
---|
| 64 | * <code>Node</code>. This makes the <code>DocumentFragment</code> very |
---|
| 65 | * useful when the user wishes to create nodes that are siblings; the |
---|
| 66 | * <code>DocumentFragment</code> acts as the parent of these nodes so that the |
---|
| 67 | * user can use the standard methods from the <code>Node</code> interface, |
---|
| 68 | * such as <code>insertBefore()</code> and <code>appendChild()</code>. |
---|
| 69 | */ |
---|
| 70 | |
---|
| 71 | class DEPRECATED_DOM_EXPORT DOM_DocumentFragment: public DOM_Node { |
---|
| 72 | |
---|
| 73 | public: |
---|
| 74 | /** @name Constructors and assignment operators */ |
---|
| 75 | //@{ |
---|
| 76 | /** |
---|
| 77 | * Default constructor for <code>DOM_DocumentFragment</code>. The resulting object does not |
---|
| 78 | * refer to an actual Document Fragment node; it will compare == to 0, and is similar |
---|
| 79 | * to a null object reference variable in Java. It may subsequently be |
---|
| 80 | * assigned to refer to an actual Document Fragment node. |
---|
| 81 | * <p> |
---|
| 82 | * New document fragment nodes are created by DOM_Document::createDocumentFragment(). |
---|
| 83 | * |
---|
| 84 | */ |
---|
| 85 | |
---|
| 86 | DOM_DocumentFragment(); |
---|
| 87 | |
---|
| 88 | /** |
---|
| 89 | * Copy constructor. Creates a new <code>DOM_DocumentFragment</code> that refers to the |
---|
| 90 | * same underlying node as the original. See also DOM_Node::clone(), |
---|
| 91 | * which will copy the actual Document fragment node, rather than just creating a new |
---|
| 92 | * reference to the original node. |
---|
| 93 | * |
---|
| 94 | * @param other The object to be copied |
---|
| 95 | */ |
---|
| 96 | DOM_DocumentFragment(const DOM_DocumentFragment &other); |
---|
| 97 | |
---|
| 98 | /** |
---|
| 99 | * Assignment operator |
---|
| 100 | * |
---|
| 101 | * @param other The object to be copied |
---|
| 102 | */ |
---|
| 103 | DOM_DocumentFragment & operator = (const DOM_DocumentFragment &other); |
---|
| 104 | |
---|
| 105 | /** |
---|
| 106 | * Assignment operator. This overloaded variant is provided for |
---|
| 107 | * the sole purpose of setting a DOM_Node reference variable to |
---|
| 108 | * zero. Nulling out a reference variable in this way will decrement |
---|
| 109 | * the reference count on the underlying Node object that the variable |
---|
| 110 | * formerly referenced. This effect is normally obtained when reference |
---|
| 111 | * variable goes out of scope, but zeroing them can be useful for |
---|
| 112 | * global instances, or for local instances that will remain in scope |
---|
| 113 | * for an extended time, when the storage belonging to the underlying |
---|
| 114 | * node needs to be reclaimed. |
---|
| 115 | * |
---|
| 116 | * @param val Only a value of 0, or null, is allowed. |
---|
| 117 | */ |
---|
| 118 | DOM_DocumentFragment & operator = (const DOM_NullPtr *val); |
---|
| 119 | |
---|
| 120 | //@} |
---|
| 121 | /** @name Destructor */ |
---|
| 122 | //@{ |
---|
| 123 | |
---|
| 124 | /** |
---|
| 125 | * Destructor. The object being destroyed is the reference |
---|
| 126 | * object, not the underlying Comment node itself. |
---|
| 127 | * |
---|
| 128 | */ |
---|
| 129 | ~DOM_DocumentFragment(); |
---|
| 130 | |
---|
| 131 | //@} |
---|
| 132 | |
---|
| 133 | protected: |
---|
| 134 | DOM_DocumentFragment(DocumentFragmentImpl *); |
---|
| 135 | |
---|
| 136 | friend class DOM_Document; |
---|
| 137 | friend class RangeImpl; |
---|
| 138 | }; |
---|
| 139 | |
---|
| 140 | XERCES_CPP_NAMESPACE_END |
---|
| 141 | |
---|
| 142 | #endif |
---|