Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Attributes | Private Attributes
txStepPattern Class Reference

#include <txXSLTPatterns.h>

Inheritance diagram for txStepPattern:
Inheritance graph
[legend]
Collaboration diagram for txStepPattern:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 txStepPattern (txNodeTest *aNodeTest, MBool isAttr)
 ~txStepPattern ()
nsresult add (Expr *aExpr)
 Adds the given Expr to the list.
nsresult evaluatePredicates (txNodeSet *aNodes, txIMatchContext *aContext)
MBool isEmpty ()
 returns true if this predicate list is empty
virtual MBool matches (const txXPathNode &aNode, txIMatchContext *aContext)=0
virtual double getDefaultPriority ()=0
virtual nsresult getSimplePatterns (txList &aList)

Public Attributes

 TX_DECL_PATTERN

Protected Attributes

List predicates

Private Attributes

txNodeTestmNodeTest
MBool mIsAttr

Detailed Description

Definition at line 216 of file txXSLTPatterns.h.


Constructor & Destructor Documentation

txStepPattern::txStepPattern ( txNodeTest aNodeTest,
MBool  isAttr 
) [inline]

Definition at line 219 of file txXSLTPatterns.h.

        :mNodeTest(aNodeTest), mIsAttr(isAttr)
    {
    }

Definition at line 470 of file txXSLTPatterns.cpp.

{
    delete mNodeTest;
}

Member Function Documentation

nsresult PredicateList::add ( Expr aExpr) [inherited]

Adds the given Expr to the list.

The ownership of the given Expr is passed over the PredicateList, even on failure.

Parameters:
aExprthe Expr to add to the list
Returns:
nsresult indicating out of memory

Definition at line 68 of file PredicateList.cpp.

{
    NS_ASSERTION(aExpr, "missing expression");
    nsresult rv = predicates.add(aExpr);
    if (NS_FAILED(rv)) {
        delete aExpr;
    }
    return rv;
} // add

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult PredicateList::evaluatePredicates ( txNodeSet aNodes,
txIMatchContext aContext 
) [inherited]

Definition at line 79 of file PredicateList.cpp.

{
    NS_ASSERTION(nodes, "called evaluatePredicates with NULL NodeSet");
    nsresult rv = NS_OK;

    txListIterator iter(&predicates);
    while (iter.hasNext() && !nodes->isEmpty()) {
        Expr* expr = (Expr*)iter.next();
        txNodeSetContext predContext(nodes, aContext);
        /*
         * add nodes to newNodes that match the expression
         * or, if the result is a number, add the node with the right
         * position
         */
        PRInt32 index = 0;
        while (predContext.hasNext()) {
            predContext.next();
            nsRefPtr<txAExprResult> exprResult;
            rv = expr->evaluate(&predContext, getter_AddRefs(exprResult));
            NS_ENSURE_SUCCESS(rv, rv);

            // handle default, [position() == numberValue()]
            if (exprResult->getResultType() == txAExprResult::NUMBER) {
                if ((double)predContext.position() == exprResult->numberValue()) {
                    nodes->mark(index);
                }
            }
            else if (exprResult->booleanValue()) {
                nodes->mark(index);
            }
            ++index;
        }
        // sweep the non-marked nodes
        nodes->sweep();
    }

    return NS_OK;
}

Here is the call graph for this function:

virtual double txPattern::getDefaultPriority ( ) [pure virtual, inherited]

Here is the caller graph for this function:

nsresult txPattern::getSimplePatterns ( txList aList) [virtual, inherited]

Definition at line 56 of file txXSLTPatterns.cpp.

{
    aList.add(this);
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

MBool PredicateList::isEmpty ( ) [inherited]

returns true if this predicate list is empty

Definition at line 122 of file PredicateList.cpp.

{
    return (MBool)(predicates.getLength() == 0);
} // isEmpty

Here is the call graph for this function:

virtual MBool txPattern::matches ( const txXPathNode aNode,
txIMatchContext aContext 
) [pure virtual, inherited]

Here is the caller graph for this function:


Member Data Documentation

Definition at line 230 of file txXSLTPatterns.h.

Definition at line 229 of file txXSLTPatterns.h.

List PredicateList::predicates [protected, inherited]

Definition at line 356 of file Expr.h.

Definition at line 226 of file txXSLTPatterns.h.


The documentation for this class was generated from the following files: