txStringResult.cpp (1281B)
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 * 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 * Creates a new StringResult with the value of the given String parameter 20 * @param str the String to use for initialization of this StringResult's value 21 **/ 22 StringResult::StringResult(const nsAString& aValue, txResultRecycler* aRecycler) 23 : txAExprResult(aRecycler), mValue(aValue) {} 24 25 /* 26 * Virtual Methods from ExprResult 27 */ 28 29 short StringResult::getResultType() { 30 return txAExprResult::STRING; 31 } //-- getResultType 32 33 void StringResult::stringValue(nsString& aResult) { aResult.Append(mValue); } 34 35 const nsString* StringResult::stringValuePointer() { return &mValue; } 36 37 bool StringResult::booleanValue() { 38 return !mValue.IsEmpty(); 39 } //-- booleanValue 40 41 double StringResult::numberValue() { 42 return txDouble::toDouble(mValue); 43 } //-- numberValue