本文整理汇总了C++中CObjectIStream::ReadFileHeader方法的典型用法代码示例。如果您正苦于以下问题:C++ CObjectIStream::ReadFileHeader方法的具体用法?C++ CObjectIStream::ReadFileHeader怎么用?C++ CObjectIStream::ReadFileHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CObjectIStream
的用法示例。
在下文中一共展示了CObjectIStream::ReadFileHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}