Back to index

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

The following are definitions for the XPath functions. More...

#include <FunctionLib.h>

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

List of all members.

Public Types

enum  BooleanFunctions {
  TX_BOOLEAN, TX_FALSE, TX_LANG, TX_NOT,
  TX_TRUE
}

Public Member Functions

 BooleanFunctionCall (BooleanFunctions aType)
 Creates a BooleanFunctionCall of the given type.
nsresult addParam (Expr *aExpr)
 Adds the given parameter to this FunctionCall's parameter list.
virtual PRBool requireParams (PRInt32 aParamCountMin, PRInt32 aParamCountMax, txIEvalContext *aContext)
 Check if the number of parameters falls within a range.
virtual nsresult evaluate (txIEvalContext *aContext, txAExprResult **aResult)=0
 Evaluates this Expr based on the given context node and processor state.

Public Attributes

 TX_DECL_FUNCTION
u8 op
char affinity
u8 flags
CollSeqpColl
ExprpLeft
ExprpRight
ExprListpList
Token token
Token span
int iTable
int iColumn
AggInfopAggInfo
int iAgg
int iRightJoinTable
SelectpSelect
TablepTab
SchemapSchema

Protected Member Functions

void evaluateToString (Expr *aExpr, txIEvalContext *aContext, nsAString &aDest)
double evaluateToNumber (Expr *aExpr, txIEvalContext *aContext)
MBool evaluateToBoolean (Expr *aExpr, txIEvalContext *aContext)
nsresult evaluateToNodeSet (Expr *aExpr, txIEvalContext *aContext, txNodeSet **aResult)

Protected Attributes

txList params

Private Attributes

BooleanFunctions mType

Detailed Description

The following are definitions for the XPath functions.

 Modifications:
 20000418: Keith Visco
   -- added ExtensionFunctionCall
19990805: Keith Visco

Definition at line 70 of file FunctionLib.h.


Member Enumeration Documentation

Enumerator:
TX_BOOLEAN 
TX_FALSE 
TX_LANG 
TX_NOT 
TX_TRUE 

Definition at line 74 of file FunctionLib.h.

                          {
        TX_BOOLEAN,  // boolean()
        TX_FALSE,    // false()
        TX_LANG,     // lang()
        TX_NOT,      // not()
        TX_TRUE      // true()
    };

Constructor & Destructor Documentation

Creates a BooleanFunctionCall of the given type.

Creates a default BooleanFunctionCall, which always evaluates to False.

Definition at line 51 of file BooleanFunctionCall.cpp.

    : mType(aType)
{
}

Member Function Documentation

nsresult FunctionCall::addParam ( Expr aExpr) [inherited]

Adds the given parameter to this FunctionCall's parameter list.

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

Parameters:
aExprthe Expr to add to this FunctionCall's parameter list
Returns:
nsresult indicating out of memory
Parameters:
exprthe Expr to add to this FunctionCall's parameter list

Definition at line 73 of file FunctionCall.cpp.

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

Here is the call graph for this function:

Here is the caller graph for this function:

virtual nsresult Expr::evaluate ( txIEvalContext aContext,
txAExprResult **  aResult 
) [pure virtual, inherited]

Evaluates this Expr based on the given context node and processor state.

Parameters:
contextthe context node for evaluation of this Expr
psthe ContextState containing the stack information needed for evaluation
Returns:
the result of the evaluation

Here is the caller graph for this function:

MBool FunctionCall::evaluateToBoolean ( Expr aExpr,
txIEvalContext aContext 
) [protected, inherited]

Definition at line 116 of file FunctionCall.cpp.

{
    NS_ASSERTION(aExpr, "missing expression");
    nsRefPtr<txAExprResult> exprResult;
    nsresult rv = aExpr->evaluate(aContext, getter_AddRefs(exprResult));
    if (NS_FAILED(rv))
        return PR_FALSE;

    return exprResult->booleanValue();
}

Here is the call graph for this function:

nsresult FunctionCall::evaluateToNodeSet ( Expr aExpr,
txIEvalContext aContext,
txNodeSet **  aResult 
) [protected, inherited]

Definition at line 132 of file FunctionCall.cpp.

{
    NS_ASSERTION(aExpr, "Missing expression to evaluate");
    *aResult = nsnull;

    nsRefPtr<txAExprResult> exprRes;
    nsresult rv = aExpr->evaluate(aContext, getter_AddRefs(exprRes));
    NS_ENSURE_SUCCESS(rv, rv);

    if (exprRes->getResultType() != txAExprResult::NODESET) {
        aContext->receiveError(NS_LITERAL_STRING("NodeSet expected as argument"), NS_ERROR_XSLT_NODESET_EXPECTED);
        return NS_ERROR_XSLT_NODESET_EXPECTED;
    }

    *aResult =
        NS_STATIC_CAST(txNodeSet*, NS_STATIC_CAST(txAExprResult*, exprRes));
    NS_ADDREF(*aResult);

    return NS_OK;
}

Here is the call graph for this function:

double FunctionCall::evaluateToNumber ( Expr aExpr,
txIEvalContext aContext 
) [protected, inherited]

Definition at line 102 of file FunctionCall.cpp.

{
    NS_ASSERTION(aExpr, "missing expression");
    nsRefPtr<txAExprResult> exprResult;
    nsresult rv = aExpr->evaluate(aContext, getter_AddRefs(exprResult));
    if (NS_FAILED(rv))
        return Double::NaN;

    return exprResult->numberValue();
}

Here is the call graph for this function:

void FunctionCall::evaluateToString ( Expr aExpr,
txIEvalContext aContext,
nsAString &  aDest 
) [protected, inherited]

Definition at line 87 of file FunctionCall.cpp.

{
    NS_ASSERTION(aExpr, "missing expression");
    nsRefPtr<txAExprResult> exprResult;
    nsresult rv = aExpr->evaluate(aContext, getter_AddRefs(exprResult));
    if (NS_FAILED(rv))
        return;

    exprResult->stringValue(aDest);
}

Here is the call graph for this function:

PRBool FunctionCall::requireParams ( PRInt32  aParamCountMin,
PRInt32  aParamCountMax,
txIEvalContext aContext 
) [virtual, inherited]

Check if the number of parameters falls within a range.

Parameters:
aParamCountMinminimum number of required parameters.
aParamCountMaxmaximum number of parameters. If aParamCountMax is negative the maximum number is not checked.
Returns:
boolean representing whether the number of parameters falls within the expected range or not.

XXX txIEvalContext should be txIParseContest, bug 143291

Definition at line 154 of file FunctionCall.cpp.

{
    PRInt32 argc = params.getLength();
    if (argc < aParamCountMin ||
        (aParamCountMax > -1 && argc > aParamCountMax)) {
        nsAutoString err(NS_LITERAL_STRING("invalid number of parameters for function"));
#ifdef TX_TO_STRING
        err.AppendLiteral(": ");
        toString(err);
#endif
        aContext->receiveError(err, NS_ERROR_XPATH_INVALID_ARG);

        return PR_FALSE;
    }

    return PR_TRUE;
}

Here is the call graph for this function:


Member Data Documentation

char Expr::affinity [inherited]

Definition at line 951 of file sqliteInt.h.

u8 Expr::flags [inherited]

Definition at line 952 of file sqliteInt.h.

int Expr::iAgg [inherited]

Definition at line 962 of file sqliteInt.h.

int Expr::iColumn [inherited]

Definition at line 959 of file sqliteInt.h.

Definition at line 963 of file sqliteInt.h.

int Expr::iTable [inherited]

Definition at line 959 of file sqliteInt.h.

Definition at line 90 of file FunctionLib.h.

u8 Expr::op [inherited]

Reimplemented in MultiplicativeExpr, BooleanExpr, and AdditiveExpr.

Definition at line 950 of file sqliteInt.h.

AggInfo* Expr::pAggInfo [inherited]

Definition at line 961 of file sqliteInt.h.

txList FunctionCall::params [protected, inherited]

Definition at line 158 of file Expr.h.

CollSeq* Expr::pColl [inherited]

Definition at line 953 of file sqliteInt.h.

Expr* Expr::pLeft [inherited]

Definition at line 954 of file sqliteInt.h.

ExprList* Expr::pList [inherited]

Definition at line 955 of file sqliteInt.h.

Expr * Expr::pRight [inherited]

Definition at line 954 of file sqliteInt.h.

Schema* Expr::pSchema [inherited]

Definition at line 967 of file sqliteInt.h.

Select* Expr::pSelect [inherited]

Definition at line 964 of file sqliteInt.h.

Table* Expr::pTab [inherited]

Definition at line 966 of file sqliteInt.h.

Token Expr::span [inherited]

Definition at line 958 of file sqliteInt.h.

Token Expr::token [inherited]

Definition at line 957 of file sqliteInt.h.

Definition at line 87 of file FunctionLib.h.


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