dom/xslt/xpath/txNumberResult.cpp

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

mercurial