Ejemplo n.º 1
0
    virtual void CopyObject(CObjectStreamCopier& copier,
                            const CObjectTypeInfo& passed_info)
    {
        cout << copier.In().GetStackPath() << endl;
#if 1
        DefaultCopy(copier, passed_info);

#else
#if 1
// or skip the object
        copier.In().SkipObject(passed_info.GetTypeInfo());
#endif
#if 0
// or read object
        CSeq_annot annot;
        copier.In().ReadObject(&annot, CSeq_annot::GetTypeInfo());
        cout << MSerial_AsnText << annot << endl;
// and maybe write it as well
        copier.Out().WriteObject(&annot, CSeq_annot::GetTypeInfo());
#endif
#if 0
// or read object and write it
        CObjectInfo oi(passed_info.GetTypeInfo());
        copier.In().ReadObject(oi);
        copier.Out().WriteObject(oi);
#endif
        
        // typeinfo of the object (Seq-annot)
        TTypeInfo ti = passed_info.GetTypeInfo();
#endif
    }
Ejemplo n.º 2
0
void CObjectOStream::CopyChoice(const CChoiceTypeInfo* choiceType,
                                CObjectStreamCopier& copier)
{
    BEGIN_OBJECT_2FRAMES_OF2(copier, eFrameChoice, choiceType);

    BeginChoice(choiceType);
    copier.In().BeginChoice(choiceType);
    BEGIN_OBJECT_2FRAMES_OF(copier, eFrameChoiceVariant);
    TMemberIndex index = copier.In().BeginChoiceVariant(choiceType);
    if ( index == kInvalidMember ) {
        if (choiceType->MayBeEmpty() || copier.In().CanSkipUnknownVariants()) {
            copier.In().SkipAnyContentVariant();
        } else {
            copier.ThrowError(CObjectIStream::fFormatError,
                              "choice variant id expected");
        }
    } else {
        for (;;) {
        const CVariantInfo* variantInfo = choiceType->GetVariantInfo(index);
        if (variantInfo->GetId().IsAttlist()) {
            const CMemberInfo* memberInfo =
                dynamic_cast<const CMemberInfo*>(
                    choiceType->GetVariants().GetItemInfo(index));
            BeginClassMember(memberInfo->GetId());
            memberInfo->CopyMember(copier);
            EndClassMember();
            copier.In().EndChoiceVariant();
            index = copier.In().BeginChoiceVariant(choiceType);
            if ( index == kInvalidMember ) {
                if (copier.In().CanSkipUnknownVariants()) {
                    copier.In().SkipAnyContentVariant();
                    break;
                } else {
                    copier.ThrowError(CObjectIStream::fFormatError,
                                  "choice variant id expected");
                }
            }
            variantInfo = choiceType->GetVariantInfo(index);
        }
        copier.In().SetTopMemberId(variantInfo->GetId());
        copier.Out().SetTopMemberId(variantInfo->GetId());
        copier.SetPathHooks(copier.Out(), true);
        BeginChoiceVariant(choiceType, variantInfo->GetId());

        variantInfo->CopyVariant(copier);

        EndChoiceVariant();
        copier.SetPathHooks(copier.Out(), false);
        copier.In().EndChoiceVariant();
        break;
        }
    }
    END_OBJECT_2FRAMES_OF(copier);
    copier.In().EndChoice();
    EndChoice();
    END_OBJECT_2FRAMES_OF(copier);
}
Ejemplo n.º 3
0
 static void Copy(CObjectStreamCopier& copier, TTypeInfo )
     {
         copier.In().ReadNull();
         copier.Out().WriteNull();
     }