I made may be a little more headways since my previous question
and now have an xml archive that appears to 'denote' the shared pointers
(see below)
To do this I found and used boost template function specifically for
shared pointers
-- a data member of myclass inheritin from std::multiset
-- TRow is the Value type of the multiset that implements 'serialize'
method
--
--
struct
{
template <typename Archive>
void serialize (Archive& ar, const unsigned int version)const
{
for(tThisClassConstIterator it=this->begin();
it!=this->end(); ++it)
{
boost::serialization::save(ar,*it,version);
}
}
tTEST_TB3
now however I do not understand how to 'deserialize this'
The basic call to
void load_table (tTEST_TB3& t, const char * filename)
{
// open the archive
std::ifstream ifs(filename);
assert(ifs.good());
boost::archive::xml_iarchive ia(ifs);
ia >> BOOST_SERIALIZATION_NVP(t);
}
does not even compile, I suspect it is because
when this 'serialize' function on tTEST_TB3 is called, now
the
boost::serialization::save(ar,*it,version);
is NOT valid, because the ar is of type iarchive, and save function
on the shared_ptr is not defined for 'iarchive', only for oarchive.
So there is another function in the same boost header file
( #include )
that defines a 'load' function for the shared ptr
However -- what I do not undestand is how to invoke this function
it seems like I have to iterate through every entry in the archive
and then call load to read it into a shared ptr?
That seems to be contrary to all the other mechanism supported by
the Serialization library.
The basic examples just say that I can take a container and just shift
it in
(or out) of Archiver -- but that does not work if the container is of
shared pointers.
That's why I went the route of iterating through every element of the
container to
serialize, and not do not undestand how to load it back.
So I need some help
(I can provide the complete example if needed)
thank you in advance
----------
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
<t class_id="0" tracking_level="0" version="0">
<px class_id="1" tracking_level="1" version="0" object_id="_0">
1245439719
1245439719
<mydate>6/19/2009 15:28:39</mydate>
<amount>33222112121.212000</amount>
</px>
<px class_id_reference="1" object_id="_1">
1245439719
1245439719
<mydate>6/19/2009 15:28:39</mydate>
<amount>33222112121.212000</amount>
</px>
<px class_id_reference="1" object_id="_2">
1245439719
1245439719
<mydate>6/19/2009 15:28:39</mydate>
<amount>33222112121.212000</amount>
</px>
<px class_id_reference="1" object_id="_3">
1245439719
1245439719
<mydate>6/19/2009 15:28:39</mydate>
<amount>33222112121.212000</amount>
</px>
<px class_id_reference="1" object_id="_4">
1245439719
1245439719
<mydate>6/19/2009 15:28:39</mydate>
<amount>33222112121.212000</amount>
</px>
<px class_id_reference="1" object_id="_5">
1245439719
1245439719
<mydate>6/19/2009 15:28:39</mydate>
<amount>33222112121.212000</amount>
</px>
<px class_id_reference="1" object_id="_6">
1245439719
1245439719
<mydate>6/19/2009 15:28:39</mydate>
<amount>33222112121.212000</amount>
</px>
<px class_id_reference="1" object_id="_7">
1245439719
1245439719
<mydate>6/19/2009 15:28:39</mydate>
<amount>33222112121.212000</amount>
</px>
<px class_id_reference="1" object_id="_8">
1245439719
1245439719
<mydate>6/19/2009 15:28:39</mydate>
<amount>33222112121.212000</amount>
</px>
<px class_id_reference="1" object_id="_9">
1245439719
1245439719
<mydate>6/19/2009 15:28:39</mydate>
<amount>33222112121.212000</amount>
</px>
</t>
--
V S P
toreason@fastmail.fm
--
http://www.fastmail.fm - Send your email first class