void SerializeClass( const CRuntimeClass* pRuntimeClass );
Parameters
pRuntimeClass
A pointer to a run-time class object for the base class.
Remarks
Call this member function when you want to store and load the version information of a base class. SerializeClass reads or writes the reference to a class to the CArchive object, depending on the direction of the CArchive. Use SerializeClass in place of ReadClass and WriteClass as a convenient way to serialize base-class objects; SerializeClass requires less code and fewer parameters.
Like ReadClass, SerializeClass verifies that the archived class information is compatible with your runtime class. If it is not compatible, SerializeClass will throw a CArchiveException.
Your runtime class must use DECLARE_SERIAL and IMPLEMENT_SERIAL; otherwise, SerializeClass will throw a CNotSupportedException.
Use the RUNTIME_CLASS macro to retrieve the value for the pRuntimeClass parameter. The base class must have used the IMPLEMENT_SERIAL macro.
Example
class CBaseClass : public CObject { ... };
class CDerivedClass : public CBaseClass { ... };
void CDerivedClass::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
//normal code for storing contents
//of this object
}
else
{
//normal code for reading contents
//of this object
}
//allow the base class to serialize along
//with its version information
ar.SerializeClass(RUNTIME_CLASS(CBaseClass));
CBaseClass::Serialize(ar);
}
CArchive Overview | Class Members | Hierarchy Chart
See Also CArchive::ReadClass, CArchive::WriteClass, CArchive::GetObjectSchema, CArchive::SetObjectSchema, CArchiveException, CNotSupportedException