本文整理汇总了C++中DataPtr::destroy方法的典型用法代码示例。如果您正苦于以下问题:C++ DataPtr::destroy方法的具体用法?C++ DataPtr::destroy怎么用?C++ DataPtr::destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataPtr
的用法示例。
在下文中一共展示了DataPtr::destroy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
FreezeScript::TransformVisitor::visitObject(const ObjectRefPtr& dest)
{
Slice::TypePtr type = dest->getType();
ObjectRefPtr src = ObjectRefPtr::dynamicCast(_src);
if(!src)
{
typeMismatchError(type, _src->getType());
}
else if(_info->doDefaultTransform(type))
{
ObjectDataPtr srcValue = src->getValue();
Slice::TypePtr srcType = src->getType();
if(!srcValue)
{
//
// Allow a nil value from type Object.
//
if(Slice::BuiltinPtr::dynamicCast(srcType) || isCompatible(type, srcType))
{
dest->setValue(0);
}
else
{
typeMismatchError(type, srcType);
}
}
else
{
Slice::TypePtr srcValueType = srcValue->getType();
if(isCompatible(type, srcValueType))
{
//
// If the types are in the same Slice unit, then we can simply
// copy the reference. Otherwise, we check the object map to
// see if an equivalent object has already been created, and
// if not, then we have to create one.
//
if(type->unit().get() == srcValueType->unit().get())
{
dest->setValue(srcValue);
}
else
{
ObjectDataMap& objectDataMap = _info->getObjectDataMap();
ObjectDataMap::iterator p = objectDataMap.find(srcValue.get());
if(p != objectDataMap.end() && p->second)
{
dest->setValue(p->second);
}
else
{
//
// If the type has been renamed, we need to get its equivalent
// in the new Slice definitions.
//
Slice::TypePtr newType = _info->getRenamedType(srcValueType);
if(!newType)
{
string name = typeToString(srcValueType);
Slice::TypeList l = type->unit()->lookupType(name, false);
if(l.empty())
{
throw ClassNotFoundException(name);
}
newType = l.front();
}
//
// Use createObject() so that an initializer is invoked if necessary.
//
DataPtr newObj = _info->getDataFactory()->createObject(newType, false);
ObjectRefPtr newRef = ObjectRefPtr::dynamicCast(newObj);
assert(newRef);
ObjectDataPtr newValue = newRef->getValue();
try
{
transformObject(newValue, srcValue);
}
catch(...)
{
newObj->destroy();
throw;
}
dest->setValue(newValue);
newObj->destroy();
}
}
}
else
{
typeMismatchError(type, srcValueType);
}
}
}
_info->executeCustomTransform(dest, _src);
}