tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

txNumberResult.cpp (1380B)


      1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      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 "txExprResult.h"
     12 
     13 /**
     14 * Default Constructor
     15 **/
     16 
     17 /**
     18 * Creates a new NumberResult with the value of the given double parameter
     19 * @param dbl the double to use for initialization of this NumberResult's value
     20 **/
     21 NumberResult::NumberResult(double aValue, txResultRecycler* aRecycler)
     22    : txAExprResult(aRecycler), value(aValue) {}  //-- NumberResult
     23 
     24 /*
     25 * Virtual Methods from ExprResult
     26 */
     27 
     28 short NumberResult::getResultType() {
     29  return txAExprResult::NUMBER;
     30 }  //-- getResultType
     31 
     32 void NumberResult::stringValue(nsString& aResult) {
     33  txDouble::toString(value, aResult);
     34 }
     35 
     36 const nsString* NumberResult::stringValuePointer() { return nullptr; }
     37 
     38 bool NumberResult::booleanValue() {
     39  // OG+
     40  // As per the XPath spec, the boolean value of a number is true if and only if
     41  // it is neither positive 0 nor negative 0 nor NaN
     42  return (bool)(value != 0.0 && !std::isnan(value));
     43  // OG-
     44 }  //-- booleanValue
     45 
     46 double NumberResult::numberValue() { return this->value; }  //-- numberValue