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_SET_CONTEXT michael@0: #define __TX_XPATH_SET_CONTEXT michael@0: michael@0: #include "txIXPathContext.h" michael@0: #include "txNodeSet.h" michael@0: #include "nsAutoPtr.h" michael@0: michael@0: class txNodeSetContext : public txIEvalContext michael@0: { michael@0: public: michael@0: txNodeSetContext(txNodeSet* aContextNodeSet, txIMatchContext* aContext) michael@0: : mContextSet(aContextNodeSet), mPosition(0), mInner(aContext) michael@0: { michael@0: } michael@0: michael@0: // Iteration over the given NodeSet michael@0: bool hasNext() michael@0: { michael@0: return mPosition < size(); michael@0: } michael@0: void next() michael@0: { michael@0: NS_ASSERTION(mPosition < size(), "Out of bounds."); michael@0: mPosition++; michael@0: } michael@0: void setPosition(uint32_t aPosition) michael@0: { michael@0: NS_ASSERTION(aPosition > 0 && michael@0: aPosition <= size(), "Out of bounds."); michael@0: mPosition = aPosition; michael@0: } michael@0: michael@0: TX_DECL_EVAL_CONTEXT; michael@0: michael@0: protected: michael@0: nsRefPtr mContextSet; michael@0: uint32_t mPosition; michael@0: txIMatchContext* mInner; michael@0: }; michael@0: michael@0: #endif // __TX_XPATH_SET_CONTEXT