Bumping manifests a=b2g-bump
[gecko.git] / dom / xslt / xpath / txExprResult.h
blob04cf5e4d2df536ecfb6e6ead9a2757101abfd9f7
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
9 #include "nsString.h"
10 #include "nsAutoPtr.h"
11 #include "txCore.h"
12 #include "txResultRecycler.h"
15 * ExprResult
17 * Classes Represented:
18 * BooleanResult, ExprResult, NumberResult, StringResult
20 * Note: for NodeSet, see NodeSet.h
23 class txAExprResult
25 public:
26 friend class txResultRecycler;
28 // Update txLiteralExpr::getReturnType and sTypes in txEXSLTFunctions.cpp if
29 // this enum is changed.
30 enum ResultType {
31 NODESET = 0,
32 BOOLEAN,
33 NUMBER,
34 STRING,
35 RESULT_TREE_FRAGMENT
38 explicit txAExprResult(txResultRecycler* aRecycler) : mRecycler(aRecycler)
41 virtual ~txAExprResult()
45 void AddRef()
47 ++mRefCnt;
48 NS_LOG_ADDREF(this, mRefCnt, "txAExprResult", sizeof(*this));
51 void Release(); // Implemented in txResultRecycler.cpp
53 /**
54 * Returns the type of ExprResult represented
55 * @return the type of ExprResult represented
56 **/
57 virtual short getResultType() = 0;
59 /**
60 * Creates a String representation of this ExprResult
61 * @param aResult the destination string to append the String
62 * representation to.
63 **/
64 virtual void stringValue(nsString& aResult) = 0;
66 /**
67 * Returns a pointer to the stringvalue if possible. Otherwise null is
68 * returned.
70 virtual const nsString* stringValuePointer() = 0;
72 /**
73 * Converts this ExprResult to a Boolean (bool) value
74 * @return the Boolean value
75 **/
76 virtual bool booleanValue() = 0;
78 /**
79 * Converts this ExprResult to a Number (double) value
80 * @return the Number value
81 **/
82 virtual double numberValue() = 0;
84 private:
85 nsAutoRefCnt mRefCnt;
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 {
99 public:
100 explicit BooleanResult(bool aValue);
102 TX_DECL_EXPRRESULT
104 private:
105 bool value;
108 class NumberResult : public txAExprResult {
110 public:
111 NumberResult(double aValue, txResultRecycler* aRecycler);
113 TX_DECL_EXPRRESULT
115 double value;
120 class StringResult : public txAExprResult {
121 public:
122 explicit StringResult(txResultRecycler* aRecycler);
123 StringResult(const nsAString& aValue, txResultRecycler* aRecycler);
125 TX_DECL_EXPRRESULT
127 nsString mValue;
130 #endif