KHtml

dom3_xpathimpl.h
1 /*
2  * dom3_xpathimpl.h - Copyright 2005 Frerich Raabe <[email protected]>
3  * Copyright 2010 Maksim Orlovich <[email protected]>
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 #ifndef XPATHRESULTIMPL_H
27 #define XPATHRESULTIMPL_H
28 
29 #include "misc/shared.h"
30 #include "xpath/expression.h"
31 #include "xpath/parsedstatement.h"
32 
33 namespace DOM
34 {
35 class DOMStringImpl;
36 class NodeImpl;
37 }
38 
39 namespace khtml
40 {
41 
42 class XPathNSResolverImpl;
43 
44 class XPathResultImpl : public Shared<XPathResultImpl>
45 {
46 public:
47  XPathResultImpl();
48  XPathResultImpl(const XPath::Value &value);
49 
50  void convertTo(unsigned short type, int &exceptioncode);
51 
52  unsigned short resultType() const;
53 
54  double numberValue(int &exceptioncode) const;
55  DOM::DOMString stringValue(int &exceptioncode) const;
56  bool booleanValue(int &exceptioncode) const;
57  DOM::NodeImpl *singleNodeValue(int &exceptioncode) const;
58 
59  bool invalidIteratorState() const;
60  unsigned long snapshotLength(int &exceptioncode) const;
61  DOM::NodeImpl *iterateNext(int &exceptioncode);
62  DOM::NodeImpl *snapshotItem(unsigned long index, int &exceptioncode);
63 
64 private:
65  XPath::Value m_value;
66  unsigned long m_nodeIterator;
67  unsigned short m_resultType;
68 };
69 
70 class XPathExpressionImpl : public Shared<XPathExpressionImpl>
71 {
72 public:
73  XPathExpressionImpl(const DOM::DOMString &expression,
74  XPathNSResolverImpl *resolver);
75 
76  // expression we got while parsing, or 0
77  int parseExceptionCode();
78 
79  XPathResultImpl *evaluate(DOM::NodeImpl *contextNode,
80  unsigned short type,
81  XPathResultImpl *result,
82  int &exceptioncode);
83 
84 private:
85  XPath::ParsedStatement m_statement;
86 };
87 
88 // This is the base class for resolver interfaces
89 class XPathNSResolverImpl : public khtml::Shared<XPathNSResolverImpl>
90 {
91 public:
92  enum Type {
93  Default,
94  JS,
95  CPP
96  };
97 
98  virtual DOM::DOMString lookupNamespaceURI(const DOM::DOMString &prefix) = 0;
99  virtual Type type() = 0;
100  virtual ~XPathNSResolverImpl() {}
101 };
102 
103 // This is the default implementation, used by createNSResolver
104 class DefaultXPathNSResolverImpl : public XPathNSResolverImpl
105 {
106 public:
107  DefaultXPathNSResolverImpl(DOM::NodeImpl *node);
108 
109  DOM::DOMString lookupNamespaceURI(const DOM::DOMString &prefix) override;
110  Type type() override
111  {
112  return Default;
113  }
114 
115 private:
116  SharedPtr<DOM::NodeImpl> m_node;
117 };
118 
119 } // namespace khtml
120 
121 #endif // XPATHRESULTIMPL_H
122 
This file is part of the HTML rendering engine for KDE.
Type type(const QSqlDatabase &db)
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
This library provides a full-featured HTML parser and widget.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 16 2021 22:47:52 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.