本文整理汇总了C++中CObjectIStream::GetStreamPos方法的典型用法代码示例。如果您正苦于以下问题:C++ CObjectIStream::GetStreamPos方法的具体用法?C++ CObjectIStream::GetStreamPos怎么用?C++ CObjectIStream::GetStreamPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CObjectIStream
的用法示例。
在下文中一共展示了CObjectIStream::GetStreamPos方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadObject
void COffsetReadHook::ReadObject(CObjectIStream &in,
const CObjectInfo &object)
{
CCallStackGuard guard(m_Sniffer->m_CallStack, object);
if (m_EventMode == CObjectsSniffer::eCallAlways) {
// Clear the discard flag before calling sniffer's event reactors
m_Sniffer->SetDiscardCurrObject(false);
m_Sniffer->OnObjectFoundPre(object, in.GetStreamPos());
DefaultRead(in, object);
m_Sniffer->OnObjectFoundPost(object);
// Relay discard flag to the stream
bool discard = m_Sniffer->GetDiscardCurrObject();
in.SetDiscardCurrObject(discard);
}
else {
if (m_EventMode == CObjectsSniffer::eSkipObject) {
DefaultSkip(in, object);
}
else {
DefaultRead(in, object);
}
}
}
示例2: 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
}
示例3: 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);
}
}