Line data Source code
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_XPATH_SINGLENODE_CONTEXT
7 : #define __TX_XPATH_SINGLENODE_CONTEXT
8 :
9 : #include "mozilla/Attributes.h"
10 : #include "txIXPathContext.h"
11 :
12 0 : class txSingleNodeContext : public txIEvalContext
13 : {
14 : public:
15 0 : txSingleNodeContext(const txXPathNode& aContextNode,
16 : txIMatchContext* aContext)
17 0 : : mNode(aContextNode),
18 0 : mInner(aContext)
19 : {
20 0 : NS_ASSERTION(aContext, "txIMatchContext must be given");
21 0 : }
22 :
23 0 : nsresult getVariable(int32_t aNamespace, nsIAtom* aLName,
24 : txAExprResult*& aResult) override
25 : {
26 0 : NS_ASSERTION(mInner, "mInner is null!!!");
27 0 : return mInner->getVariable(aNamespace, aLName, aResult);
28 : }
29 :
30 0 : nsresult isStripSpaceAllowed(const txXPathNode& aNode,
31 : bool& aAllowed) override
32 : {
33 0 : NS_ASSERTION(mInner, "mInner is null!!!");
34 0 : return mInner->isStripSpaceAllowed(aNode, aAllowed);
35 : }
36 :
37 0 : void* getPrivateContext() override
38 : {
39 0 : NS_ASSERTION(mInner, "mInner is null!!!");
40 0 : return mInner->getPrivateContext();
41 : }
42 :
43 0 : txResultRecycler* recycler() override
44 : {
45 0 : NS_ASSERTION(mInner, "mInner is null!!!");
46 0 : return mInner->recycler();
47 : }
48 :
49 0 : void receiveError(const nsAString& aMsg, nsresult aRes) override
50 : {
51 0 : NS_ASSERTION(mInner, "mInner is null!!!");
52 : #ifdef DEBUG
53 0 : nsAutoString error(NS_LITERAL_STRING("forwarded error: "));
54 0 : error.Append(aMsg);
55 0 : mInner->receiveError(error, aRes);
56 : #else
57 : mInner->receiveError(aMsg, aRes);
58 : #endif
59 0 : }
60 :
61 0 : const txXPathNode& getContextNode() override
62 : {
63 0 : return mNode;
64 : }
65 :
66 0 : uint32_t size() override
67 : {
68 0 : return 1;
69 : }
70 :
71 0 : uint32_t position() override
72 : {
73 0 : return 1;
74 : }
75 :
76 : private:
77 : const txXPathNode& mNode;
78 : txIMatchContext* mInner;
79 : };
80 :
81 : #endif // __TX_XPATH_SINGLENODE_CONTEXT
|