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
15using std::nothrow;
16
17// constructor
18Int64Property::Int64Property(uint32 identifier, int64 value)
19	: Property(identifier),
20	  fValue(value)
21{
22}
23
24// constructor
25Int64Property::Int64Property(const Int64Property& other)
26	: Property(other),
27	  fValue(other.fValue)
28{
29}
30
31// destructor
32Int64Property::~Int64Property()
33{
34}
35
36// Clone
37Property*
38Int64Property::Clone() const
39{
40	return new (nothrow) Int64Property(*this);
41}
42
43// SetValue
44bool
45Int64Property::SetValue(const char* value)
46{
47	// TODO: atoll is defined for __i386__ only
48	return SetValue(atoll(value));
49}
50
51// SetValue
52bool
53Int64Property::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
63void
64Int64Property::GetValue(BString& string)
65{
66	string << fValue;
67}
68
69// InterpolateTo
70bool
71Int64Property::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
82bool
83Int64Property::SetValue(int64 value)
84{
85	if (value != fValue) {
86		fValue = value;
87		return true;
88	}
89	return false;
90}
91
92