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