dom/xslt/xpath/txNodeSetContext.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/xslt/xpath/txNodeSetContext.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,46 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef __TX_XPATH_SET_CONTEXT
    1.10 +#define __TX_XPATH_SET_CONTEXT
    1.11 +
    1.12 +#include "txIXPathContext.h"
    1.13 +#include "txNodeSet.h"
    1.14 +#include "nsAutoPtr.h"
    1.15 +
    1.16 +class txNodeSetContext : public txIEvalContext
    1.17 +{
    1.18 +public:
    1.19 +    txNodeSetContext(txNodeSet* aContextNodeSet, txIMatchContext* aContext)
    1.20 +        : mContextSet(aContextNodeSet), mPosition(0), mInner(aContext)
    1.21 +    {
    1.22 +    }
    1.23 +
    1.24 +    // Iteration over the given NodeSet
    1.25 +    bool hasNext()
    1.26 +    {
    1.27 +        return mPosition < size();
    1.28 +    }
    1.29 +    void next()
    1.30 +    {
    1.31 +        NS_ASSERTION(mPosition < size(), "Out of bounds.");
    1.32 +        mPosition++;
    1.33 +    }
    1.34 +    void setPosition(uint32_t aPosition)
    1.35 +    {
    1.36 +        NS_ASSERTION(aPosition > 0 &&
    1.37 +                     aPosition <= size(), "Out of bounds.");
    1.38 +        mPosition = aPosition;
    1.39 +    }
    1.40 +
    1.41 +    TX_DECL_EVAL_CONTEXT;
    1.42 +
    1.43 +protected:
    1.44 +    nsRefPtr<txNodeSet> mContextSet;
    1.45 +    uint32_t mPosition;
    1.46 +    txIMatchContext* mInner;
    1.47 +};
    1.48 +
    1.49 +#endif // __TX_XPATH_SET_CONTEXT

mercurial