Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2006-11-10 17:34:05


> Thanks for the quick reply. That approach was what I also had thought
> at first, but the length of the list is not necessarily a defined
> member in all the XML files, and they are often generated by another
> application without the size member.

In this case its extremely unlikely that they will be loadable by the
serialization library at all. The serialization library includes support
for std::list. Other list classes aren't included - you'll have to roll
your own serialization for anything not included in the library.

> This is fine for saving but a problem for loading because the for
> loop has no way of knowing how many elements to load into the list.

Then there will have to be SOME way to know when to stop loading
the list items. perhaps special "end element".

> I've tried an implementation which loads objects until exceptions are
> caught, but this implementation crashes upon receiving a stream_error
> exception.

Depending on an exception is an extremely bad idea. There is no way
to know what kind of exception would occur. and how would you detect
a "real" exception from one of these "special" ones.

> Is it possible that after the archive reads an object and generates
> the exception, it doesn't 'rewind' to the position before the
> offending object? If so, is there a way to make it do this?

It doesn't "rewind". By the time you've caught the exception,
the data stream has been read.

Basically I think you have to think some more about whatyou really want to
do.

If you have your own list, that's ok. but you'll have to include
information
and/or functions on how to know how many elements to read. This is
not really a serialization library question. The same issues would arise
when reading any collection from a stream.

Robert Ramey


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net