1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef TRANSFRMX_EXPRRESULT_H
7 #define TRANSFRMX_EXPRRESULT_H
10 #include "nsAutoPtr.h"
12 #include "txResultRecycler.h"
17 * Classes Represented:
18 * BooleanResult, ExprResult, NumberResult, StringResult
20 * Note: for NodeSet, see NodeSet.h
26 friend class txResultRecycler
;
28 // Update txLiteralExpr::getReturnType and sTypes in txEXSLTFunctions.cpp if
29 // this enum is changed.
38 explicit txAExprResult(txResultRecycler
* aRecycler
) : mRecycler(aRecycler
)
41 virtual ~txAExprResult()
48 NS_LOG_ADDREF(this, mRefCnt
, "txAExprResult", sizeof(*this));
51 void Release(); // Implemented in txResultRecycler.cpp
54 * Returns the type of ExprResult represented
55 * @return the type of ExprResult represented
57 virtual short getResultType() = 0;
60 * Creates a String representation of this ExprResult
61 * @param aResult the destination string to append the String
64 virtual void stringValue(nsString
& aResult
) = 0;
67 * Returns a pointer to the stringvalue if possible. Otherwise null is
70 virtual const nsString
* stringValuePointer() = 0;
73 * Converts this ExprResult to a Boolean (bool) value
74 * @return the Boolean value
76 virtual bool booleanValue() = 0;
79 * Converts this ExprResult to a Number (double) value
80 * @return the Number value
82 virtual double numberValue() = 0;
86 nsRefPtr
<txResultRecycler
> mRecycler
;
89 #define TX_DECL_EXPRRESULT \
90 virtual short getResultType(); \
91 virtual void stringValue(nsString& aString); \
92 virtual const nsString* stringValuePointer(); \
93 virtual bool booleanValue(); \
94 virtual double numberValue(); \
97 class BooleanResult : public txAExprResult {
100 explicit BooleanResult(bool aValue
);
108 class NumberResult
: public txAExprResult
{
111 NumberResult(double aValue
, txResultRecycler
* aRecycler
);
120 class StringResult
: public txAExprResult
{
122 explicit StringResult(txResultRecycler
* aRecycler
);
123 StringResult(const nsAString
& aValue
, txResultRecycler
* aRecycler
);