From 6d9f98fd95c3c3ae2d6cb7621c9e34c5de41696a Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 5 Nov 2014 23:51:28 -0500 Subject: [PATCH] Debugger: Add some type utility functions. Add helper function for converting a type code to a type name. --- .../debugger/user_interface/util/UiUtils.cpp | 32 ++++++++++++++++++- .../debugger/user_interface/util/UiUtils.h | 3 ++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/apps/debugger/user_interface/util/UiUtils.cpp b/src/apps/debugger/user_interface/util/UiUtils.cpp index 39eee3f784..b6c9904b8c 100644 --- a/src/apps/debugger/user_interface/util/UiUtils.cpp +++ b/src/apps/debugger/user_interface/util/UiUtils.cpp @@ -1,6 +1,6 @@ /* * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2012-2013, Rene Gollent, rene@gollent.com. + * Copyright 2012-2014, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -453,3 +453,33 @@ UiUtils::ParseRangeExpression(const BString& rangeExpression, int32 lowerBound, return B_OK; } + + +/*static*/ const char* +UiUtils::TypeCodeToString(type_code type) +{ + switch (type) { + case B_INT8_TYPE: + return "int8"; + case B_UINT8_TYPE: + return "uint8"; + case B_INT16_TYPE: + return "int16"; + case B_UINT16_TYPE: + return "uint16"; + case B_INT32_TYPE: + return "int32"; + case B_UINT32_TYPE: + return "uint32"; + case B_INT64_TYPE: + return "int64"; + case B_UINT64_TYPE: + return "uint64"; + case B_FLOAT_TYPE: + return "float"; + case B_DOUBLE_TYPE: + return "double"; + default: + return "unknown"; + } +} diff --git a/src/apps/debugger/user_interface/util/UiUtils.h b/src/apps/debugger/user_interface/util/UiUtils.h index 7b11be9a18..4d9cdb2c42 100644 --- a/src/apps/debugger/user_interface/util/UiUtils.h +++ b/src/apps/debugger/user_interface/util/UiUtils.h @@ -1,4 +1,5 @@ /* + * Copyright 2014, Rene Gollent, rene@gollent.com. * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -57,6 +58,8 @@ public: int32 lowerBound, int32 upperBound, bool fixedRange, RangeList& _output); + + static const char* TypeCodeToString(type_code type); };