Bug 1935611 - Fix libyuv/libpng link failed for loongarch64. r=glandium,tnikkel,ng
[gecko.git] / dom / xslt / xpath / txExprResult.h
blob5572b222f54fd61d6acc4df34d77359b7f3e5402
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
9 #include "nsString.h"
10 #include "txCore.h"
11 #include "txResultRecycler.h"
14 * ExprResult
16 * Classes Represented:
17 * BooleanResult, ExprResult, NumberResult, StringResult
19 * Note: for NodeSet, see NodeSet.h
22 class txAExprResult {
23 public:
24 friend class txResultRecycler;
26 // Update txLiteralExpr::getReturnType and sTypes in txEXSLTFunctions.cpp if
27 // this enum is changed.
28 enum ResultType {
29 NODESET = 0,
30 BOOLEAN,
31 NUMBER,
32 STRING,
33 RESULT_TREE_FRAGMENT
36 explicit txAExprResult(txResultRecycler* aRecycler) : mRecycler(aRecycler) {}
37 virtual ~txAExprResult() = default;
39 void AddRef() {
40 ++mRefCnt;
41 NS_LOG_ADDREF(this, mRefCnt, "txAExprResult", sizeof(*this));
44 void Release(); // Implemented in txResultRecycler.cpp
46 /**
47 * Returns the type of ExprResult represented
48 * @return the type of ExprResult represented
49 **/
50 virtual short getResultType() = 0;
52 /**
53 * Creates a String representation of this ExprResult
54 * @param aResult the destination string to append the String
55 * representation to.
56 **/
57 virtual void stringValue(nsString& aResult) = 0;
59 /**
60 * Returns a pointer to the stringvalue if possible. Otherwise null is
61 * returned.
63 virtual const nsString* stringValuePointer() = 0;
65 /**
66 * Converts this ExprResult to a Boolean (bool) value
67 * @return the Boolean value
68 **/
69 virtual bool booleanValue() = 0;
71 /**
72 * Converts this ExprResult to a Number (double) value
73 * @return the Number value
74 **/
75 virtual double numberValue() = 0;
77 private:
78 nsAutoRefCnt mRefCnt;
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 {
90 public:
91 explicit BooleanResult(bool aValue);
93 TX_DECL_EXPRRESULT
95 private:
96 bool value;
99 class NumberResult : public txAExprResult {
100 public:
101 NumberResult(double aValue, txResultRecycler* aRecycler);
103 TX_DECL_EXPRRESULT
105 double value;
108 class StringResult : public txAExprResult {
109 public:
110 explicit StringResult(txResultRecycler* aRecycler);
111 StringResult(const nsAString& aValue, txResultRecycler* aRecycler);
113 TX_DECL_EXPRRESULT
115 nsString mValue;
118 #endif