|
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 * StringResult |
|
8 * Represents a String as a Result of evaluating an Expr |
|
9 **/ |
|
10 #include "txExprResult.h" |
|
11 |
|
12 /** |
|
13 * Default Constructor |
|
14 **/ |
|
15 StringResult::StringResult(txResultRecycler* aRecycler) |
|
16 : txAExprResult(aRecycler) |
|
17 { |
|
18 } |
|
19 |
|
20 /** |
|
21 * Creates a new StringResult with the value of the given String parameter |
|
22 * @param str the String to use for initialization of this StringResult's value |
|
23 **/ |
|
24 StringResult::StringResult(const nsAString& aValue, txResultRecycler* aRecycler) |
|
25 : txAExprResult(aRecycler), mValue(aValue) |
|
26 { |
|
27 } |
|
28 |
|
29 /* |
|
30 * Virtual Methods from ExprResult |
|
31 */ |
|
32 |
|
33 short StringResult::getResultType() { |
|
34 return txAExprResult::STRING; |
|
35 } //-- getResultType |
|
36 |
|
37 void |
|
38 StringResult::stringValue(nsString& aResult) |
|
39 { |
|
40 aResult.Append(mValue); |
|
41 } |
|
42 |
|
43 const nsString* |
|
44 StringResult::stringValuePointer() |
|
45 { |
|
46 return &mValue; |
|
47 } |
|
48 |
|
49 bool StringResult::booleanValue() { |
|
50 return !mValue.IsEmpty(); |
|
51 } //-- booleanValue |
|
52 |
|
53 double StringResult::numberValue() { |
|
54 return txDouble::toDouble(mValue); |
|
55 } //-- numberValue |
|
56 |