⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 variant.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    variantType->ReadData(in, variantPtr);}void CVariantInfo::SetReadFunction(TVariantReadFunction func){    m_ReadHookData.SetDefaultFunction(func);}void CVariantInfo::SetWriteFunction(TVariantWriteFunction func){    m_WriteHookData.SetDefaultFunction(func);}void CVariantInfo::SetCopyFunction(TVariantCopyFunction func){    m_CopyHookData.SetDefaultFunction(func);}void CVariantInfo::SetSkipFunction(TVariantSkipFunction func){    m_SkipHookData.SetDefaultFunction(func);}TObjectPtr CVariantInfo::CreateChoice(void) const{    return GetChoiceType()->Create();}TConstObjectPtrCVariantInfoFunctions::GetConstInlineVariant(const CVariantInfo* variantInfo,                                             TConstObjectPtr choicePtr){    _ASSERT(!variantInfo->CanBeDelayed());    _ASSERT(variantInfo->IsInline());    _ASSERT(variantInfo->GetChoiceType()->GetIndex(choicePtr) ==            variantInfo->GetIndex());    return variantInfo->GetItemPtr(choicePtr);}TConstObjectPtrCVariantInfoFunctions::GetConstPointerVariant(const CVariantInfo* variantInfo,                                              TConstObjectPtr choicePtr){    _ASSERT(!variantInfo->CanBeDelayed());    _ASSERT(variantInfo->IsPointer());    _ASSERT(variantInfo->GetChoiceType()->GetIndex(choicePtr) ==            variantInfo->GetIndex());    TConstObjectPtr variantPtr = variantInfo->GetItemPtr(choicePtr);    variantPtr = CTypeConverter<TConstObjectPtr>::Get(variantPtr);    _ASSERT(variantPtr);    return variantPtr;}TConstObjectPtrCVariantInfoFunctions::GetConstDelayedVariant(const CVariantInfo* variantInfo,                                              TConstObjectPtr choicePtr){    _ASSERT(variantInfo->CanBeDelayed());    _ASSERT(variantInfo->GetChoiceType()->GetIndex(choicePtr) ==            variantInfo->GetIndex());    const_cast<CDelayBuffer&>(variantInfo->GetDelayBuffer(choicePtr)).Update();    TConstObjectPtr variantPtr = variantInfo->GetItemPtr(choicePtr);    if ( variantInfo->IsPointer() ) {        variantPtr = CTypeConverter<TConstObjectPtr>::Get(variantPtr);        _ASSERT(variantPtr);    }    return variantPtr;}TConstObjectPtrCVariantInfoFunctions::GetConstSubclassVariant(const CVariantInfo* variantInfo,                                               TConstObjectPtr choicePtr){    _ASSERT(variantInfo->IsSubClass());    _ASSERT(variantInfo->GetChoiceType()->GetIndex(choicePtr) ==            variantInfo->GetIndex());    const CChoiceTypeInfo* choiceType = variantInfo->GetChoiceType();    const CChoicePointerTypeInfo* choicePtrType =        CTypeConverter<CChoicePointerTypeInfo>::SafeCast(choiceType);    TConstObjectPtr variantPtr =        choicePtrType->GetPointerTypeInfo()->GetObjectPointer(choicePtr);    _ASSERT(variantPtr);    return variantPtr;}TObjectPtrCVariantInfoFunctions::GetInlineVariant(const CVariantInfo* variantInfo,                                        TObjectPtr choicePtr){    _ASSERT(!variantInfo->CanBeDelayed());    _ASSERT(variantInfo->IsInline());    _ASSERT(variantInfo->GetChoiceType()->GetIndex(choicePtr) ==            variantInfo->GetIndex());    return variantInfo->GetItemPtr(choicePtr);}TObjectPtrCVariantInfoFunctions::GetPointerVariant(const CVariantInfo* variantInfo,                                         TObjectPtr choicePtr){    _ASSERT(!variantInfo->CanBeDelayed());    _ASSERT(variantInfo->IsPointer());    _ASSERT(variantInfo->GetChoiceType()->GetIndex(choicePtr) ==            variantInfo->GetIndex());    TObjectPtr variantPtr = variantInfo->GetItemPtr(choicePtr);    variantPtr = CTypeConverter<TObjectPtr>::Get(variantPtr);    _ASSERT(variantPtr);    return variantPtr;}TObjectPtrCVariantInfoFunctions::GetDelayedVariant(const CVariantInfo* variantInfo,                                         TObjectPtr choicePtr){    _ASSERT(variantInfo->CanBeDelayed());    _ASSERT(variantInfo->GetChoiceType()->GetIndex(choicePtr) ==            variantInfo->GetIndex());    variantInfo->GetDelayBuffer(choicePtr).Update();    TObjectPtr variantPtr = variantInfo->GetItemPtr(choicePtr);    if ( variantInfo->IsPointer() ) {        variantPtr = CTypeConverter<TObjectPtr>::Get(variantPtr);        _ASSERT(variantPtr);    }    return variantPtr;}TObjectPtrCVariantInfoFunctions::GetSubclassVariant(const CVariantInfo* variantInfo,                                          TObjectPtr choicePtr){    _ASSERT(variantInfo->IsSubClass());    _ASSERT(variantInfo->GetChoiceType()->GetIndex(choicePtr) ==            variantInfo->GetIndex());    const CChoiceTypeInfo* choiceType = variantInfo->GetChoiceType();    const CChoicePointerTypeInfo* choicePtrType =        CTypeConverter<CChoicePointerTypeInfo>::SafeCast(choiceType);    TObjectPtr variantPtr =        choicePtrType->GetPointerTypeInfo()->GetObjectPointer(choicePtr);    _ASSERT(variantPtr);    return variantPtr;}void CVariantInfoFunctions::ReadInlineVariant(CObjectIStream& in,                                              const CVariantInfo* variantInfo,                                              TObjectPtr choicePtr){    _ASSERT(!variantInfo->CanBeDelayed());    _ASSERT(variantInfo->IsInline());    const CChoiceTypeInfo* choiceType = variantInfo->GetChoiceType();    TMemberIndex index = variantInfo->GetIndex();    choiceType->SetIndex(choicePtr, index);    in.ReadObject(variantInfo->GetItemPtr(choicePtr),                  variantInfo->GetTypeInfo());}void CVariantInfoFunctions::ReadPointerVariant(CObjectIStream& in,                                               const CVariantInfo* variantInfo,                                               TObjectPtr choicePtr){    _ASSERT(!variantInfo->CanBeDelayed());    _ASSERT(variantInfo->IsNonObjectPointer());    const CChoiceTypeInfo* choiceType = variantInfo->GetChoiceType();    TMemberIndex index = variantInfo->GetIndex();    choiceType->SetIndex(choicePtr, index);    TObjectPtr variantPtr = variantInfo->GetItemPtr(choicePtr);    variantPtr = CTypeConverter<TObjectPtr>::Get(variantPtr);    _ASSERT(variantPtr != 0 );    in.ReadObject(variantPtr, variantInfo->GetTypeInfo());}void CVariantInfoFunctions::ReadObjectPointerVariant(CObjectIStream& in,                                                     const CVariantInfo* variantInfo,                                                     TObjectPtr choicePtr){    _ASSERT(!variantInfo->CanBeDelayed());    _ASSERT(variantInfo->IsObjectPointer());    const CChoiceTypeInfo* choiceType = variantInfo->GetChoiceType();    TMemberIndex index = variantInfo->GetIndex();    choiceType->SetIndex(choicePtr, index);    TObjectPtr variantPtr = variantInfo->GetItemPtr(choicePtr);    variantPtr = CTypeConverter<TObjectPtr>::Get(variantPtr);    _ASSERT(variantPtr != 0 );    in.ReadExternalObject(variantPtr, variantInfo->GetTypeInfo());}void CVariantInfoFunctions::ReadSubclassVariant(CObjectIStream& in,                                                const CVariantInfo* variantInfo,                                                TObjectPtr choicePtr){    _ASSERT(!variantInfo->CanBeDelayed());    _ASSERT(variantInfo->IsSubClass());    const CChoiceTypeInfo* choiceType = variantInfo->GetChoiceType();    TMemberIndex index = variantInfo->GetIndex();    choiceType->SetIndex(choicePtr, index);    const CChoicePointerTypeInfo* choicePtrType =        CTypeConverter<CChoicePointerTypeInfo>::SafeCast(choiceType);    TObjectPtr variantPtr =        choicePtrType->GetPointerTypeInfo()->GetObjectPointer(choicePtr);    _ASSERT(variantPtr);    in.ReadExternalObject(variantPtr, variantInfo->GetTypeInfo());}void CVariantInfoFunctions::ReadDelayedVariant(CObjectIStream& in,                                               const CVariantInfo* variantInfo,                                               TObjectPtr choicePtr){    _ASSERT(variantInfo->CanBeDelayed());    const CChoiceTypeInfo* choiceType = variantInfo->GetChoiceType();    TMemberIndex index = variantInfo->GetIndex();    TTypeInfo variantType = variantInfo->GetTypeInfo();    if ( index != choiceType->GetIndex(choicePtr) ) {        // index is differnet from current -> first, reset choice        choiceType->ResetIndex(choicePtr);        CDelayBuffer& buffer = variantInfo->GetDelayBuffer(choicePtr);        if ( !buffer ) {            in.StartDelayBuffer();            if ( variantInfo->IsObjectPointer() )                in.SkipExternalObject(variantType);            else                in.SkipObject(variantType);            in.EndDelayBuffer(buffer, variantInfo, choicePtr);            // update index            choiceType->SetDelayIndex(choicePtr, index);            return;        }        buffer.Update();        _ASSERT(!variantInfo->GetDelayBuffer(choicePtr));    }    // select for reading    choiceType->SetIndex(choicePtr, index);    TObjectPtr variantPtr = variantInfo->GetItemPtr(choicePtr);    if ( variantInfo->IsPointer() ) {        variantPtr = CTypeConverter<TObjectPtr>::Get(variantPtr);        _ASSERT(variantPtr != 0 );        if ( variantInfo->IsObjectPointer() ) {            in.ReadExternalObject(variantPtr, variantType);            return;        }    }    in.ReadObject(variantPtr, variantType);}void CVariantInfoFunctions::WriteInlineVariant(CObjectOStream& out,                                               const CVariantInfo* variantInfo,                                               TConstObjectPtr choicePtr){    _ASSERT(!variantInfo->CanBeDelayed());    _ASSERT(variantInfo->IsInline());    _ASSERT(variantInfo->GetChoiceType()->GetIndex(choicePtr) ==            variantInfo->GetIndex());    out.WriteObject(variantInfo->GetItemPtr(choicePtr),                    variantInfo->GetTypeInfo());}void CVariantInfoFunctions::WritePointerVariant(CObjectOStream& out,                                                const CVariantInfo* variantInfo,                                                TConstObjectPtr choicePtr){    _ASSERT(!variantInfo->CanBeDelayed());    _ASSERT(variantInfo->IsNonObjectPointer());    _ASSERT(variantInfo->GetChoiceType()->GetIndex(choicePtr) ==            variantInfo->GetIndex());    TConstObjectPtr variantPtr = variantInfo->GetItemPtr(choicePtr);    variantPtr = CTypeConverter<TConstObjectPtr>::Get(variantPtr);    _ASSERT(variantPtr != 0 );    out.WriteObject(variantPtr, variantInfo->GetTypeInfo());}void CVariantInfoFunctions::WriteObjectPointerVariant(CObjectOStream& out,                                                      const CVariantInfo* variantInfo,                                                      TConstObjectPtr choicePtr){    _ASSERT(!variantInfo->CanBeDelayed());    _ASSERT(variantInfo->IsObjectPointer());    _ASSERT(variantInfo->GetChoiceType()->GetIndex(choicePtr) ==            variantInfo->GetIndex());    TConstObjectPtr variantPtr = variantInfo->GetItemPtr(choicePtr);    variantPtr = CTypeConverter<TConstObjectPtr>::Get(variantPtr);    _ASSERT(variantPtr != 0 );    out.WriteExternalObject(variantPtr, variantInfo->GetTypeInfo());}void CVariantInfoFunctions::WriteSubclassVariant(CObjectOStream& out,                                                 const CVariantInfo* variantInfo,                                                 TConstObjectPtr choicePtr){    _ASSERT(!variantInfo->CanBeDelayed());    _ASSERT(variantInfo->IsSubClass());    _ASSERT(variantInfo->GetChoiceType()->GetIndex(choicePtr) ==            variantInfo->GetIndex());    const CChoiceTypeInfo* choiceType = variantInfo->GetChoiceType();    const CChoicePointerTypeInfo* choicePtrType =        CTypeConverter<CChoicePointerTypeInfo>::SafeCast(choiceType);    TConstObjectPtr variantPtr =        choicePtrType->GetPointerTypeInfo()->GetObjectPointer(choicePtr);    _ASSERT(variantPtr);    out.WriteExternalObject(variantPtr, variantInfo->GetTypeInfo());}void CVariantInfoFunctions::WriteDelayedVariant(CObjectOStream& out,                                                const CVariantInfo* variantInfo,                                                TConstObjectPtr choicePtr){    _ASSERT(variantInfo->CanBeDelayed());    _ASSERT(variantInfo->GetChoiceType()->GetIndex(choicePtr) ==            variantInfo->GetIndex());    const CDelayBuffer& buffer = variantInfo->GetDelayBuffer(choicePtr);    if ( buffer.GetIndex() == variantInfo->GetIndex() ) {        if ( buffer.HaveFormat(out.GetDataFormat()) ) {            out.Write(buffer.GetSource());            return;        }        const_cast<CDelayBuffer&>(buffer).Update();        _ASSERT(!variantInfo->GetDelayBuffer(choicePtr));    }    TConstObjectPtr variantPtr = variantInfo->GetItemPtr(choicePtr);    if ( variantInfo->IsPointer() ) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -