/src/mozilla-central/dom/xslt/xpath/txIXPathContext.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
3 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | | |
6 | | #ifndef __TX_I_XPATH_CONTEXT |
7 | | #define __TX_I_XPATH_CONTEXT |
8 | | |
9 | | #include "txCore.h" |
10 | | |
11 | | class FunctionCall; |
12 | | class nsAtom; |
13 | | class txAExprResult; |
14 | | class txResultRecycler; |
15 | | class txXPathNode; |
16 | | |
17 | | /* |
18 | | * txIParseContext |
19 | | * |
20 | | * This interface describes the context needed to create |
21 | | * XPath Expressions and XSLT Patters. |
22 | | * (not completely though. key() requires the ProcessorState, which is |
23 | | * not part of this interface.) |
24 | | */ |
25 | | |
26 | | class txIParseContext |
27 | | { |
28 | | public: |
29 | | virtual ~txIParseContext() |
30 | 0 | { |
31 | 0 | } |
32 | | |
33 | | /* |
34 | | * Return a namespaceID for a given prefix. |
35 | | */ |
36 | | virtual nsresult resolveNamespacePrefix(nsAtom* aPrefix, int32_t& aID) = 0; |
37 | | |
38 | | /* |
39 | | * Create a FunctionCall, needed for extension function calls and |
40 | | * XSLT. XPath function calls are resolved by the Parser. |
41 | | */ |
42 | | virtual nsresult resolveFunctionCall(nsAtom* aName, int32_t aID, |
43 | | FunctionCall** aFunction) = 0; |
44 | | |
45 | | /** |
46 | | * Should nametests parsed in this context be case-sensitive |
47 | | */ |
48 | | virtual bool caseInsensitiveNameTests() = 0; |
49 | | |
50 | | /* |
51 | | * Callback to be used by the Parser if errors are detected. |
52 | | */ |
53 | | virtual void SetErrorOffset(uint32_t aOffset) = 0; |
54 | | |
55 | | enum Allowed { |
56 | | KEY_FUNCTION = 1 << 0 |
57 | | }; |
58 | | virtual bool allowed(Allowed aAllowed) |
59 | 0 | { |
60 | 0 | return true; |
61 | 0 | } |
62 | | }; |
63 | | |
64 | | /* |
65 | | * txIMatchContext |
66 | | * |
67 | | * Interface used for matching XSLT Patters. |
68 | | * This is the part of txIEvalContext (see below), that is independent |
69 | | * of the context node when evaluating a XPath expression, too. |
70 | | * When evaluating a XPath expression, |txIMatchContext|s are used |
71 | | * to transport the information from Step to Step. |
72 | | */ |
73 | | class txIMatchContext |
74 | | { |
75 | | public: |
76 | | virtual ~txIMatchContext() |
77 | 0 | { |
78 | 0 | } |
79 | | |
80 | | /* |
81 | | * Return the ExprResult associated with the variable with the |
82 | | * given namespace and local name. |
83 | | */ |
84 | | virtual nsresult getVariable(int32_t aNamespace, nsAtom* aLName, |
85 | | txAExprResult*& aResult) = 0; |
86 | | |
87 | | /* |
88 | | * Is whitespace stripping allowed for the given node? |
89 | | * See http://www.w3.org/TR/xslt#strip |
90 | | */ |
91 | | virtual nsresult isStripSpaceAllowed(const txXPathNode& aNode, |
92 | | bool& aAllowed) = 0; |
93 | | |
94 | | /** |
95 | | * Returns a pointer to the private context |
96 | | */ |
97 | | virtual void* getPrivateContext() = 0; |
98 | | |
99 | | virtual txResultRecycler* recycler() = 0; |
100 | | |
101 | | /* |
102 | | * Callback to be used by the expression/pattern if errors are detected. |
103 | | */ |
104 | | virtual void receiveError(const nsAString& aMsg, nsresult aRes) = 0; |
105 | | }; |
106 | | |
107 | | #define TX_DECL_MATCH_CONTEXT \ |
108 | | nsresult getVariable(int32_t aNamespace, nsAtom* aLName, \ |
109 | | txAExprResult*& aResult) override; \ |
110 | | nsresult isStripSpaceAllowed(const txXPathNode& aNode, \ |
111 | | bool& aAllowed) override; \ |
112 | | void* getPrivateContext() override; \ |
113 | | txResultRecycler* recycler() override; \ |
114 | | void receiveError(const nsAString& aMsg, nsresult aRes) override |
115 | | |
116 | | class txIEvalContext : public txIMatchContext |
117 | | { |
118 | | public: |
119 | | /* |
120 | | * Get the context node. |
121 | | */ |
122 | | virtual const txXPathNode& getContextNode() = 0; |
123 | | |
124 | | /* |
125 | | * Get the size of the context node set. |
126 | | */ |
127 | | virtual uint32_t size() = 0; |
128 | | |
129 | | /* |
130 | | * Get the position of the context node in the context node set, |
131 | | * starting with 1. |
132 | | */ |
133 | | virtual uint32_t position() = 0; |
134 | | }; |
135 | | |
136 | | #define TX_DECL_EVAL_CONTEXT \ |
137 | | TX_DECL_MATCH_CONTEXT; \ |
138 | | const txXPathNode& getContextNode() override; \ |
139 | | uint32_t size() override; \ |
140 | | uint32_t position() override |
141 | | |
142 | | #endif // __TX_I_XPATH_CONTEXT |