|
-
May 5th, 1999, 02:45 AM
#1
Serialize
Hello there!
Would it be possible to get the following items clarified?
Class Schema Number
It seems not possible to get the class Schema Number behave as specified in the C++ documentation (versions 4 and 6).
The class Schema Number seems to be:
common to all different classes being serialised, despite that a specific Schema Number can be defined for each class through the IMPLEMENT_SERIAL macro
neither stored to nor read from permanent storage (just initialised to -1 during the construction of the CArchive object)
Are the above considerations correct or is there some parameter to be set in the compiler, project, etc.?
Object::Serialise
Currently Object::Serialise does nothing.
Is it worth keeping it into the code as recommended by the documentation?
Is there some planned use? If yes, what about compatibility with old objects?
Thanks for your prompt reply, Nicola
-
May 5th, 1999, 04:21 PM
#2
Re: Serialize
First, make sure the object you are trying to serialize is derived from CObject.
Second,use the GetObjectSchema() and SetObjectSchema() methods of CArchive.
SO, something like this:
void CMyObject::Serialize(CArcive& ar)
{
if(ar.IsLoading())
{
int nSchemaVersion = ar.GetObjectSchema();
int nData = 0;
switch(nSchemaVersion)
{
case 0:
ar >> nData;
break;
case 1:
// etc...
}
}
else
{
ar << nData;
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|