|
Boost Users : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2006-11-10 16:04:16
I'm not sure what the problem is with having an std::list have its own NVP
but you can easily handle tihs yourself without using the definition of
std::list serialization included in the package.
class my_class {
std::list<int> my_list;
// instead of the following
template<class Archive>
void serialize(Archive &ar, const unsigned int version){
ar & BOOST_SERIALZATION_NVP(my_list)
}
// do the fillowing
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
Devin Fallak wrote:
> Hi all,
>
> I'm working with the Serialization library and trying to output a
> list of objects into an XML file. The problem I'm having is that in
> serializing a std::list, the Serialization library requires that the
> list itself is given a NVP. The specification I'm working with
> requires a list of undefined length WITHOUT its own NVP.
>
> Is there any way to serialize a std::list into/out of an
> xml_oarchive/xml_iarchive?
>
> Any help would be much appreciated.
>
> Thanks,
>
> Devin Fallak
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