Code

Translations. POTFILES.in cleanup and inkscape.pot update.
[inkscape.git] / src / dom / xpath.h
1 #ifndef __XPATH_H__
2 #define __XPATH_H__
4 /**
5  * Phoebe DOM Implementation.
6  *
7  * This is a C++ approximation of the W3C DOM model, which follows
8  * fairly closely the specifications in the various .idl files, copies of
9  * which are provided for reference.  Most important is this one:
10  *
11  * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
12  *
13  * Authors:
14  *   Bob Jamison
15  *
16  * Copyright (C) 2005 Bob Jamison
17  *
18  *  This library is free software; you can redistribute it and/or
19  *  modify it under the terms of the GNU Lesser General Public
20  *  License as published by the Free Software Foundation; either
21  *  version 2.1 of the License, or (at your option) any later version.
22  *
23  *  This library is distributed in the hope that it will be useful,
24  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
25  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26  *  Lesser General Public License for more details.
27  *
28  *  You should have received a copy of the GNU Lesser General Public
29  *  License along with this library; if not, write to the Free Software
30  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
31  */
34 #include "dom.h"
37 namespace org
38 {
39 namespace w3c
40 {
41 namespace dom
42 {
43 namespace xpath
44 {
48 typedef dom::DOMString DOMString;
49 typedef dom::Node Node;
50 typedef dom::DOMObject DOMObject;
51 typedef dom::Element Element;
54 class XPathNSResolver;
55 class XPathExpression;
56 class XPathResult;
58 /*#########################################################################
59 ## XPathException
60 #########################################################################*/
61 /**
62  *  Maybe this should inherit from DOMException?
63  */
64 class XPathException
65 {
67 public:
69     XPathException(const DOMString &reasonMsg)
70         { msg = reasonMsg; }
72     XPathException(short theCode)
73         {
74         code = theCode;
75         }
77     virtual ~XPathException() throw()
78        {}
80     /**
81      *
82      */
83     unsigned short code;
85     /**
86      *
87      */
88     DOMString msg;
90     /**
91      * Get a string, translated from the code.
92      * Like std::exception. Not in spec.
93      */
94     const char *what()
95         { return msg.c_str(); }
99 };
102 /**
103  * XPathExceptionCode
104  */
105 typedef enum
107         INVALID_EXPRESSION_ERR         = 51,
108         TYPE_ERR                       = 52
109 } XPathExceptionCode;
112 /*#########################################################################
113 ## XPathEvaluator
114 #########################################################################*/
116 /**
117  *
118  */
119 class XPathEvaluator
121 public:
123     /**
124      *
125      */
126     virtual XPathExpression *createExpression(
127                                 const DOMString &expression,
128                                 const XPathNSResolver *resolver)
129                                 throw (XPathException, dom::DOMException) =0;
131     /**
132      *
133      */
134     virtual XPathNSResolver *createNSResolver(const Node *nodeResolver) =0;
136     /**
137      *
138      */
139     virtual XPathResult *evaluate(
140                                 const DOMString &expression,
141                                 const Node *contextNode,
142                                 const XPathNSResolver *resolver,
143                                 const unsigned short type,
144                                 const XPathResult *result)
145                                 throw (XPathException, dom::DOMException) =0;
147     //###################
148     //# Non-API methods
149     //###################
151     /**
152      *
153      */
154     virtual ~XPathEvaluator() {}
156 };
158 /*#########################################################################
159 ## XPathExpression
160 #########################################################################*/
162 /**
163  *
164  */
165 class XPathExpression
167 public:
170     /**
171      *
172      */
173     virtual XPathResult *evaluate(
174                                 const Node *contextNode,
175                                 unsigned short type,
176                                 const XPathResult *result)
177                                 throw (XPathException, dom::DOMException) =0;
180     //###################
181     //# Non-API methods
182     //###################
184     /**
185      *
186      */
187     virtual ~XPathExpression() {}
189 };
191 /*#########################################################################
192 ## XPathNSResolver
193 #########################################################################*/
195 /**
196  *
197  */
198 class XPathNSResolver
200 public:
202     /**
203      *
204      */
205     virtual DOMString lookupNamespaceURI(const DOMString &prefix) =0;
208     //###################
209     //# Non-API methods
210     //###################
212     /**
213      *
214      */
215     virtual ~XPathNSResolver() {}
217 };
219 /*#########################################################################
220 ## XPathResult
221 #########################################################################*/
223 /**
224  *
225  */
226 class XPathResult
228 public:
230     // XPathResultType
231     typedef enum
232         {
233         ANY_TYPE                       = 0,
234         NUMBER_TYPE                    = 1,
235         STRING_TYPE                    = 2,
236         BOOLEAN_TYPE                   = 3,
237         UNORDERED_NODE_ITERATOR_TYPE   = 4,
238         ORDERED_NODE_ITERATOR_TYPE     = 5,
239         UNORDERED_NODE_SNAPSHOT_TYPE   = 6,
240         ORDERED_NODE_SNAPSHOT_TYPE     = 7,
241         ANY_UNORDERED_NODE_TYPE        = 8,
242         FIRST_ORDERED_NODE_TYPE        = 9
243         } XPathResultType;
246     /**
247      *
248      */
249     virtual unsigned short  getResultType() throw (XPathException) =0;
251     /**
252      *
253      */
254     virtual double getNumberValue() throw (XPathException) =0;
256     /**
257      *
258      */
259     virtual DOMString getStringValue() throw (XPathException) =0;
261     /**
262      *
263      */
264     virtual bool getBooleanValue() throw (XPathException) =0;
266     /**
267      *
268      */
269     virtual Node *getSingleNodeValue() throw (XPathException) =0;
271     /**
272      *
273      */
274     virtual bool getInvalidIteratorState() throw (XPathException) =0;
276     /**
277      *
278      */
279     virtual unsigned long getSnapshotLength() throw (XPathException) =0;
281     /**
282      *
283      */
284     virtual Node *iterateNext() throw (XPathException, dom::DOMException) =0;
286     /**
287      *
288      */
289     virtual Node *snapshotItem(unsigned long index) throw (XPathException) =0;
291    //###################
292    //# Non-API methods
293    //###################
295     /**
296      *
297      */
298     virtual ~XPathResult() {}
300 };
302 /*#########################################################################
303 ## XPathNamespace
304 #########################################################################*/
305 class XPathNamespace : virtual public Node
307 public:
309     typedef enum
310         {
311         XPATH_NAMESPACE_NODE           = 13
312         } XPathNodeType;
314     /**
315      *
316      */
317     virtual Element *getOwnerElement() = 0;
320     //###################
321     //# Non-API methods
322     //###################
324     /**
325      *
326      */
327    virtual ~XPathNamespace() {}
329 };
335 }  //namespace xpath
336 }  //namespace dom
337 }  //namespace w3c
338 }  //namespace org
343 #endif /* __XPATH_H__ */
344 /*#########################################################################
345 ## E N D    O F    F I L E
346 #########################################################################*/