xref: /haiku/src/apps/debugger/user_interface/gui/util/TargetAddressTableColumn.cpp (revision 25a7b01d15612846f332751841da3579db313082)
1e3a631c0SIngo Weinhold /*
2*7483c98dSIngo Weinhold  * Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de.
3e3a631c0SIngo Weinhold  * Distributed under the terms of the MIT License.
4e3a631c0SIngo Weinhold  */
5e3a631c0SIngo Weinhold 
6e3a631c0SIngo Weinhold 
7e3a631c0SIngo Weinhold #include "TargetAddressTableColumn.h"
8e3a631c0SIngo Weinhold 
9e3a631c0SIngo Weinhold #include <stdio.h>
10e3a631c0SIngo Weinhold 
11e3a631c0SIngo Weinhold 
TargetAddressTableColumn(int32 modelIndex,const char * title,float width,float minWidth,float maxWidth,uint32 truncate,alignment align)12e3a631c0SIngo Weinhold TargetAddressTableColumn::TargetAddressTableColumn(int32 modelIndex,
13e3a631c0SIngo Weinhold 	const char* title, float width, float minWidth, float maxWidth,
14e3a631c0SIngo Weinhold 	uint32 truncate, alignment align)
15e3a631c0SIngo Weinhold 	:
16e3a631c0SIngo Weinhold 	StringTableColumn(modelIndex, title, width, minWidth, maxWidth, truncate,
17e3a631c0SIngo Weinhold 		align)
18e3a631c0SIngo Weinhold {
19e3a631c0SIngo Weinhold }
20e3a631c0SIngo Weinhold 
21e3a631c0SIngo Weinhold 
22e3a631c0SIngo Weinhold BField*
PrepareField(const BVariant & value) const23e3a631c0SIngo Weinhold TargetAddressTableColumn::PrepareField(const BVariant& value) const
24e3a631c0SIngo Weinhold {
25e3a631c0SIngo Weinhold 	char buffer[64];
26*7483c98dSIngo Weinhold 	snprintf(buffer, sizeof(buffer), "%#" B_PRIx64, value.ToUInt64());
27e3a631c0SIngo Weinhold 
28e3a631c0SIngo Weinhold 	return StringTableColumn::PrepareField(
29e3a631c0SIngo Weinhold 		BVariant(buffer, B_VARIANT_DONT_COPY_DATA));
30e3a631c0SIngo Weinhold }
31e3a631c0SIngo Weinhold 
32e3a631c0SIngo Weinhold 
33e3a631c0SIngo Weinhold int
CompareValues(const BVariant & a,const BVariant & b)34e3a631c0SIngo Weinhold TargetAddressTableColumn::CompareValues(const BVariant& a, const BVariant& b)
35e3a631c0SIngo Weinhold {
36e3a631c0SIngo Weinhold 	uint64 valueA = a.ToUInt64();
37e3a631c0SIngo Weinhold 	uint64 valueB = b.ToUInt64();
38e3a631c0SIngo Weinhold 	return valueA < valueB ? -1 : (valueA == valueB ? 0 : 1);
39e3a631c0SIngo Weinhold }
40