
Kim Barrett wrote:
At 9:13 AM +0800 7/10/06, Joel de Guzman wrote:
Say with version 1, I want to serialize X Y and Z. These are hierarchical and expensive data structures. Now, with version 2, I do not need to create Y objects anymore. Yet, I still have to open version 1 files for backward compatibility. So, when loading version 1 files, I want to skip reading Y objects. How do I do that without having to create a temporary Y object that will be discarded later?
(I'm particularly interested with XML archives. If I had control over the xml parser, that would simply mean ignoring everything from the current tag until the next matching tag is found).
I think such a simple approach will not work in general. Consider the case where
1. your Y contains a pointer to P 2. pointer tracking is enabled for P's type 3. the occurrence of P in Y is the first occurrence within the archive 4. there are later occurrences of P in the archive after Y
If you simply discard everything involved in constructing Y, you will discard the information needed to construct and record P, and those later occurrences will be left dangling.
Don't worry. I know what I am doing :) Trust the programmer ;) Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net