本文整理汇总了C++中CObjectOStream::EndChoice方法的典型用法代码示例。如果您正苦于以下问题:C++ CObjectOStream::EndChoice方法的具体用法?C++ CObjectOStream::EndChoice怎么用?C++ CObjectOStream::EndChoice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CObjectOStream
的用法示例。
在下文中一共展示了CObjectOStream::EndChoice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteChoiceDefault
void CChoiceTypeInfoFunctions::WriteChoiceDefault(CObjectOStream& out,
TTypeInfo objectType,
TConstObjectPtr objectPtr)
{
const CChoiceTypeInfo* choiceType =
CTypeConverter<CChoiceTypeInfo>::SafeCast(objectType);
BEGIN_OBJECT_FRAME_OF3(out, eFrameChoice, choiceType, objectPtr);
out.BeginChoice(choiceType);
TMemberIndex index = choiceType->GetVariants().FirstIndex();
const CVariantInfo* variantInfo = choiceType->GetVariantInfo(index);
if (variantInfo->GetId().IsAttlist()) {
const CMemberInfo* memberInfo =
dynamic_cast<const CMemberInfo*>(
choiceType->GetVariants().GetItemInfo(index));
memberInfo->WriteMember(out,objectPtr);
}
index = choiceType->GetIndex(objectPtr);
if ( index == kInvalidMember )
out.ThrowError(out.fInvalidData, "cannot write empty choice");
variantInfo = choiceType->GetVariantInfo(index);
BEGIN_OBJECT_FRAME_OF2(out, eFrameChoiceVariant, variantInfo->GetId());
out.BeginChoiceVariant(choiceType, variantInfo->GetId());
variantInfo->WriteVariant(out, objectPtr);
out.EndChoiceVariant();
END_OBJECT_FRAME_OF(out);
out.EndChoice();
END_OBJECT_FRAME_OF(out);
}