michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /** michael@0: * NumberResult michael@0: * Represents the a number as the result of evaluating an Expr michael@0: **/ michael@0: michael@0: #include "mozilla/FloatingPoint.h" michael@0: michael@0: #include "txExprResult.h" michael@0: michael@0: /** michael@0: * Default Constructor michael@0: **/ michael@0: michael@0: /** michael@0: * Creates a new NumberResult with the value of the given double parameter michael@0: * @param dbl the double to use for initialization of this NumberResult's value michael@0: **/ michael@0: NumberResult::NumberResult(double aValue, txResultRecycler* aRecycler) michael@0: : txAExprResult(aRecycler), value(aValue) michael@0: { michael@0: } //-- NumberResult michael@0: michael@0: /* michael@0: * Virtual Methods from ExprResult michael@0: */ michael@0: michael@0: short NumberResult::getResultType() { michael@0: return txAExprResult::NUMBER; michael@0: } //-- getResultType michael@0: michael@0: void michael@0: NumberResult::stringValue(nsString& aResult) michael@0: { michael@0: txDouble::toString(value, aResult); michael@0: } michael@0: michael@0: const nsString* michael@0: NumberResult::stringValuePointer() michael@0: { michael@0: return nullptr; michael@0: } michael@0: michael@0: bool NumberResult::booleanValue() { michael@0: // OG+ michael@0: // As per the XPath spec, the boolean value of a number is true if and only if michael@0: // it is neither positive 0 nor negative 0 nor NaN michael@0: return (bool)(value != 0.0 && !mozilla::IsNaN(value)); michael@0: // OG- michael@0: } //-- booleanValue michael@0: michael@0: double NumberResult::numberValue() { michael@0: return this->value; michael@0: } //-- numberValue michael@0: