1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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
11 #include "txResultRecycler.h"
16 * Classes Represented:
17 * BooleanResult, ExprResult, NumberResult, StringResult
19 * Note: for NodeSet, see NodeSet.h
24 friend class txResultRecycler
;
26 // Update txLiteralExpr::getReturnType and sTypes in txEXSLTFunctions.cpp if
27 // this enum is changed.
36 explicit txAExprResult(txResultRecycler
* aRecycler
) : mRecycler(aRecycler
) {}
37 virtual ~txAExprResult() = default;
41 NS_LOG_ADDREF(this, mRefCnt
, "txAExprResult", sizeof(*this));
44 void Release(); // Implemented in txResultRecycler.cpp
47 * Returns the type of ExprResult represented
48 * @return the type of ExprResult represented
50 virtual short getResultType() = 0;
53 * Creates a String representation of this ExprResult
54 * @param aResult the destination string to append the String
57 virtual void stringValue(nsString
& aResult
) = 0;
60 * Returns a pointer to the stringvalue if possible. Otherwise null is
63 virtual const nsString
* stringValuePointer() = 0;
66 * Converts this ExprResult to a Boolean (bool) value
67 * @return the Boolean value
69 virtual bool booleanValue() = 0;
72 * Converts this ExprResult to a Number (double) value
73 * @return the Number value
75 virtual double numberValue() = 0;
79 RefPtr
<txResultRecycler
> mRecycler
;
82 #define TX_DECL_EXPRRESULT \
83 virtual short getResultType() override; \
84 virtual void stringValue(nsString& aString) override; \
85 virtual const nsString* stringValuePointer() override; \
86 virtual bool booleanValue() override; \
87 virtual double numberValue() override;
89 class BooleanResult
: public txAExprResult
{
91 explicit BooleanResult(bool aValue
);
99 class NumberResult
: public txAExprResult
{
101 NumberResult(double aValue
, txResultRecycler
* aRecycler
);
108 class StringResult
: public txAExprResult
{
110 explicit StringResult(txResultRecycler
* aRecycler
);
111 StringResult(const nsAString
& aValue
, txResultRecycler
* aRecycler
);