From 36c16b92925b4a5df08cb8b1d59a7f4423c4f312 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 19 Jun 2009 17:26:59 +0000 Subject: [PATCH] Added Is{Number,Integer,Float}() methods. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31119 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/debuganalyzer/util/Variant.cpp | 53 +++++++++++++++++++++++++ src/apps/debuganalyzer/util/Variant.h | 5 +++ 2 files changed, 58 insertions(+) diff --git a/src/apps/debuganalyzer/util/Variant.cpp b/src/apps/debuganalyzer/util/Variant.cpp index daeff14e9f..767d6d5a3c 100644 --- a/src/apps/debuganalyzer/util/Variant.cpp +++ b/src/apps/debuganalyzer/util/Variant.cpp @@ -64,6 +64,59 @@ Variant::Unset() } +bool +Variant::IsNumber() const +{ + switch (fType) { + case B_INT8_TYPE: + case B_UINT8_TYPE: + case B_INT16_TYPE: + case B_UINT16_TYPE: + case B_INT32_TYPE: + case B_UINT32_TYPE: + case B_INT64_TYPE: + case B_UINT64_TYPE: + case B_FLOAT_TYPE: + case B_DOUBLE_TYPE: + return true; + default: + return false; + } +} + + +bool +Variant::IsInteger() const +{ + switch (fType) { + case B_INT8_TYPE: + case B_UINT8_TYPE: + case B_INT16_TYPE: + case B_UINT16_TYPE: + case B_INT32_TYPE: + case B_UINT32_TYPE: + case B_INT64_TYPE: + case B_UINT64_TYPE: + return true; + default: + return false; + } +} + + +bool +Variant::IsFloat() const +{ + switch (fType) { + case B_FLOAT_TYPE: + case B_DOUBLE_TYPE: + return true; + default: + return false; + } +} + + int8 Variant::ToInt8() const { diff --git a/src/apps/debuganalyzer/util/Variant.h b/src/apps/debuganalyzer/util/Variant.h index b959304c3c..ff743f53ad 100644 --- a/src/apps/debuganalyzer/util/Variant.h +++ b/src/apps/debuganalyzer/util/Variant.h @@ -55,6 +55,11 @@ public: type_code Type() const { return fType; } + bool IsNumber() const; + bool IsInteger() const; + bool IsFloat() const; + // floating point, not just float + int8 ToInt8() const; uint8 ToUInt8() const; int16 ToInt16() const;