本文整理汇总了C++中CDatum::GetNumberType方法的典型用法代码示例。如果您正苦于以下问题:C++ CDatum::GetNumberType方法的具体用法?C++ CDatum::GetNumberType怎么用?C++ CDatum::GetNumberType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDatum
的用法示例。
在下文中一共展示了CDatum::GetNumberType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNumberType
CDatum::Types CDatum::GetNumberType (int *retiValue, CDatum *retdConverted) const
// GetNumberType
//
// Returns the most appropriate number type for the datum and optimistically
// returns the value if the type is integer.
//
// The number type is the best number type that the datum can be cast
// to without loss of data, following this order (from most preferable to
// least):
//
// typeInteger32
// typeDouble
// typeIntegerIP
//
// If the original datum is a string then we try to parse it and return the
// best number type. retdConverted will be a datum representing the parsed
// number.
//
// If the value cannot be converted to a number we return typeUnknown.
{
// Pre-init
if (retdConverted)
*retdConverted = *this;
switch (m_dwData & AEON_TYPE_MASK)
{
case AEON_TYPE_STRING:
{
if (m_dwData == 0)
{
if (retiValue)
*retiValue = 0;
return typeInteger32;
}
else
{
CDatum dNumberValue;
if (!CDatum::CreateFromStringValue(*this, &dNumberValue)
|| !dNumberValue.IsNumber())
return typeUnknown;
if (retdConverted)
*retdConverted = dNumberValue;
return dNumberValue.GetNumberType(retiValue);
}
}
case AEON_TYPE_NUMBER:
switch (m_dwData & AEON_NUMBER_TYPE_MASK)
{
case AEON_NUMBER_CONSTANT:
{
switch (m_dwData)
{
case constTrue:
if (retiValue)
*retiValue = 1;
return typeInteger32;
default:
ASSERT(false);
return typeUnknown;
}
}
case AEON_NUMBER_28BIT:
if (retiValue)
*retiValue = ((int)(m_dwData & AEON_NUMBER_MASK) >> 4);
return typeInteger32;
case AEON_NUMBER_32BIT:
if (retiValue)
*retiValue = (int)g_IntAlloc.Get(GetNumberIndex());
return typeInteger32;
case AEON_NUMBER_DOUBLE:
return typeDouble;
default:
ASSERT(false);
return typeUnknown;
}
case AEON_TYPE_COMPLEX:
return raw_GetComplex()->GetNumberType(retiValue);
default:
ASSERT(false);
return typeUnknown;
}
}