dom/xslt/xpath/txExprResult.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef TRANSFRMX_EXPRRESULT_H
michael@0 7 #define TRANSFRMX_EXPRRESULT_H
michael@0 8
michael@0 9 #include "nsString.h"
michael@0 10 #include "nsAutoPtr.h"
michael@0 11 #include "txCore.h"
michael@0 12 #include "txResultRecycler.h"
michael@0 13
michael@0 14 /*
michael@0 15 * ExprResult
michael@0 16 *
michael@0 17 * Classes Represented:
michael@0 18 * BooleanResult, ExprResult, NumberResult, StringResult
michael@0 19 *
michael@0 20 * Note: for NodeSet, see NodeSet.h
michael@0 21 */
michael@0 22
michael@0 23 class txAExprResult
michael@0 24 {
michael@0 25 public:
michael@0 26 friend class txResultRecycler;
michael@0 27
michael@0 28 // Update txLiteralExpr::getReturnType and sTypes in txEXSLTFunctions.cpp if
michael@0 29 // this enum is changed.
michael@0 30 enum ResultType {
michael@0 31 NODESET = 0,
michael@0 32 BOOLEAN,
michael@0 33 NUMBER,
michael@0 34 STRING,
michael@0 35 RESULT_TREE_FRAGMENT
michael@0 36 };
michael@0 37
michael@0 38 txAExprResult(txResultRecycler* aRecycler) : mRecycler(aRecycler)
michael@0 39 {
michael@0 40 }
michael@0 41 virtual ~txAExprResult()
michael@0 42 {
michael@0 43 }
michael@0 44
michael@0 45 void AddRef()
michael@0 46 {
michael@0 47 ++mRefCnt;
michael@0 48 NS_LOG_ADDREF(this, mRefCnt, "txAExprResult", sizeof(*this));
michael@0 49 }
michael@0 50
michael@0 51 void Release(); // Implemented in txResultRecycler.cpp
michael@0 52
michael@0 53 /**
michael@0 54 * Returns the type of ExprResult represented
michael@0 55 * @return the type of ExprResult represented
michael@0 56 **/
michael@0 57 virtual short getResultType() = 0;
michael@0 58
michael@0 59 /**
michael@0 60 * Creates a String representation of this ExprResult
michael@0 61 * @param aResult the destination string to append the String
michael@0 62 * representation to.
michael@0 63 **/
michael@0 64 virtual void stringValue(nsString& aResult) = 0;
michael@0 65
michael@0 66 /**
michael@0 67 * Returns a pointer to the stringvalue if possible. Otherwise null is
michael@0 68 * returned.
michael@0 69 */
michael@0 70 virtual const nsString* stringValuePointer() = 0;
michael@0 71
michael@0 72 /**
michael@0 73 * Converts this ExprResult to a Boolean (bool) value
michael@0 74 * @return the Boolean value
michael@0 75 **/
michael@0 76 virtual bool booleanValue() = 0;
michael@0 77
michael@0 78 /**
michael@0 79 * Converts this ExprResult to a Number (double) value
michael@0 80 * @return the Number value
michael@0 81 **/
michael@0 82 virtual double numberValue() = 0;
michael@0 83
michael@0 84 private:
michael@0 85 nsAutoRefCnt mRefCnt;
michael@0 86 nsRefPtr<txResultRecycler> mRecycler;
michael@0 87 };
michael@0 88
michael@0 89 #define TX_DECL_EXPRRESULT \
michael@0 90 virtual short getResultType(); \
michael@0 91 virtual void stringValue(nsString& aString); \
michael@0 92 virtual const nsString* stringValuePointer(); \
michael@0 93 virtual bool booleanValue(); \
michael@0 94 virtual double numberValue(); \
michael@0 95
michael@0 96
michael@0 97 class BooleanResult : public txAExprResult {
michael@0 98
michael@0 99 public:
michael@0 100 BooleanResult(bool aValue);
michael@0 101
michael@0 102 TX_DECL_EXPRRESULT
michael@0 103
michael@0 104 private:
michael@0 105 bool value;
michael@0 106 };
michael@0 107
michael@0 108 class NumberResult : public txAExprResult {
michael@0 109
michael@0 110 public:
michael@0 111 NumberResult(double aValue, txResultRecycler* aRecycler);
michael@0 112
michael@0 113 TX_DECL_EXPRRESULT
michael@0 114
michael@0 115 double value;
michael@0 116
michael@0 117 };
michael@0 118
michael@0 119
michael@0 120 class StringResult : public txAExprResult {
michael@0 121 public:
michael@0 122 StringResult(txResultRecycler* aRecycler);
michael@0 123 StringResult(const nsAString& aValue, txResultRecycler* aRecycler);
michael@0 124
michael@0 125 TX_DECL_EXPRRESULT
michael@0 126
michael@0 127 nsString mValue;
michael@0 128 };
michael@0 129
michael@0 130 #endif
michael@0 131

mercurial