1 /*
2  * dom3_xpath.h - Copyright 2005 Frerich Raabe <raabe@kde.org>
3  *                Copyright 2010 Maksim Orlovich <maksim@kde.org>
4  *                Copyright 1999 Lars Knoll (knoll@kde.org)
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  * Based on kdomxpath.h, which was licensed as follows:
22  *   Redistribution and use in source and binary forms, with or without
23  *   modification, are permitted provided that the following conditions
24  *   are met:
25  *
26  *   1. Redistributions of source code must retain the above copyright
27  *      notice, this list of conditions and the following disclaimer.
28  *   2. Redistributions in binary form must reproduce the above copyright
29  *      notice, this list of conditions and the following disclaimer in the
30  *      documentation and/or other materials provided with the distribution.
31  *
32  *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
33  *   IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
34  *   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35  *   IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
36  *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37  *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
41  *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42  *
43  */
44 #ifndef DOM3_XPATH_H
45 #define DOM3_XPATH_H
46 
47 #include <dom_string.h>
48 
49 namespace DOM
50 {
51 
52 enum XPathExceptionCode {
53     INVALID_EXPRESSION_ERR = 51,
54     TYPE_ERR = 52
55 };
56 
57 namespace XPath
58 {
59 enum XPathResultType {
60     ANY_TYPE = 0,
61     NUMBER_TYPE = 1,
62     STRING_TYPE = 2,
63     BOOLEAN_TYPE = 3,
64     UNORDERED_NODE_ITERATOR_TYPE = 4,
65     ORDERED_NODE_ITERATOR_TYPE = 5,
66     UNORDERED_NODE_SNAPSHOT_TYPE = 6,
67     ORDERED_NODE_SNAPSHOT_TYPE = 7,
68     ANY_UNORDERED_NODE_TYPE = 8,
69     FIRST_ORDERED_NODE_TYPE = 9
70 };
71 }
72 
73 class KHTML_EXPORT XPathException
74 {
75 public:
XPathException(unsigned short _code)76     XPathException(unsigned short _code)
77     {
78         code = _code;
79     }
XPathException(const XPathException & other)80     XPathException(const XPathException &other)
81     {
82         code = other.code;
83     }
84 
85     XPathException &operator = (const XPathException &other)
86     {
87         code = other.code;
88         return *this;
89     }
90 
~XPathException()91     virtual ~XPathException() {}
92 
93     /**
94      * An integer indicating the type of error generated, as given by DOM L3 XPath
95      *
96      */
97     unsigned short   code;
98 
99     enum XPathExceptionCode {
100         INVALID_EXPRESSION_ERR = 51,
101         TYPE_ERR = 52,
102 
103         _EXCEPTION_OFFSET = 4000,
104         _EXCEPTION_MAX = 4999
105     };
106 
107     DOMString codeAsString() const;
108     static DOMString codeAsString(int xpathCode);
109 
110     /** @internal - converts XPath exception code to internal code */
111     static int toCode(int xpathCode);
112 
113     /** @internal - checks to see whether internal code is an XPath one */
114     static bool isXPathExceptionCode(int exceptioncode);
115 };
116 
117 }
118 
119 #endif // DOM3_XPATH_H
120 
121