2005-11-02 10:42:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2005-11-02 10:34:13 +03:00
|
|
|
|
2005-11-02 10:35:52 +03:00
|
|
|
#ifndef TRANSFRMX_EXPRRESULT_H
|
|
|
|
#define TRANSFRMX_EXPRRESULT_H
|
2005-11-02 10:34:13 +03:00
|
|
|
|
2005-11-02 10:39:22 +03:00
|
|
|
#include "nsString.h"
|
2005-11-02 10:40:48 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2005-11-02 10:42:16 +03:00
|
|
|
#include "txCore.h"
|
|
|
|
#include "txResultRecycler.h"
|
2005-11-02 10:34:13 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ExprResult
|
2005-11-02 10:36:47 +03:00
|
|
|
*
|
2005-11-02 10:34:13 +03:00
|
|
|
* Classes Represented:
|
|
|
|
* BooleanResult, ExprResult, NumberResult, StringResult
|
2005-11-02 10:36:47 +03:00
|
|
|
*
|
|
|
|
* Note: for NodeSet, see NodeSet.h
|
2005-11-02 10:34:13 +03:00
|
|
|
*/
|
|
|
|
|
2006-12-12 04:59:30 +03:00
|
|
|
class txAExprResult
|
2005-11-02 10:40:48 +03:00
|
|
|
{
|
2005-11-02 10:34:13 +03:00
|
|
|
public:
|
2005-11-02 10:40:48 +03:00
|
|
|
friend class txResultRecycler;
|
2006-01-26 04:50:30 +03:00
|
|
|
|
2006-11-17 00:42:25 +03:00
|
|
|
// Update txLiteralExpr::getReturnType and sTypes in txEXSLTFunctions.cpp if
|
|
|
|
// this enum is changed.
|
2005-11-02 10:34:42 +03:00
|
|
|
enum ResultType {
|
2006-01-26 04:50:30 +03:00
|
|
|
NODESET = 0,
|
2005-11-02 10:40:06 +03:00
|
|
|
BOOLEAN,
|
2005-11-02 10:37:24 +03:00
|
|
|
NUMBER,
|
2005-11-02 10:34:13 +03:00
|
|
|
STRING,
|
2005-11-02 10:40:06 +03:00
|
|
|
RESULT_TREE_FRAGMENT
|
2005-11-02 10:34:13 +03:00
|
|
|
};
|
|
|
|
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit txAExprResult(txResultRecycler* aRecycler) : mRecycler(aRecycler)
|
2006-04-01 06:12:15 +04:00
|
|
|
{
|
|
|
|
}
|
2007-09-01 21:47:39 +04:00
|
|
|
virtual ~txAExprResult()
|
|
|
|
{
|
|
|
|
}
|
2005-11-02 10:40:48 +03:00
|
|
|
|
|
|
|
void AddRef()
|
|
|
|
{
|
|
|
|
++mRefCnt;
|
2007-09-01 21:47:39 +04:00
|
|
|
NS_LOG_ADDREF(this, mRefCnt, "txAExprResult", sizeof(*this));
|
2005-11-02 10:40:48 +03:00
|
|
|
}
|
2005-11-02 10:41:05 +03:00
|
|
|
|
|
|
|
void Release(); // Implemented in txResultRecycler.cpp
|
Landing TX_BRIDGE_1_1_BRANCH.
Rewrite pretty much all variable and parameter handling. Makes global and local variables be handled differently. Global variables are no longer part of the variables stack, and are lazily evaluated. Fixes bugs 117658, 92929 and some unfiled bugs and fixes remaining parts of bugs 83651 and 96802. Patch by sicking, r=Pike sr=bz.
Fix for bug 156464: fix rounding problems in module, allow patterns without any '0's in the integer part and fix problems with grouping for standalone. Patch by sicking, r=Pike sr=bz.
Fix for bug 157340 (Probable bugs in extensions/transformiix/source/base/txMozillaString.h). Patch by peterv, r=Pike, sr=bz.
Fix for bug 146967 (Clean up Transformiix strings). Patch by peterv, r=sicking, sr=jst.
Fix for bug 156464 (Remove static strings from Transformiix). Patch by peterv, r=Pike, sr=jst.
2005-11-02 10:38:17 +03:00
|
|
|
|
2005-11-02 10:34:13 +03:00
|
|
|
/**
|
|
|
|
* Returns the type of ExprResult represented
|
|
|
|
* @return the type of ExprResult represented
|
|
|
|
**/
|
|
|
|
virtual short getResultType() = 0;
|
2005-11-02 10:35:44 +03:00
|
|
|
|
2005-11-02 10:34:13 +03:00
|
|
|
/**
|
|
|
|
* Creates a String representation of this ExprResult
|
2006-04-01 06:12:15 +04:00
|
|
|
* @param aResult the destination string to append the String
|
|
|
|
* representation to.
|
2005-11-02 10:34:13 +03:00
|
|
|
**/
|
2006-04-01 06:12:15 +04:00
|
|
|
virtual void stringValue(nsString& aResult) = 0;
|
2005-11-02 10:34:13 +03:00
|
|
|
|
2005-11-02 10:40:21 +03:00
|
|
|
/**
|
|
|
|
* Returns a pointer to the stringvalue if possible. Otherwise null is
|
|
|
|
* returned.
|
|
|
|
*/
|
2006-04-01 06:12:15 +04:00
|
|
|
virtual const nsString* stringValuePointer() = 0;
|
2005-11-02 10:40:21 +03:00
|
|
|
|
2005-11-02 10:34:13 +03:00
|
|
|
/**
|
2011-11-10 23:26:13 +04:00
|
|
|
* Converts this ExprResult to a Boolean (bool) value
|
2005-11-02 10:34:13 +03:00
|
|
|
* @return the Boolean value
|
|
|
|
**/
|
2011-11-10 23:26:13 +04:00
|
|
|
virtual bool booleanValue() = 0;
|
2005-11-02 10:34:13 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts this ExprResult to a Number (double) value
|
|
|
|
* @return the Number value
|
|
|
|
**/
|
|
|
|
virtual double numberValue() = 0;
|
|
|
|
|
2005-11-02 10:40:48 +03:00
|
|
|
private:
|
|
|
|
nsAutoRefCnt mRefCnt;
|
|
|
|
nsRefPtr<txResultRecycler> mRecycler;
|
2005-11-02 10:34:13 +03:00
|
|
|
};
|
|
|
|
|
2005-11-02 10:40:21 +03:00
|
|
|
#define TX_DECL_EXPRRESULT \
|
|
|
|
virtual short getResultType(); \
|
2006-04-01 06:12:15 +04:00
|
|
|
virtual void stringValue(nsString& aString); \
|
|
|
|
virtual const nsString* stringValuePointer(); \
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool booleanValue(); \
|
2005-11-02 10:40:21 +03:00
|
|
|
virtual double numberValue(); \
|
|
|
|
|
|
|
|
|
2005-11-02 10:40:48 +03:00
|
|
|
class BooleanResult : public txAExprResult {
|
2005-11-02 10:34:13 +03:00
|
|
|
|
|
|
|
public:
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit BooleanResult(bool aValue);
|
2005-11-02 10:34:13 +03:00
|
|
|
|
2005-11-02 10:40:21 +03:00
|
|
|
TX_DECL_EXPRRESULT
|
2005-11-02 10:34:13 +03:00
|
|
|
|
|
|
|
private:
|
2011-11-10 23:26:13 +04:00
|
|
|
bool value;
|
2005-11-02 10:34:13 +03:00
|
|
|
};
|
|
|
|
|
2005-11-02 10:40:48 +03:00
|
|
|
class NumberResult : public txAExprResult {
|
2005-11-02 10:34:13 +03:00
|
|
|
|
|
|
|
public:
|
2005-11-02 10:40:48 +03:00
|
|
|
NumberResult(double aValue, txResultRecycler* aRecycler);
|
2005-11-02 10:34:13 +03:00
|
|
|
|
2005-11-02 10:40:21 +03:00
|
|
|
TX_DECL_EXPRRESULT
|
2005-11-02 10:34:13 +03:00
|
|
|
|
|
|
|
double value;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-11-02 10:40:48 +03:00
|
|
|
class StringResult : public txAExprResult {
|
2005-11-02 10:34:13 +03:00
|
|
|
public:
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit StringResult(txResultRecycler* aRecycler);
|
2005-11-02 10:40:48 +03:00
|
|
|
StringResult(const nsAString& aValue, txResultRecycler* aRecycler);
|
2005-11-02 10:34:13 +03:00
|
|
|
|
2005-11-02 10:40:21 +03:00
|
|
|
TX_DECL_EXPRRESULT
|
2005-11-02 10:34:13 +03:00
|
|
|
|
2005-11-02 10:39:22 +03:00
|
|
|
nsString mValue;
|
2005-11-02 10:34:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|