Added Is{Number,Integer,Float}() methods.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31119 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2009-06-19 17:26:59 +00:00
parent 2a3974d313
commit 36c16b9292
2 changed files with 58 additions and 0 deletions

View File

@ -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
{

View File

@ -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;