扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
在本页阅读全文(共2页)
// assumes initialized to 0 map
{
// save out index of already stored object
if (nObIndex < wBigObjectTag)
*this << (WORD)nObIndex;
else
{
*this << wBigObjectTag;
*this << nObIndex;
}
}
else
{
// write class of object first
CRuntimeClass* pClassRef = pOb-> GetRuntimeClass();
WriteClass(pClassRef); //写入运行类信息
// enter in stored object table, checking for overflow
CheckCount();
(*m_pStoreMap)[(void*)pOb] = (void*)m_nMapCount++;
// 调用CObject的Serialize成员,按其中的代码写入类中数据。
((CObject*)pOb)-> Serialize(*this);
}
}
CObject* CArchive::ReadObject(const CRuntimeClass* pClassRefRequested)
{
// attempt to load next stream as CRuntimeClass
UINT nSchema;
DWORD obTag;
//先读入运行时类信息
CRuntimeClass* pClassRef = ReadClass(pClassRefRequested, &nSchema, &obTag);
// check to see if tag to already loaded object
CObject* pOb;
if (pClassRef == NULL)
{
if (obTag > (DWORD)m_pLoadArray-> GetUpperBound())
{
// tag is too large for the number of objects read so far
AfxThrowArchiveException(CArchiveException::badIndex,
m_strFileName);
}
pOb = (CObject*)m_pLoadArray-> GetAt(obTag);
if (pOb != NULL && pClassRefRequested != NULL &&
!pOb-> IsKindOf(pClassRefRequested))
{
// loaded an object but of the wrong class
AfxThrowArchiveException(CArchiveException::badClass,
m_strFileName);
}
}
else
{
// 建立对象
pOb = pClassRef-> CreateObject();
if (pOb == NULL)
AfxThrowMemoryException();
// Add to mapping array BEFORE de-serializing
CheckCount();
m_pLoadArray-> InsertAt(m_nMapCount++, pOb);
// Serialize the object with the schema number set in the archive
UINT nSchemaSave = m_nObjectSchema;
m_nObjectSchema = nSchema;
pOb-> Serialize(*this); //调用CObject的Serialize,按其中代码读入对象数据。
m_nObjectSchema = nSchemaSave;
ASSERT_VALID(pOb);
}
return pOb;
}
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者