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

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

xerces added

Line 
1#ifndef DOMXPathResult_HEADER_GUARD_
2#define DOMXPathResult_HEADER_GUARD_
3
4/*
5 * Copyright 2001-2004 The Apache Software Foundation.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20#include <xercesc/util/XercesDefs.hpp>
21
22XERCES_CPP_NAMESPACE_BEGIN
23
24class DOMXPathNSResolver;
25class DOMXPathExpression;
26class DOMNode;
27
28/**
29 * The <code>DOMXPathResult</code> interface represents the result of the
30 * evaluation of an XPath 1.0 expression within the context of a particular
31 * node. Since evaluation of an XPath expression can result in various result
32 * types, this object makes it possible to discover and manipulate the type
33 * and value of the result.
34 * @since DOM Level 3
35 */
36class CDOM_EXPORT DOMXPathResult
37{
38
39protected:
40    // -----------------------------------------------------------------------
41    //  Hidden constructors
42    // -----------------------------------------------------------------------
43    /** @name Hidden constructors */
44    //@{   
45    DOMXPathResult() {};
46    //@}
47
48private:
49    // -----------------------------------------------------------------------
50    // Unimplemented constructors and operators
51    // -----------------------------------------------------------------------
52    /** @name Unimplemented constructors and operators */
53    //@{
54    DOMXPathResult(const DOMXPathResult &);
55    DOMXPathResult& operator = (const  DOMXPathResult&);
56    //@}
57
58public:
59    // -----------------------------------------------------------------------
60    //  All constructors are hidden, just the destructor is available
61    // -----------------------------------------------------------------------
62    /** @name Destructor */
63    //@{
64    /**
65     * Destructor
66     *
67     */
68    virtual ~DOMXPathResult() {};
69    //@}
70
71    // -----------------------------------------------------------------------
72    //  Class Types
73    // -----------------------------------------------------------------------
74    /** @name Public Contants */
75    //@{
76    /**    ANY_TYPE
77     * This code does not represent a specific type. An evaluation of an XPath
78     * expression will never produce this type. If this type is requested, then
79     * the evaluation returns whatever type naturally results from evaluation
80     * of the expression.
81     * If the natural result is a node set when ANY_TYPE was requested, then
82     * UNORDERED_NODE_ITERATOR_TYPE is always the resulting type. Any other
83     * representation of a node set must be explicitly requested.
84     * ANY_UNORDERED_NODE_TYPE
85     * The result is a node set as defined by [XPath 1.0] and will be accessed
86     * as a single node, which may be nullif the node set is empty. Document
87     * modification does not invalidate the node, but may mean that the result
88     * node no longer corresponds to the current document. This is a convenience
89     * that permits optimization since the implementation can stop once any node
90     * in the resulting set has been found.
91     * If there is more than one node in the actual result, the single node
92     * returned might not be the first in document order.
93     * BOOLEAN_TYPE
94     * The result is a boolean as defined by [XPath 1.0]. Document modification
95     * does not invalidate the boolean, but may mean that reevaluation would not
96     * yield the same boolean.
97     * FIRST_ORDERED_NODE_TYPE
98     * The result is a node set as defined by [XPath 1.0] and will be accessed
99     * as a single node, which may be null if the node set is empty. Document
100     * modification does not invalidate the node, but may mean that the result
101     * node no longer corresponds to the current document. This is a convenience
102     * that permits optimization since the implementation can stop once the first
103     * node in document order of the resulting set has been found.
104     * If there are more than one node in the actual result, the single node
105     * returned will be the first in document order.
106     * NUMBER_TYPE
107     * The result is a number as defined by [XPath 1.0]. Document modification does
108     * not invalidate the number, but may mean that reevaluation would not yield the
109     * same number.
110     * ORDERED_NODE_ITERATOR_TYPE
111     * The result is a node set as defined by [XPath 1.0] that will be accessed
112     * iteratively, which will produce document-ordered nodes. Document modification
113     * invalidates the iteration.
114     * ORDERED_NODE_SNAPSHOT_TYPE
115     * The result is a node set as defined by [XPath 1.0] that will be accessed as a
116     * snapshot list of nodes that will be in original document order. Document
117     * modification does not invalidate the snapshot but may mean that reevaluation would
118     * not yield the same snapshot and nodes in the snapshot may have been altered, moved,
119     * or removed from the document.
120     * STRING_TYPE
121     * The result is a string as defined by [XPath 1.0]. Document modification does not
122     * invalidate the string, but may mean that the string no longer corresponds to the
123     * current document.
124     * UNORDERED_NODE_ITERATOR_TYPE
125     * The result is a node set as defined by [XPath 1.0] that will be accessed iteratively,
126     * which may not produce nodes in a particular order. Document modification invalidates the iteration.
127     * This is the default type returned if the result is a node set and ANY_TYPE is requested.
128     * UNORDERED_NODE_SNAPSHOT_TYPE
129     * The result is a node set as defined by [XPath 1.0] that will be accessed as a
130     * snapshot list of nodes that may not be in a particular order. Document modification
131     * does not invalidate the snapshot but may mean that reevaluation would not yield the same
132     * snapshot and nodes in the snapshot may have been altered, moved, or removed from the document.
133     */
134        enum resultType {
135                ANY_TYPE = 0,
136                NUMBER_TYPE = 1,
137                STRING_TYPE = 2,
138                BOOLEAN_TYPE = 3,
139                UNORDERED_NODE_ITERATOR_TYPE = 4,
140                ORDERED_NODE_ITERATOR_TYPE = 5,
141                UNORDERED_NODE_SNAPSHOT_TYPE = 6,
142                ORDERED_NODE_SNAPSHOT_TYPE = 7,
143                ANY_UNORDERED_NODE_TYPE = 8,
144                FIRST_ORDERED_NODE_TYPE = 9
145    };
146    //@}
147
148
149    // -----------------------------------------------------------------------
150    // Virtual DOMDocument interface
151    // -----------------------------------------------------------------------
152    /** @name Functions introduced in DOM Level 3 */
153    //@{
154
155
156    /**
157     * Returns the boolean value of this result
158     * @return booleanValue of type boolean, readonly
159     * The value of this boolean result.
160     * @exception XPathException
161     * TYPE_ERR: raised if resultType is not BOOLEAN_TYPE.
162     */
163        virtual bool getBooleanValue() const = 0;
164
165    /**
166     * Returns the state of the iterator
167     * @return invalidIteratorState
168     * Signifies that the iterator has become invalid. True if resultType is
169     * UNORDERED_NODE_ITERATOR_TYPE or ORDERED_NODE_ITERATOR_TYPE and the
170     * document has been modified since this result was returned.
171     * @exception XPathException
172     * TYPE_ERR: raised if resultType is not NUMBER_TYPE.
173     */
174        virtual bool getInvalidIteratorState() const = 0;
175
176    /**
177     * Returns the number value of this result
178     * @return numberValue
179     * The value of this number result. If the native double type of the DOM
180     * binding does not directly support the exact IEEE 754 result of the XPath
181     * expression, then it is up to the definition of the binding to specify how
182     * the XPath number is converted to the native binding number.
183     * @exception XPathException
184     * TYPE_ERR: raised if resultType is not NUMBER_TYPE.
185     */
186        virtual double getNumberValue() const = 0;
187
188    /**
189     * Returns the result type of this result
190     * @return resultType
191     * A code representing the type of this result, as defined by the type constants.       
192     * @exception XPathException
193     * TYPE_ERR: raised if resultType is not ANY_UNORDERED_NODE_TYPE or FIRST_ORDERED_NODE_TYPE.
194     */
195        virtual short getResultType() const = 0;
196       
197    /**
198     * Returns the single node value of this result
199     * @return singleNodeValue
200     * The value of this single node result, which may be null.
201     * @exception XPathException
202     * TYPE_ERR: raised if resultType is not ANY_UNORDERED_NODE_TYPE or FIRST_ORDERED_NODE_TYPE.
203     */
204        virtual DOMNode *getSingleNodeValue() const = 0;
205
206    /**
207     * Returns the snapshot length
208     * @return snapshotLength
209     * The number of nodes in the result snapshot. Valid values for snapshotItem indices
210     * are 0 to snapshotLength-1 inclusive.
211     * @exception XPathException
212     * TYPE_ERR: raised if resultType is not UNORDERED_NODE_SNAPSHOT_TYPE or
213     * ORDERED_NODE_SNAPSHOT_TYPE.       
214     */
215        virtual unsigned long getSnapshotLength() const = 0;
216       
217    /**
218     * Returns the string value of this result
219     * @return stringValue
220     * The value of this string result.
221     * @exception XPathException
222     * TYPE_ERR: raised if resultType is not STRING_TYPE.
223     */
224        virtual const XMLCh* getStringValue() const = 0;
225   
226    /**
227     * Iterates and returns the next node from the node set or nullif there are no more nodes.
228     * @return the next node.
229     * @exception XPathException
230     * TYPE_ERR: raised if resultType is not UNORDERED_NODE_ITERATOR_TYPE or ORDERED_NODE_ITERATOR_TYPE.
231     * @exception DOMException
232     * INVALID_STATE_ERR: The document has been mutated since the result was returned. 
233     */
234        virtual DOMNode* iterateNext() const = 0;
235
236    /**
237     * Returns the indexth item in the snapshot collection. If index is greater than or
238     * equal to the number of nodes in the list, this method returns null. Unlike the
239     * iterator result, the snapshot does not become invalid, but may not correspond
240     * to the current document if it is mutated.
241     * @param index of type unsigned long - Index into the snapshot collection.
242     * @return The node at the indexth position in the NodeList, or null if that is not a valid index.
243     * @exception XPathException
244     * TYPE_ERR: raised if resultType is not UNORDERED_NODE_SNAPSHOT_TYPE or ORDERED_NODE_SNAPSHOT_TYPE.       
245     */
246        virtual DOMNode* snapshotItem(unsigned long index) const = 0;
247
248    //@}
249};
250
251XERCES_CPP_NAMESPACE_END
252
253#endif
Note: See TracBrowser for help on using the repository browser.