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
10IntegerValue::IntegerValue(const BVariant& value)
11	:
12	fValue(value)
13{
14}
15
16
17IntegerValue::~IntegerValue()
18{
19}
20
21
22bool
23IntegerValue::IsSigned() const
24{
25	bool isSigned;
26	return fValue.IsInteger(&isSigned) && isSigned;
27}
28
29
30bool
31IntegerValue::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
51bool
52IntegerValue::ToVariant(BVariant& _value) const
53{
54	_value = fValue;
55	return true;
56}
57
58
59bool
60IntegerValue::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