2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef TRANSFRMX_EXPRRESULT_H
|
|
|
|
#define TRANSFRMX_EXPRRESULT_H
|
|
|
|
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "txCore.h"
|
|
|
|
#include "txResultRecycler.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ExprResult
|
|
|
|
*
|
|
|
|
* Classes Represented:
|
|
|
|
* BooleanResult, ExprResult, NumberResult, StringResult
|
|
|
|
*
|
|
|
|
* Note: for NodeSet, see NodeSet.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
class txAExprResult
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
friend class txResultRecycler;
|
|
|
|
|
|
|
|
// Update txLiteralExpr::getReturnType and sTypes in txEXSLTFunctions.cpp if
|
|
|
|
// this enum is changed.
|
|
|
|
enum ResultType {
|
|
|
|
NODESET = 0,
|
|
|
|
BOOLEAN,
|
|
|
|
NUMBER,
|
|
|
|
STRING,
|
|
|
|
RESULT_TREE_FRAGMENT
|
|
|
|
};
|
|
|
|
|
|
|
|
txAExprResult(txResultRecycler* aRecycler) : mRecycler(aRecycler)
|
|
|
|
{
|
|
|
|
}
|
2007-09-01 10:47:39 -07:00
|
|
|
virtual ~txAExprResult()
|
|
|
|
{
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void AddRef()
|
|
|
|
{
|
|
|
|
++mRefCnt;
|
2007-09-01 10:47:39 -07:00
|
|
|
NS_LOG_ADDREF(this, mRefCnt, "txAExprResult", sizeof(*this));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void Release(); // Implemented in txResultRecycler.cpp
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the type of ExprResult represented
|
|
|
|
* @return the type of ExprResult represented
|
|
|
|
**/
|
|
|
|
virtual short getResultType() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a String representation of this ExprResult
|
|
|
|
* @param aResult the destination string to append the String
|
|
|
|
* representation to.
|
|
|
|
**/
|
|
|
|
virtual void stringValue(nsString& aResult) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a pointer to the stringvalue if possible. Otherwise null is
|
|
|
|
* returned.
|
|
|
|
*/
|
|
|
|
virtual const nsString* stringValuePointer() = 0;
|
|
|
|
|
|
|
|
/**
|
2011-11-10 11:26:13 -08:00
|
|
|
* Converts this ExprResult to a Boolean (bool) value
|
2007-03-22 10:30:00 -07:00
|
|
|
* @return the Boolean value
|
|
|
|
**/
|
2011-11-10 11:26:13 -08:00
|
|
|
virtual bool booleanValue() = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts this ExprResult to a Number (double) value
|
|
|
|
* @return the Number value
|
|
|
|
**/
|
|
|
|
virtual double numberValue() = 0;
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsAutoRefCnt mRefCnt;
|
|
|
|
nsRefPtr<txResultRecycler> mRecycler;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define TX_DECL_EXPRRESULT \
|
|
|
|
virtual short getResultType(); \
|
|
|
|
virtual void stringValue(nsString& aString); \
|
|
|
|
virtual const nsString* stringValuePointer(); \
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool booleanValue(); \
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual double numberValue(); \
|
|
|
|
|
|
|
|
|
|
|
|
class BooleanResult : public txAExprResult {
|
|
|
|
|
|
|
|
public:
|
2011-11-10 11:26:13 -08:00
|
|
|
BooleanResult(bool aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
TX_DECL_EXPRRESULT
|
|
|
|
|
|
|
|
private:
|
2011-11-10 11:26:13 -08:00
|
|
|
bool value;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class NumberResult : public txAExprResult {
|
|
|
|
|
|
|
|
public:
|
|
|
|
NumberResult(double aValue, txResultRecycler* aRecycler);
|
|
|
|
|
|
|
|
TX_DECL_EXPRRESULT
|
|
|
|
|
|
|
|
double value;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class StringResult : public txAExprResult {
|
|
|
|
public:
|
|
|
|
StringResult(txResultRecycler* aRecycler);
|
|
|
|
StringResult(const nsAString& aValue, txResultRecycler* aRecycler);
|
|
|
|
|
|
|
|
TX_DECL_EXPRRESULT
|
|
|
|
|
|
|
|
nsString mValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|