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:
@@ -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
|
int8
|
||||||
Variant::ToInt8() const
|
Variant::ToInt8() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,6 +55,11 @@ public:
|
|||||||
|
|
||||||
type_code Type() const { return fType; }
|
type_code Type() const { return fType; }
|
||||||
|
|
||||||
|
bool IsNumber() const;
|
||||||
|
bool IsInteger() const;
|
||||||
|
bool IsFloat() const;
|
||||||
|
// floating point, not just float
|
||||||
|
|
||||||
int8 ToInt8() const;
|
int8 ToInt8() const;
|
||||||
uint8 ToUInt8() const;
|
uint8 ToUInt8() const;
|
||||||
int16 ToInt16() const;
|
int16 ToInt16() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user