dom/xslt/xpath/txNumberResult.cpp

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 /**
michael@0 7 * NumberResult
michael@0 8 * Represents the a number as the result of evaluating an Expr
michael@0 9 **/
michael@0 10
michael@0 11 #include "mozilla/FloatingPoint.h"
michael@0 12
michael@0 13 #include "txExprResult.h"
michael@0 14
michael@0 15 /**
michael@0 16 * Default Constructor
michael@0 17 **/
michael@0 18
michael@0 19 /**
michael@0 20 * Creates a new NumberResult with the value of the given double parameter
michael@0 21 * @param dbl the double to use for initialization of this NumberResult's value
michael@0 22 **/
michael@0 23 NumberResult::NumberResult(double aValue, txResultRecycler* aRecycler)
michael@0 24 : txAExprResult(aRecycler), value(aValue)
michael@0 25 {
michael@0 26 } //-- NumberResult
michael@0 27
michael@0 28 /*
michael@0 29 * Virtual Methods from ExprResult
michael@0 30 */
michael@0 31
michael@0 32 short NumberResult::getResultType() {
michael@0 33 return txAExprResult::NUMBER;
michael@0 34 } //-- getResultType
michael@0 35
michael@0 36 void
michael@0 37 NumberResult::stringValue(nsString& aResult)
michael@0 38 {
michael@0 39 txDouble::toString(value, aResult);
michael@0 40 }
michael@0 41
michael@0 42 const nsString*
michael@0 43 NumberResult::stringValuePointer()
michael@0 44 {
michael@0 45 return nullptr;
michael@0 46 }
michael@0 47
michael@0 48 bool NumberResult::booleanValue() {
michael@0 49 // OG+
michael@0 50 // As per the XPath spec, the boolean value of a number is true if and only if
michael@0 51 // it is neither positive 0 nor negative 0 nor NaN
michael@0 52 return (bool)(value != 0.0 && !mozilla::IsNaN(value));
michael@0 53 // OG-
michael@0 54 } //-- booleanValue
michael@0 55
michael@0 56 double NumberResult::numberValue() {
michael@0 57 return this->value;
michael@0 58 } //-- numberValue
michael@0 59

mercurial