Boost logo

Boost Users :

From: Devin Fallak (dmfallak_at_[hidden])
Date: 2006-11-10 16:32:04


Robert Ramey <ramey <at> rrsd.com> writes:

> ... snip ...
>
> template<class Archive>
> void save(Archive &ar, const unsigned int version){
> ar << make_nvp("size", my_list::size());
> std::list::const_iterator litr = my_list.begin();
> for(unsigned i = my_list::size(); --i; i > 0){
> ar << make_nvp("list_element", *litr++);
> }
> }
> ... load...
> };
>
> Robert Ramey
>
> ... snip ...

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.

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. I've tried an
implementation which loads objects until exceptions are caught, but this
implementation crashes upon receiving a stream_error exception.

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?

Thanks for the help,

Devin


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