winkle
asked on
Serialization Problem
I have a CObject based class that I'm serializing. Some of my files do not get read back in properly. They generate a bad format error. What appears to be happening is that certain data sets write out 0x0d characters. (I have two test files. One is always fine the other always fails. But the data is fine in both cases. I see no differences.) This is throwing thing off when I load the data back in. I've stepped through the storing process and the data is fine.
Has anyone run into anything similar? I'm at a loss as to what could be causing this. And I'm wondering if there are other things I should be checking that I'm unaware of.
Here's my Serialization function:
void CSenseInformation::Seriali ze( CArchive& ar)
{
BOOL tag = FALSE;
ar.SerializeClass(RUNTIME_ CLASS(CSen seInformat ion));
CObject::Serialize(ar);
if (ar.IsStoring()) {
ar << m_currSense << m_fileSense << m_fileDef;
ar << m_currSenseNum << m_deriveFlag;
ar << m_currSenseBase;
} else { // loading, not storing
UINT nSchema = ar.GetObjectSchema();
switch (nSchema) {
case 0:
case 1:
ar >> m_currSense >> m_fileSense >> m_fileDef;
ar >> m_currSenseNum >> m_deriveFlag;
ar >> m_currSenseBase;
break;
default:
AfxThrowArchiveException(C ArchiveExc eption::ba dSchema);
break;
} // switch
}
}
Has anyone run into anything similar? I'm at a loss as to what could be causing this. And I'm wondering if there are other things I should be checking that I'm unaware of.
Here's my Serialization function:
void CSenseInformation::Seriali
{
BOOL tag = FALSE;
ar.SerializeClass(RUNTIME_
CObject::Serialize(ar);
if (ar.IsStoring()) {
ar << m_currSense << m_fileSense << m_fileDef;
ar << m_currSenseNum << m_deriveFlag;
ar << m_currSenseBase;
} else { // loading, not storing
UINT nSchema = ar.GetObjectSchema();
switch (nSchema) {
case 0:
case 1:
ar >> m_currSense >> m_fileSense >> m_fileDef;
ar >> m_currSenseNum >> m_deriveFlag;
ar >> m_currSenseBase;
break;
default:
AfxThrowArchiveException(C
break;
} // switch
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER