To verify a data type using a group code, use casting codes. In the following examples, the pRb variable
stores a pointer to the resbuf-object.
The OdDxfCode class declares the Type enumerator that defines the symbolic notations for predefined data
types to which a data value may be cast. This class has a single static _getType() method that requires
a dxf-code or group code and returns the identifier of the predefined type to which the data value associated
with the dxf-code or group code may be cast as a value of the OdDxfCode::Type enumerator. The Type enumerator
defines the following:
To use casting codes, pass the group code to the _getType() method and compare the returned code
with the allowable values using the switch-case statement. For example:
OdString WhatIsCodeType(OdResBuf* pRb)
{
OdString sInfo;
OdGePoint3d point;
OdInt16 type = pRb->restype();
switch( OdDxfCode::_getType(type) )
{
case OdDxfCode::Bool:
sInfo.format(L"%d,Bool = %s", type, ((pRb->getBool()) ? L"true" : L"false"));
break;
case OdDxfCode::Name:
case OdDxfCode::String:
case OdDxfCode::LayerName:
sInfo.format(L"%d,String = \"%s\"", type, pRb->getString().c_str());
break;
case OdDxfCode::Integer8:
sInfo.format(L"%d,Byte = %x", type, pRb->getInt8());
break;
case OdDxfCode::Integer16:
sInfo.format(L"%d,Short = %d", type, pRb->getInt16());
break;
case OdDxfCode::Integer32:
sInfo.format(L"%d,Long = %ld", type, pRb->getInt32());
break;
case OdDxfCode::Integer64:
sInfo.format(L"%d,Int = %ld", type, pRb->getInt64());
break;
case OdDxfCode::Angle:
case OdDxfCode::Double:
sInfo.format(L"%d,Double = %g", type, pRb->getDouble());
break;
case OdDxfCode::Point:
point = pRb->getPoint3d();
sInfo.format(L"%d,3DPoint = (%g,%g,%g)", type, point.x, point.y, point.z);
break;
case OdDxfCode::Handle:
case OdDxfCode::SoftPointerId:
case OdDxfCode::HardPointerId:
case OdDxfCode::SoftOwnershipId:
case OdDxfCode::HardOwnershipId:
sInfo.format(L"%d,Handle = %s", type, pRb->getHandle().ascii().c_str());
break;
default:
if(type == OdResBuf::kRtColor)
sInfo.format(L"%d,Color = %s", type, pRb->getColor().colorNameForDisplay().c_str());
else if(type == OdResBuf::kRtEntName)
sInfo.format(L"%d,ID = %s", type, pRb->getEntName().getHandle().ascii().c_str());
else
sInfo = L"Unknown";
}
return sInfo;
}