[188] | 1 | #ifndef DOMXPathResult_HEADER_GUARD_
|
---|
| 2 | #define DOMXPathResult_HEADER_GUARD_
|
---|
| 3 |
|
---|
| 4 | /*
|
---|
| 5 | * The Apache Software License, Version 1.1
|
---|
| 6 | *
|
---|
| 7 | * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
|
---|
| 8 | * reserved.
|
---|
| 9 | *
|
---|
| 10 | * Redistribution and use in source and binary forms, with or without
|
---|
| 11 | * modification, are permitted provided that the following conditions
|
---|
| 12 | * are met:
|
---|
| 13 | *
|
---|
| 14 | * 1. Redistributions of source code must retain the above copyright
|
---|
| 15 | * notice, this list of conditions and the following disclaimer.
|
---|
| 16 | *
|
---|
| 17 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
| 18 | * notice, this list of conditions and the following disclaimer in
|
---|
| 19 | * the documentation and/or other materials provided with the
|
---|
| 20 | * distribution.
|
---|
| 21 | *
|
---|
| 22 | * 3. The end-user documentation included with the redistribution,
|
---|
| 23 | * if any, must include the following acknowledgment:
|
---|
| 24 | * "This product includes software developed by the
|
---|
| 25 | * Apache Software Foundation (http://www.apache.org/)."
|
---|
| 26 | * Alternately, this acknowledgment may appear in the software itself,
|
---|
| 27 | * if and wherever such third-party acknowledgments normally appear.
|
---|
| 28 | *
|
---|
| 29 | * 4. The names "Xerces" and "Apache Software Foundation" must
|
---|
| 30 | * not be used to endorse or promote products derived from this
|
---|
| 31 | * software without prior written permission. For written
|
---|
| 32 | * permission, please contact apache\@apache.org.
|
---|
| 33 | *
|
---|
| 34 | * 5. Products derived from this software may not be called "Apache",
|
---|
| 35 | * nor may "Apache" appear in their name, without prior written
|
---|
| 36 | * permission of the Apache Software Foundation.
|
---|
| 37 | *
|
---|
| 38 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
---|
| 39 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 40 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
| 41 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
---|
| 42 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
| 43 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
| 44 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
| 45 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
| 46 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
| 47 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
| 48 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
| 49 | * SUCH DAMAGE.
|
---|
| 50 | * ====================================================================
|
---|
| 51 | *
|
---|
| 52 | * This software consists of voluntary contributions made by many
|
---|
| 53 | * individuals on behalf of the Apache Software Foundation, and was
|
---|
| 54 | * originally based on software copyright (c) 2001, International
|
---|
| 55 | * Business Machines, Inc., http://www.ibm.com . For more information
|
---|
| 56 | * on the Apache Software Foundation, please see
|
---|
| 57 | * <http://www.apache.org/>.
|
---|
| 58 | */
|
---|
| 59 |
|
---|
| 60 | #include <xercesc/util/XercesDefs.hpp>
|
---|
| 61 |
|
---|
| 62 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
| 63 |
|
---|
| 64 | class DOMXPathNSResolver;
|
---|
| 65 | class DOMXPathExpression;
|
---|
| 66 | class DOMNode;
|
---|
| 67 |
|
---|
| 68 | /**
|
---|
| 69 | * The <code>DOMXPathResult</code> interface represents the result of the
|
---|
| 70 | * evaluation of an XPath 1.0 expression within the context of a particular
|
---|
| 71 | * node. Since evaluation of an XPath expression can result in various result
|
---|
| 72 | * types, this object makes it possible to discover and manipulate the type
|
---|
| 73 | * and value of the result.
|
---|
| 74 | * @since DOM Level 3
|
---|
| 75 | */
|
---|
| 76 | class CDOM_EXPORT DOMXPathResult
|
---|
| 77 | {
|
---|
| 78 |
|
---|
| 79 | protected:
|
---|
| 80 | // -----------------------------------------------------------------------
|
---|
| 81 | // Hidden constructors
|
---|
| 82 | // -----------------------------------------------------------------------
|
---|
| 83 | /** @name Hidden constructors */
|
---|
| 84 | //@{
|
---|
| 85 | DOMXPathResult() {};
|
---|
| 86 | //@}
|
---|
| 87 |
|
---|
| 88 | private:
|
---|
| 89 | // -----------------------------------------------------------------------
|
---|
| 90 | // Unimplemented constructors and operators
|
---|
| 91 | // -----------------------------------------------------------------------
|
---|
| 92 | /** @name Unimplemented constructors and operators */
|
---|
| 93 | //@{
|
---|
| 94 | DOMXPathResult(const DOMXPathResult &);
|
---|
| 95 | DOMXPathResult& operator = (const DOMXPathResult&);
|
---|
| 96 | //@}
|
---|
| 97 |
|
---|
| 98 | public:
|
---|
| 99 | // -----------------------------------------------------------------------
|
---|
| 100 | // All constructors are hidden, just the destructor is available
|
---|
| 101 | // -----------------------------------------------------------------------
|
---|
| 102 | /** @name Destructor */
|
---|
| 103 | //@{
|
---|
| 104 | /**
|
---|
| 105 | * Destructor
|
---|
| 106 | *
|
---|
| 107 | */
|
---|
| 108 | virtual ~DOMXPathResult() {};
|
---|
| 109 | //@}
|
---|
| 110 |
|
---|
| 111 | // -----------------------------------------------------------------------
|
---|
| 112 | // Class Types
|
---|
| 113 | // -----------------------------------------------------------------------
|
---|
| 114 | /** @name Public Contants */
|
---|
| 115 | //@{
|
---|
| 116 | /** ANY_TYPE
|
---|
| 117 | * This code does not represent a specific type. An evaluation of an XPath
|
---|
| 118 | * expression will never produce this type. If this type is requested, then
|
---|
| 119 | * the evaluation returns whatever type naturally results from evaluation
|
---|
| 120 | * of the expression.
|
---|
| 121 | * If the natural result is a node set when ANY_TYPE was requested, then
|
---|
| 122 | * UNORDERED_NODE_ITERATOR_TYPE is always the resulting type. Any other
|
---|
| 123 | * representation of a node set must be explicitly requested.
|
---|
| 124 | * ANY_UNORDERED_NODE_TYPE
|
---|
| 125 | * The result is a node set as defined by [XPath 1.0] and will be accessed
|
---|
| 126 | * as a single node, which may be nullif the node set is empty. Document
|
---|
| 127 | * modification does not invalidate the node, but may mean that the result
|
---|
| 128 | * node no longer corresponds to the current document. This is a convenience
|
---|
| 129 | * that permits optimization since the implementation can stop once any node
|
---|
| 130 | * in the resulting set has been found.
|
---|
| 131 | * If there is more than one node in the actual result, the single node
|
---|
| 132 | * returned might not be the first in document order.
|
---|
| 133 | * BOOLEAN_TYPE
|
---|
| 134 | * The result is a boolean as defined by [XPath 1.0]. Document modification
|
---|
| 135 | * does not invalidate the boolean, but may mean that reevaluation would not
|
---|
| 136 | * yield the same boolean.
|
---|
| 137 | * FIRST_ORDERED_NODE_TYPE
|
---|
| 138 | * The result is a node set as defined by [XPath 1.0] and will be accessed
|
---|
| 139 | * as a single node, which may be null if the node set is empty. Document
|
---|
| 140 | * modification does not invalidate the node, but may mean that the result
|
---|
| 141 | * node no longer corresponds to the current document. This is a convenience
|
---|
| 142 | * that permits optimization since the implementation can stop once the first
|
---|
| 143 | * node in document order of the resulting set has been found.
|
---|
| 144 | * If there are more than one node in the actual result, the single node
|
---|
| 145 | * returned will be the first in document order.
|
---|
| 146 | * NUMBER_TYPE
|
---|
| 147 | * The result is a number as defined by [XPath 1.0]. Document modification does
|
---|
| 148 | * not invalidate the number, but may mean that reevaluation would not yield the
|
---|
| 149 | * same number.
|
---|
| 150 | * ORDERED_NODE_ITERATOR_TYPE
|
---|
| 151 | * The result is a node set as defined by [XPath 1.0] that will be accessed
|
---|
| 152 | * iteratively, which will produce document-ordered nodes. Document modification
|
---|
| 153 | * invalidates the iteration.
|
---|
| 154 | * ORDERED_NODE_SNAPSHOT_TYPE
|
---|
| 155 | * The result is a node set as defined by [XPath 1.0] that will be accessed as a
|
---|
| 156 | * snapshot list of nodes that will be in original document order. Document
|
---|
| 157 | * modification does not invalidate the snapshot but may mean that reevaluation would
|
---|
| 158 | * not yield the same snapshot and nodes in the snapshot may have been altered, moved,
|
---|
| 159 | * or removed from the document.
|
---|
| 160 | * STRING_TYPE
|
---|
| 161 | * The result is a string as defined by [XPath 1.0]. Document modification does not
|
---|
| 162 | * invalidate the string, but may mean that the string no longer corresponds to the
|
---|
| 163 | * current document.
|
---|
| 164 | * UNORDERED_NODE_ITERATOR_TYPE
|
---|
| 165 | * The result is a node set as defined by [XPath 1.0] that will be accessed iteratively,
|
---|
| 166 | * which may not produce nodes in a particular order. Document modification invalidates the iteration.
|
---|
| 167 | * This is the default type returned if the result is a node set and ANY_TYPE is requested.
|
---|
| 168 | * UNORDERED_NODE_SNAPSHOT_TYPE
|
---|
| 169 | * The result is a node set as defined by [XPath 1.0] that will be accessed as a
|
---|
| 170 | * snapshot list of nodes that may not be in a particular order. Document modification
|
---|
| 171 | * does not invalidate the snapshot but may mean that reevaluation would not yield the same
|
---|
| 172 | * snapshot and nodes in the snapshot may have been altered, moved, or removed from the document.
|
---|
| 173 | */
|
---|
| 174 | enum resultType {
|
---|
| 175 | ANY_TYPE = 0,
|
---|
| 176 | NUMBER_TYPE = 1,
|
---|
| 177 | STRING_TYPE = 2,
|
---|
| 178 | BOOLEAN_TYPE = 3,
|
---|
| 179 | UNORDERED_NODE_ITERATOR_TYPE = 4,
|
---|
| 180 | ORDERED_NODE_ITERATOR_TYPE = 5,
|
---|
| 181 | UNORDERED_NODE_SNAPSHOT_TYPE = 6,
|
---|
| 182 | ORDERED_NODE_SNAPSHOT_TYPE = 7,
|
---|
| 183 | ANY_UNORDERED_NODE_TYPE = 8,
|
---|
| 184 | FIRST_ORDERED_NODE_TYPE = 9
|
---|
| 185 | };
|
---|
| 186 | //@}
|
---|
| 187 |
|
---|
| 188 |
|
---|
| 189 | // -----------------------------------------------------------------------
|
---|
| 190 | // Virtual DOMDocument interface
|
---|
| 191 | // -----------------------------------------------------------------------
|
---|
| 192 | /** @name Functions introduced in DOM Level 3 */
|
---|
| 193 | //@{
|
---|
| 194 |
|
---|
| 195 |
|
---|
| 196 | /**
|
---|
| 197 | * Returns the boolean value of this result
|
---|
| 198 | * @return booleanValue of type boolean, readonly
|
---|
| 199 | * The value of this boolean result.
|
---|
| 200 | * @exception XPathException
|
---|
| 201 | * TYPE_ERR: raised if resultType is not BOOLEAN_TYPE.
|
---|
| 202 | */
|
---|
| 203 | virtual bool getBooleanValue() const = 0;
|
---|
| 204 |
|
---|
| 205 | /**
|
---|
| 206 | * Returns the state of the iterator
|
---|
| 207 | * @return invalidIteratorState
|
---|
| 208 | * Signifies that the iterator has become invalid. True if resultType is
|
---|
| 209 | * UNORDERED_NODE_ITERATOR_TYPE or ORDERED_NODE_ITERATOR_TYPE and the
|
---|
| 210 | * document has been modified since this result was returned.
|
---|
| 211 | * @exception XPathException
|
---|
| 212 | * TYPE_ERR: raised if resultType is not NUMBER_TYPE.
|
---|
| 213 | */
|
---|
| 214 | virtual bool getInvalidIteratorState() const = 0;
|
---|
| 215 |
|
---|
| 216 | /**
|
---|
| 217 | * Returns the number value of this result
|
---|
| 218 | * @return numberValue
|
---|
| 219 | * The value of this number result. If the native double type of the DOM
|
---|
| 220 | * binding does not directly support the exact IEEE 754 result of the XPath
|
---|
| 221 | * expression, then it is up to the definition of the binding to specify how
|
---|
| 222 | * the XPath number is converted to the native binding number.
|
---|
| 223 | * @exception XPathException
|
---|
| 224 | * TYPE_ERR: raised if resultType is not NUMBER_TYPE.
|
---|
| 225 | */
|
---|
| 226 | virtual double getNumberValue() const = 0;
|
---|
| 227 |
|
---|
| 228 | /**
|
---|
| 229 | * Returns the result type of this result
|
---|
| 230 | * @return resultType
|
---|
| 231 | * A code representing the type of this result, as defined by the type constants.
|
---|
| 232 | * @exception XPathException
|
---|
| 233 | * TYPE_ERR: raised if resultType is not ANY_UNORDERED_NODE_TYPE or FIRST_ORDERED_NODE_TYPE.
|
---|
| 234 | */
|
---|
| 235 | virtual short getResultType() const = 0;
|
---|
| 236 |
|
---|
| 237 | /**
|
---|
| 238 | * Returns the single node value of this result
|
---|
| 239 | * @return singleNodeValue
|
---|
| 240 | * The value of this single node result, which may be null.
|
---|
| 241 | * @exception XPathException
|
---|
| 242 | * TYPE_ERR: raised if resultType is not ANY_UNORDERED_NODE_TYPE or FIRST_ORDERED_NODE_TYPE.
|
---|
| 243 | */
|
---|
| 244 | virtual DOMNode *getSingleNodeValue() const = 0;
|
---|
| 245 |
|
---|
| 246 | /**
|
---|
| 247 | * Returns the snapshot length
|
---|
| 248 | * @return snapshotLength
|
---|
| 249 | * The number of nodes in the result snapshot. Valid values for snapshotItem indices
|
---|
| 250 | * are 0 to snapshotLength-1 inclusive.
|
---|
| 251 | * @exception XPathException
|
---|
| 252 | * TYPE_ERR: raised if resultType is not UNORDERED_NODE_SNAPSHOT_TYPE or
|
---|
| 253 | * ORDERED_NODE_SNAPSHOT_TYPE.
|
---|
| 254 | */
|
---|
| 255 | virtual unsigned long getSnapshotLength() const = 0;
|
---|
| 256 |
|
---|
| 257 | /**
|
---|
| 258 | * Returns the string value of this result
|
---|
| 259 | * @return stringValue
|
---|
| 260 | * The value of this string result.
|
---|
| 261 | * @exception XPathException
|
---|
| 262 | * TYPE_ERR: raised if resultType is not STRING_TYPE.
|
---|
| 263 | */
|
---|
| 264 | virtual const XMLCh* getStringValue() const = 0;
|
---|
| 265 |
|
---|
| 266 | /**
|
---|
| 267 | * Iterates and returns the next node from the node set or nullif there are no more nodes.
|
---|
| 268 | * @return the next node.
|
---|
| 269 | * @exception XPathException
|
---|
| 270 | * TYPE_ERR: raised if resultType is not UNORDERED_NODE_ITERATOR_TYPE or ORDERED_NODE_ITERATOR_TYPE.
|
---|
| 271 | * @exception DOMException
|
---|
| 272 | * INVALID_STATE_ERR: The document has been mutated since the result was returned.
|
---|
| 273 | */
|
---|
| 274 | virtual DOMNode* iterateNext() const = 0;
|
---|
| 275 |
|
---|
| 276 | /**
|
---|
| 277 | * Returns the indexth item in the snapshot collection. If index is greater than or
|
---|
| 278 | * equal to the number of nodes in the list, this method returns null. Unlike the
|
---|
| 279 | * iterator result, the snapshot does not become invalid, but may not correspond
|
---|
| 280 | * to the current document if it is mutated.
|
---|
| 281 | * @param index of type unsigned long - Index into the snapshot collection.
|
---|
| 282 | * @return The node at the indexth position in the NodeList, or null if that is not a valid index.
|
---|
| 283 | * @exception XPathException
|
---|
| 284 | * TYPE_ERR: raised if resultType is not UNORDERED_NODE_SNAPSHOT_TYPE or ORDERED_NODE_SNAPSHOT_TYPE.
|
---|
| 285 | */
|
---|
| 286 | virtual DOMNode* snapshotItem(unsigned long index) const = 0;
|
---|
| 287 |
|
---|
| 288 | //@}
|
---|
| 289 | };
|
---|
| 290 |
|
---|
| 291 | XERCES_CPP_NAMESPACE_END
|
---|
| 292 |
|
---|
| 293 | #endif
|
---|