michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef __TX_XPATH_SINGLENODE_CONTEXT michael@0: #define __TX_XPATH_SINGLENODE_CONTEXT michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "txIXPathContext.h" michael@0: michael@0: class txSingleNodeContext : public txIEvalContext michael@0: { michael@0: public: michael@0: txSingleNodeContext(const txXPathNode& aContextNode, michael@0: txIMatchContext* aContext) michael@0: : mNode(aContextNode), michael@0: mInner(aContext) michael@0: { michael@0: NS_ASSERTION(aContext, "txIMatchContext must be given"); michael@0: } michael@0: michael@0: nsresult getVariable(int32_t aNamespace, nsIAtom* aLName, michael@0: txAExprResult*& aResult) MOZ_OVERRIDE michael@0: { michael@0: NS_ASSERTION(mInner, "mInner is null!!!"); michael@0: return mInner->getVariable(aNamespace, aLName, aResult); michael@0: } michael@0: michael@0: bool isStripSpaceAllowed(const txXPathNode& aNode) MOZ_OVERRIDE michael@0: { michael@0: NS_ASSERTION(mInner, "mInner is null!!!"); michael@0: return mInner->isStripSpaceAllowed(aNode); michael@0: } michael@0: michael@0: void* getPrivateContext() MOZ_OVERRIDE michael@0: { michael@0: NS_ASSERTION(mInner, "mInner is null!!!"); michael@0: return mInner->getPrivateContext(); michael@0: } michael@0: michael@0: txResultRecycler* recycler() MOZ_OVERRIDE michael@0: { michael@0: NS_ASSERTION(mInner, "mInner is null!!!"); michael@0: return mInner->recycler(); michael@0: } michael@0: michael@0: void receiveError(const nsAString& aMsg, nsresult aRes) MOZ_OVERRIDE michael@0: { michael@0: NS_ASSERTION(mInner, "mInner is null!!!"); michael@0: #ifdef DEBUG michael@0: nsAutoString error(NS_LITERAL_STRING("forwarded error: ")); michael@0: error.Append(aMsg); michael@0: mInner->receiveError(error, aRes); michael@0: #else michael@0: mInner->receiveError(aMsg, aRes); michael@0: #endif michael@0: } michael@0: michael@0: const txXPathNode& getContextNode() MOZ_OVERRIDE michael@0: { michael@0: return mNode; michael@0: } michael@0: michael@0: uint32_t size() MOZ_OVERRIDE michael@0: { michael@0: return 1; michael@0: } michael@0: michael@0: uint32_t position() MOZ_OVERRIDE michael@0: { michael@0: return 1; michael@0: } michael@0: michael@0: private: michael@0: const txXPathNode& mNode; michael@0: txIMatchContext* mInner; michael@0: }; michael@0: michael@0: #endif // __TX_XPATH_SINGLENODE_CONTEXT