当前位置: 首页>>代码示例>>C++>>正文


C++ CObjectTypeInfo::FindMember方法代码示例

本文整理汇总了C++中CObjectTypeInfo::FindMember方法的典型用法代码示例。如果您正苦于以下问题:C++ CObjectTypeInfo::FindMember方法的具体用法?C++ CObjectTypeInfo::FindMember怎么用?C++ CObjectTypeInfo::FindMember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CObjectTypeInfo的用法示例。


在下文中一共展示了CObjectTypeInfo::FindMember方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv)
{
    // Create some ASN.1 data that can be parsed by this code sample.
    char asn[] = "Date-std ::= { year 1998, month 1, day 2, season \"winter\" }";

    // Setup an input stream, based on the sample ASN.1.
    CNcbiIstrstream iss(asn);
    unique_ptr<CObjectIStream> in(CObjectIStream::Open(eSerial_AsnText, iss));

    ////////////////////////////////////////////////////
    // Create a hook for the 'year' class member of Date-std objects.
    // The year class member was aribtrarily chosen to illustrate the
    // use of hooks - many other entities would work equally well.

    // Get data structures that model the type information for Date-std
    // objects and their 'year' class members.
    // The type information will be used to recognize and forward 'year'
    // class members of Date-std objects found in the stream to the hook.
    CObjectTypeInfo stdInfo = CType<CDate_std>();
    CObjectTypeInfoMI memberInfo = stdInfo.FindMember("year");

    // Set a local hook for Date-std 'year' class members.  This involves
    // creating an instance of the hook class and passing that hook to the
    // "set hook" method, which registers the hook to be called when a hooked
    // type is encountered in the stream.
    memberInfo.SetLocalReadHook(*in, new CReadCMHook_Date_std__year());

    // Read from the input stream, storing data in the object.  At this point,
    // the hook is in place so simply reading from the input stream will
    // cause the hook to be triggered whenever the 'year' class member is
    // encountered.
    in->Read(stdInfo);

    return 0;
}
开发者ID:svn2github,项目名称:ncbi_tk,代码行数:35,代码来源:hooks_commented.cpp

示例2:

CObjectHookGuardBase::CObjectHookGuardBase(const CObjectTypeInfo& info,
                                           const string& id,
                                           CSkipClassMemberHook& hook,
                                           CObjectIStream* stream)
    : m_Hook(&hook),
      m_HookMode(eHook_Skip),
      m_HookType(eHook_Member),
      m_Id(id)
{
    m_Stream.m_IStream = stream;
    CObjectTypeInfoMI member = info.FindMember(id);
    if ( stream ) {
        member.SetLocalSkipHook(*stream, &hook);
    }
}
开发者ID:svn2github,项目名称:ncbi_tk,代码行数:15,代码来源:objhook.cpp

示例3: ResetHook

void CObjectHookGuardBase::ResetHook(const CObjectTypeInfo& info)
{
    switch (m_HookType) {
    case eHook_Object:
        switch (m_HookMode) {
        case eHook_Read:
            if ( m_Stream.m_IStream ) {
                info.ResetLocalReadHook(*m_Stream.m_IStream);
            }
            else {
                info.ResetGlobalReadHook();
            }
            break;
        case eHook_Write:
            if ( m_Stream.m_OStream ) {
                info.ResetLocalWriteHook(*m_Stream.m_OStream);
            }
            else {
                info.ResetGlobalWriteHook();
            }
            break;
        case eHook_Skip:
            if ( m_Stream.m_IStream ) {
                info.ResetLocalSkipHook(*m_Stream.m_IStream);
            }
            break;
        case eHook_Copy:
            if ( m_Stream.m_Copier ) {
                info.ResetLocalCopyHook(*m_Stream.m_Copier);
            }
            else {
                info.ResetGlobalCopyHook();
            }
            break;
        default:
            break;
        }
        break;
    case eHook_Member:
    {
        CObjectTypeInfoMI member = info.FindMember(m_Id);
        switch (m_HookMode) {
        case eHook_Read:
            if ( m_Stream.m_IStream ) {
                member.ResetLocalReadHook(*m_Stream.m_IStream);
            }
            else {
                member.ResetGlobalReadHook();
            }
            break;
        case eHook_Write:
            if ( m_Stream.m_OStream ) {
                member.ResetLocalWriteHook(*m_Stream.m_OStream);
            }
            else {
                member.ResetGlobalWriteHook();
            }
            break;
        case eHook_Skip:
            if ( m_Stream.m_IStream ) {
                member.ResetLocalSkipHook(*m_Stream.m_IStream);
            }
            break;
        case eHook_Copy:
            if ( m_Stream.m_Copier ) {
                member.ResetLocalCopyHook(*m_Stream.m_Copier);
            }
            else {
                member.ResetGlobalCopyHook();
            }
            break;
        default:
            break;
        }
        break;
    }
    case eHook_Variant:
    {
        CObjectTypeInfoVI variant = info.FindVariant(m_Id);
        switch (m_HookMode) {
        case eHook_Read:
            if ( m_Stream.m_IStream ) {
                variant.ResetLocalReadHook(*m_Stream.m_IStream);
            }
            else {
                variant.ResetGlobalReadHook();
            }
            break;
        case eHook_Write:
            if ( m_Stream.m_OStream ) {
                variant.ResetLocalWriteHook(*m_Stream.m_OStream);
            }
            else {
                variant.ResetGlobalWriteHook();
            }
            break;
        case eHook_Skip:
            if ( m_Stream.m_IStream ) {
                variant.ResetLocalSkipHook(*m_Stream.m_IStream);
            }
//.........这里部分代码省略.........
开发者ID:svn2github,项目名称:ncbi_tk,代码行数:101,代码来源:objhook.cpp


注:本文中的CObjectTypeInfo::FindMember方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。