Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/xslt/xpath/txBooleanResult.cpp
Line
Count
Source (jump to first uncovered line)
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
 * Boolean Expression result
8
*/
9
10
#include "txExprResult.h"
11
12
/**
13
 * Creates a new BooleanResult with the value of the given bool parameter
14
 * @param boolean the bool to use for initialization of this BooleanResult's value
15
**/
16
BooleanResult::BooleanResult(bool boolean)
17
    : txAExprResult(nullptr)
18
0
{
19
0
    this->value = boolean;
20
0
} //-- BooleanResult
21
22
/*
23
 * Virtual Methods from ExprResult
24
*/
25
26
0
short BooleanResult::getResultType() {
27
0
    return txAExprResult::BOOLEAN;
28
0
} //-- getResultType
29
30
void
31
BooleanResult::stringValue(nsString& aResult)
32
0
{
33
0
    if (value) {
34
0
        aResult.AppendLiteral("true");
35
0
    }
36
0
    else {
37
0
        aResult.AppendLiteral("false");
38
0
    }
39
0
}
40
41
const nsString*
42
BooleanResult::stringValuePointer()
43
0
{
44
0
    // In theory we could set strings containing "true" and "false" somewhere,
45
0
    // but most stylesheets never get the stringvalue of a bool so that won't
46
0
    // really buy us anything.
47
0
    return nullptr;
48
0
}
49
50
0
bool BooleanResult::booleanValue() {
51
0
   return this->value;
52
0
} //-- toBoolean
53
54
0
double BooleanResult::numberValue() {
55
0
    return ( value ) ? 1.0 : 0.0;
56
0
} //-- toNumber