Link to home
Start Free TrialLog in
Avatar of Tomers
Tomers

asked on

Serialization with version

I added a data member to a class that had a Serialize() function. The Serialize() function didn't support versioning. Now I want to serialize the new data member but to be compatible with previous serializaions.
My class has DECLARE_SERIAL(...) and IMPLEMENT_SERIAL(...,...,VERSIONABLE_SCHEMA|1) but when I use the function CArchive::GetObjectSchema() I always get -1.
I can't distinguish between old versions and new ones.
The class I serialize is an item in a CMap object that I serialize in another class.
How can I distinguish the different versions?
Thanks, Tomer
ASKER CERTIFIED SOLUTION
Avatar of naveenkohli
naveenkohli

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tomers
Tomers

ASKER

The answer I got was like what I already read in the VC++ documents. The problem
is it didn't work, maybe because it was items in a CMap.
Anyway I solved it by trying to read it once with 3 arguments and if I encounter an
exception, I close the archive and open it again trying to read 2 arguments.