dom/xslt/xpath/txBooleanResult.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/xslt/xpath/txBooleanResult.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,56 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/*
    1.10 + * Boolean Expression result
    1.11 +*/
    1.12 +
    1.13 +#include "txExprResult.h"
    1.14 +
    1.15 +/**
    1.16 + * Creates a new BooleanResult with the value of the given bool parameter
    1.17 + * @param boolean the bool to use for initialization of this BooleanResult's value
    1.18 +**/
    1.19 +BooleanResult::BooleanResult(bool boolean)
    1.20 +    : txAExprResult(nullptr)
    1.21 +{
    1.22 +    this->value = boolean;
    1.23 +} //-- BooleanResult
    1.24 +
    1.25 +/*
    1.26 + * Virtual Methods from ExprResult
    1.27 +*/
    1.28 +
    1.29 +short BooleanResult::getResultType() {
    1.30 +    return txAExprResult::BOOLEAN;
    1.31 +} //-- getResultType
    1.32 +
    1.33 +void
    1.34 +BooleanResult::stringValue(nsString& aResult)
    1.35 +{
    1.36 +    if (value) {
    1.37 +        aResult.AppendLiteral("true");
    1.38 +    }
    1.39 +    else {
    1.40 +        aResult.AppendLiteral("false");
    1.41 +    }
    1.42 +}
    1.43 +
    1.44 +const nsString*
    1.45 +BooleanResult::stringValuePointer()
    1.46 +{
    1.47 +    // In theory we could set strings containing "true" and "false" somewhere,
    1.48 +    // but most stylesheets never get the stringvalue of a bool so that won't
    1.49 +    // really buy us anything.
    1.50 +    return nullptr;
    1.51 +}
    1.52 +
    1.53 +bool BooleanResult::booleanValue() {
    1.54 +   return this->value;
    1.55 +} //-- toBoolean
    1.56 +
    1.57 +double BooleanResult::numberValue() {
    1.58 +    return ( value ) ? 1.0 : 0.0;
    1.59 +} //-- toNumber

mercurial