1 /* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include "IntegerValue.h" 8 9 10 IntegerValue::IntegerValue(const BVariant& value) 11 : 12 fValue(value) 13 { 14 } 15 16 17 IntegerValue::~IntegerValue() 18 { 19 } 20 21 22 bool 23 IntegerValue::IsSigned() const 24 { 25 bool isSigned; 26 return fValue.IsInteger(&isSigned) && isSigned; 27 } 28 29 30 bool 31 IntegerValue::ToString(BString& _string) const 32 { 33 bool isSigned; 34 if (!fValue.IsInteger(&isSigned)) 35 return false; 36 37 BString string; 38 if (isSigned) 39 string << fValue.ToInt64(); 40 else 41 string << fValue.ToUInt64(); 42 43 if (string.Length() == 0) 44 return false; 45 46 _string = string; 47 return true; 48 } 49 50 51 bool 52 IntegerValue::ToVariant(BVariant& _value) const 53 { 54 _value = fValue; 55 return true; 56 } 57 58 59 bool 60 IntegerValue::operator==(const Value& other) const 61 { 62 const IntegerValue* otherInt = dynamic_cast<const IntegerValue*>(&other); 63 return otherInt != NULL ? fValue == otherInt->fValue : false; 64 } 65