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_NodeIterator.hpp,v 1.5 2004/09/08 13:55:42 peiyongz Exp $
|
---|
19 | */
|
---|
20 |
|
---|
21 | #ifndef DOM_NodeIterator_HEADER_GUARD_
|
---|
22 | #define DOM_NodeIterator_HEADER_GUARD_
|
---|
23 |
|
---|
24 | #include "DOM_NodeFilter.hpp"
|
---|
25 | #include "DOM_Node.hpp"
|
---|
26 |
|
---|
27 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
28 |
|
---|
29 |
|
---|
30 | class NodeIteratorImpl;
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * NodeIterators are used to step through a set of nodes
|
---|
34 | * e.g. the set of nodes in a NodeList, the document subtree governed by
|
---|
35 | * a particular node, the results of a query, or any other set of nodes.
|
---|
36 | * The set of nodes to be iterated is determined by the implementation
|
---|
37 | * of the NodeIterator. DOM Level 2 specifies a single NodeIterator
|
---|
38 | * implementation for document-order traversal of a document
|
---|
39 | * subtree. Instances of these iterators are created by calling
|
---|
40 | * <code>DocumentTraversal.createNodeIterator()</code>.
|
---|
41 | *
|
---|
42 | */
|
---|
43 | class DEPRECATED_DOM_EXPORT DOM_NodeIterator
|
---|
44 | {
|
---|
45 | public:
|
---|
46 | /** @name Constructors and assignment operator */
|
---|
47 | //@{
|
---|
48 | /**
|
---|
49 | * Default constructor.
|
---|
50 | */
|
---|
51 | DOM_NodeIterator ();
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * Copy constructor.
|
---|
55 | *
|
---|
56 | * @param other The object to be copied.
|
---|
57 | */
|
---|
58 | DOM_NodeIterator(const DOM_NodeIterator &other);
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * Assignment operator.
|
---|
62 | *
|
---|
63 | * @param other The object to be copied.
|
---|
64 | */
|
---|
65 | DOM_NodeIterator & operator = (const DOM_NodeIterator &other);
|
---|
66 |
|
---|
67 | /**
|
---|
68 | * Assignment operator. This overloaded variant is provided for
|
---|
69 | * the sole purpose of setting a DOM_NodeIterator to null.
|
---|
70 | *
|
---|
71 | * @param val Only a value of 0, or null, is allowed.
|
---|
72 | */
|
---|
73 | DOM_NodeIterator & operator = (const DOM_NullPtr *val);
|
---|
74 | //@}
|
---|
75 |
|
---|
76 | /** @name Destructor. */
|
---|
77 | //@{
|
---|
78 | /**
|
---|
79 | * Destructor for DOM_NodeIterator.
|
---|
80 | */
|
---|
81 | ~DOM_NodeIterator();
|
---|
82 | //@}
|
---|
83 |
|
---|
84 | /** @name Equality and Inequality operators. */
|
---|
85 | //@{
|
---|
86 | /**
|
---|
87 | * The equality operator.
|
---|
88 | *
|
---|
89 | * @param other The object reference with which <code>this</code> object is compared
|
---|
90 | * @returns True if both <code>DOM_NodeIterator</code>s refer to the same
|
---|
91 | * actual node, or are both null; return false otherwise.
|
---|
92 | */
|
---|
93 | bool operator == (const DOM_NodeIterator & other)const;
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * Compare with a pointer. Intended only to allow a convenient
|
---|
97 | * comparison with null.
|
---|
98 | */
|
---|
99 | bool operator == (const DOM_NullPtr *other) const;
|
---|
100 |
|
---|
101 | /**
|
---|
102 | * The inequality operator. See operator ==.
|
---|
103 | */
|
---|
104 | bool operator != (const DOM_NodeIterator & other) const;
|
---|
105 |
|
---|
106 | /**
|
---|
107 | * Compare with a pointer. Intended only to allow a convenient
|
---|
108 | * comparison with null.
|
---|
109 | *
|
---|
110 | */
|
---|
111 | bool operator != (const DOM_NullPtr * other) const;
|
---|
112 | //@}
|
---|
113 |
|
---|
114 | /** @name Get functions. */
|
---|
115 | //@{
|
---|
116 | /**
|
---|
117 | * The root node of the <code>NodeIterator</code>, as specified when it
|
---|
118 | * was created.
|
---|
119 | */
|
---|
120 | DOM_Node getRoot();
|
---|
121 |
|
---|
122 | /**
|
---|
123 | * Return which node types are presented via the iterator.
|
---|
124 | * The available set of constants is defined in the DOM_NodeFilter interface.
|
---|
125 | *
|
---|
126 | */
|
---|
127 | unsigned long getWhatToShow();
|
---|
128 |
|
---|
129 | /**
|
---|
130 | * Return The filter used to screen nodes.
|
---|
131 | *
|
---|
132 | */
|
---|
133 | DOM_NodeFilter* getFilter();
|
---|
134 |
|
---|
135 | /**
|
---|
136 | * Return the expandEntityReferences flag.
|
---|
137 | * The value of this flag determines whether the children of entity reference
|
---|
138 | * nodes are visible to the DOM_NodeFilter. If false, they will be skipped over.
|
---|
139 | *
|
---|
140 | */
|
---|
141 | bool getExpandEntityReferences();
|
---|
142 |
|
---|
143 | /**
|
---|
144 | * Returns the next node in the set and advances the position of the iterator
|
---|
145 | * in the set. After a DOM_NodeIterator is created, the first call to nextNode()
|
---|
146 | * returns the first node in the set.
|
---|
147 | *
|
---|
148 | * @exception DOMException
|
---|
149 | * INVALID_STATE_ERR: Raised if this method is called after the
|
---|
150 | * <code>detach</code> method was invoked.
|
---|
151 | */
|
---|
152 | DOM_Node nextNode();
|
---|
153 |
|
---|
154 | /**
|
---|
155 | * Returns the previous node in the set and moves the position of the iterator
|
---|
156 | * backwards in the set.
|
---|
157 | *
|
---|
158 | * @exception DOMException
|
---|
159 | * INVALID_STATE_ERR: Raised if this method is called after the
|
---|
160 | * <code>detach</code> method was invoked.
|
---|
161 | */
|
---|
162 | DOM_Node previousNode();
|
---|
163 | //@}
|
---|
164 |
|
---|
165 | /** @name Detaching functions. */
|
---|
166 | //@{
|
---|
167 | /**
|
---|
168 | * Detaches the iterator from the set which it iterated over, releasing any
|
---|
169 | * computational resources and placing the iterator in the INVALID state. After
|
---|
170 | * <code>detach</code> has been invoked, calls to <code>nextNode</code> or
|
---|
171 | * <code>previousNode</code> will raise the exception INVALID_STATE_ERR.
|
---|
172 | *
|
---|
173 | */
|
---|
174 | void detach();
|
---|
175 | //@}
|
---|
176 |
|
---|
177 | protected:
|
---|
178 | DOM_NodeIterator (NodeIteratorImpl* impl);
|
---|
179 |
|
---|
180 | friend class DOM_Document;
|
---|
181 |
|
---|
182 | private:
|
---|
183 | NodeIteratorImpl* fImpl;
|
---|
184 | };
|
---|
185 |
|
---|
186 | XERCES_CPP_NAMESPACE_END
|
---|
187 |
|
---|
188 | #endif
|
---|