Line data Source code
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 0 : NumberResult::NumberResult(double aValue, txResultRecycler* aRecycler)
24 0 : : txAExprResult(aRecycler), value(aValue)
25 : {
26 0 : } //-- NumberResult
27 :
28 : /*
29 : * Virtual Methods from ExprResult
30 : */
31 :
32 0 : short NumberResult::getResultType() {
33 0 : return txAExprResult::NUMBER;
34 : } //-- getResultType
35 :
36 : void
37 0 : NumberResult::stringValue(nsString& aResult)
38 : {
39 0 : txDouble::toString(value, aResult);
40 0 : }
41 :
42 : const nsString*
43 0 : NumberResult::stringValuePointer()
44 : {
45 0 : return nullptr;
46 : }
47 :
48 0 : 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 0 : return (bool)(value != 0.0 && !mozilla::IsNaN(value));
53 : // OG-
54 : } //-- booleanValue
55 :
56 0 : double NumberResult::numberValue() {
57 0 : return this->value;
58 : } //-- numberValue
59 :
|