source: NonGTP/Xerces/xerces/include/xercesc/dom/deprecated/DOM_DocumentFragment.hpp @ 358

Revision 358, 5.7 KB checked in by bittner, 19 years ago (diff)

xerces added

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