1 /* 2 * Copyright 2006, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 */ 8 9 #include "Int64Property.h" 10 11 #include <new> 12 #include <stdio.h> 13 #include <stdlib.h> 14 15 using std::nothrow; 16 17 // constructor 18 Int64Property::Int64Property(uint32 identifier, int64 value) 19 : Property(identifier), 20 fValue(value) 21 { 22 } 23 24 // constructor 25 Int64Property::Int64Property(const Int64Property& other) 26 : Property(other), 27 fValue(other.fValue) 28 { 29 } 30 31 // destructor 32 Int64Property::~Int64Property() 33 { 34 } 35 36 // Clone 37 Property* 38 Int64Property::Clone() const 39 { 40 return new (nothrow) Int64Property(*this); 41 } 42 43 // SetValue 44 bool 45 Int64Property::SetValue(const char* value) 46 { 47 // TODO: atoll is defined for __i386__ only 48 return SetValue(atoll(value)); 49 } 50 51 // SetValue 52 bool 53 Int64Property::SetValue(const Property* other) 54 { 55 const Int64Property* intOther = dynamic_cast<const Int64Property*>(other); 56 if (intOther) { 57 return SetValue(intOther->Value()); 58 } 59 return false; 60 } 61 62 // GetValue 63 void 64 Int64Property::GetValue(BString& string) 65 { 66 string << fValue; 67 } 68 69 // InterpolateTo 70 bool 71 Int64Property::InterpolateTo(const Property* other, float scale) 72 { 73 const Int64Property* intOther = dynamic_cast<const Int64Property*>(other); 74 if (intOther) { 75 return SetValue(fValue + (int64)((double)(intOther->Value() 76 - fValue) * scale + 0.5)); 77 } 78 return false; 79 } 80 81 // SetValue 82 bool 83 Int64Property::SetValue(int64 value) 84 { 85 if (value != fValue) { 86 fValue = value; 87 return true; 88 } 89 return false; 90 } 91 92