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


C++ CObjectIStream::SetStreamPos方法代码示例

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


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

示例1: object_info

void CObjectsSniffer::ProbeASN1_Bin(CObjectIStream& input)
{
    TCandidates::const_iterator last_cand = m_Candidates.end();
    for ( ;; ) {
        m_StreamPos = input.GetStreamPos();

        if ( last_cand != m_Candidates.end() ) {
            // Check the previously found candidate first
            // (performance optimization)
            try {
                TCandidates::const_iterator it = last_cand;
                CObjectInfo object_info(it->type_info.GetTypeInfo());
                input.Read(object_info);
                m_TopLevelMap.push_back(
                    SObjectDescription(it->type_info, m_StreamPos));
                _TRACE("Same type ASN.1 binary top level object found:" 
                       << it->type_info.GetTypeInfo()->GetName());
                continue;
            }
            catch ( CEofException& ) {
                // no more objects
                return;
            }
            catch ( exception& ) {
                Reset();
                input.SetStreamPos(m_StreamPos);
            }
        }

        bool found = false;
        // Scan through all candidates
        ITERATE ( TCandidates, it, m_Candidates ) {
            if ( it == last_cand ) {
                // already tried
                continue;
            }
            try {
                CObjectInfo object_info(it->type_info.GetTypeInfo());
                input.Read(object_info);
                found = true;
                last_cand = it;
                m_TopLevelMap.push_back(
                    SObjectDescription(it->type_info, m_StreamPos));
                LOG_POST_X(2, Info 
                           << "ASN.1 binary top level object found:" 
                           << it->type_info.GetTypeInfo()->GetName());
                break;
            }
            catch ( CEofException& ) {
                // no more objects
                return;
            }
            catch ( exception& ) {
                Reset();
                input.SetStreamPos(m_StreamPos);
            }
        }
        if ( !found ) {
            // no matching candidate
            break;
        }
    } // while
}
开发者ID:swuecho,项目名称:igblast,代码行数:63,代码来源:obj_sniff.cpp

示例2: ProbeText

void CObjectsSniffer::ProbeText(CObjectIStream& input)
{
    TCandidates::const_iterator last_cand = m_Candidates.end();

    string format_name;  // for LOG_POST messages
    if (input.GetDataFormat() == eSerial_AsnText) {
        format_name = "ASN.1 text";
    } else {
        format_name = "XML";
    }

    try {
        while (true) {
            m_StreamPos = input.GetStreamPos();
            string header = input.ReadFileHeader();

            if ( last_cand != m_Candidates.end() ) {
                // Check the previously found candidate first
                // (performance optimization)
                if (header == last_cand->type_info.GetTypeInfo()->GetName()) {
                    TCandidates::const_iterator it = last_cand;
                    CObjectInfo object_info(it->type_info.GetTypeInfo());
                    input.Read(object_info, CObjectIStream::eNoFileHeader);
                    m_TopLevelMap.push_back(
                        SObjectDescription(it->type_info, m_StreamPos));

                    _TRACE("Same type "
                           << format_name << " top level object found:" 
                           << it->type_info.GetTypeInfo()->GetName());
                    continue;
                }
            }

            bool found = false;
            // Scan through all candidates
            ITERATE ( TCandidates, it, m_Candidates ) {
                if ( header == it->type_info.GetTypeInfo()->GetName() ) {
                    CObjectInfo object_info(it->type_info.GetTypeInfo());
                    input.Read(object_info, CObjectIStream::eNoFileHeader);
                    found = true;
                    last_cand = it;
                    m_TopLevelMap.push_back(
                        SObjectDescription(it->type_info, m_StreamPos));

                    LOG_POST_X(2, Info 
                                << format_name << " top level object found:" 
                                << it->type_info.GetTypeInfo()->GetName());
                    break;
                }
            } // for
            if ( !found ) {
                input.SetStreamPos(m_StreamPos);
                return;
            }
        } // while
    }
    catch (CEofException& /*ignored*/) {
    }
    catch (exception& e) {
        LOG_POST_X(3, Info << "Exception reading "
                   << format_name << " " << e.what());
        input.SetStreamPos(m_StreamPos);
    }
}
开发者ID:swuecho,项目名称:igblast,代码行数:64,代码来源:obj_sniff.cpp


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