Bug 1874684 - Part 4: Prefer const references instead of copying Instant values....
[gecko.git] / dom / xslt / xpath / txIXPathContext.h
blob8d5b5df4becefcbe4de01426553cb67aa379bd62
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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/. */
6 #ifndef __TX_I_XPATH_CONTEXT
7 #define __TX_I_XPATH_CONTEXT
9 #include "nscore.h"
10 #include "nsISupportsImpl.h"
11 #include "nsStringFwd.h"
13 class FunctionCall;
14 class nsAtom;
15 class txAExprResult;
16 class txResultRecycler;
17 class txXPathNode;
20 * txIParseContext
22 * This interface describes the context needed to create
23 * XPath Expressions and XSLT Patters.
24 * (not completely though. key() requires the ProcessorState, which is
25 * not part of this interface.)
28 class txIParseContext {
29 public:
30 virtual ~txIParseContext() = default;
33 * Return a namespaceID for a given prefix.
35 virtual nsresult resolveNamespacePrefix(nsAtom* aPrefix, int32_t& aID) = 0;
38 * Create a FunctionCall, needed for extension function calls and
39 * XSLT. XPath function calls are resolved by the Parser.
41 virtual nsresult resolveFunctionCall(nsAtom* aName, int32_t aID,
42 FunctionCall** aFunction) = 0;
44 /**
45 * Should nametests parsed in this context be case-sensitive
47 virtual bool caseInsensitiveNameTests() = 0;
50 * Callback to be used by the Parser if errors are detected.
52 virtual void SetErrorOffset(uint32_t aOffset) = 0;
54 enum Allowed { KEY_FUNCTION = 1 << 0 };
55 virtual bool allowed(Allowed aAllowed) { return true; }
59 * txIMatchContext
61 * Interface used for matching XSLT Patters.
62 * This is the part of txIEvalContext (see below), that is independent
63 * of the context node when evaluating a XPath expression, too.
64 * When evaluating a XPath expression, |txIMatchContext|s are used
65 * to transport the information from Step to Step.
67 class txIMatchContext {
68 public:
69 virtual ~txIMatchContext() = default;
72 * Return the ExprResult associated with the variable with the
73 * given namespace and local name.
75 virtual nsresult getVariable(int32_t aNamespace, nsAtom* aLName,
76 txAExprResult*& aResult) = 0;
79 * Is whitespace stripping allowed for the given node?
80 * See http://www.w3.org/TR/xslt#strip
82 virtual nsresult isStripSpaceAllowed(const txXPathNode& aNode,
83 bool& aAllowed) = 0;
85 /**
86 * Returns a pointer to the private context
88 virtual void* getPrivateContext() = 0;
90 virtual txResultRecycler* recycler() = 0;
93 * Callback to be used by the expression/pattern if errors are detected.
95 virtual void receiveError(const nsAString& aMsg, nsresult aRes) = 0;
98 #define TX_DECL_MATCH_CONTEXT \
99 nsresult getVariable(int32_t aNamespace, nsAtom* aLName, \
100 txAExprResult*& aResult) override; \
101 nsresult isStripSpaceAllowed(const txXPathNode& aNode, bool& aAllowed) \
102 override; \
103 void* getPrivateContext() override; \
104 txResultRecycler* recycler() override; \
105 void receiveError(const nsAString& aMsg, nsresult aRes) override
107 class txIEvalContext : public txIMatchContext {
108 public:
110 * Get the context node.
112 virtual const txXPathNode& getContextNode() = 0;
115 * Get the size of the context node set.
117 virtual uint32_t size() = 0;
120 * Get the position of the context node in the context node set,
121 * starting with 1.
123 virtual uint32_t position() = 0;
126 #define TX_DECL_EVAL_CONTEXT \
127 TX_DECL_MATCH_CONTEXT; \
128 const txXPathNode& getContextNode() override; \
129 uint32_t size() override; \
130 uint32_t position() override
132 #endif // __TX_I_XPATH_CONTEXT