|
Boost : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2007-12-05 11:07:49
This would start a whole new group of additions which I would have to
maintain
and I'm already stretched beyond my limit in anycase.
If you're interested in this subject, maybe you want to start/build/maintain
/review or what ever a new directory serialization_tr1 which would have
its own set of tests and support.
I'm out of the serialization business and just about out of the archive
class business. The leaves the field wide open for someone who
want's to become a celebrity.
Robert Ramey
René Bürgel wrote:
> As this is pretty straightforward, would you mind adding the
> serialization code for this two classes to your library?
> I just adapted it from map/multimap and it works without any problems
> on gcc-4.2 for Linux on x86 and PowerPC
>
>
> #include <tr1/unordered_map>
>
> #include <boost/config.hpp>
>
> #include <boost/serialization/utility.hpp>
> #include <boost/serialization/collections_save_imp.hpp>
> #include <boost/serialization/collections_load_imp.hpp>
> #include <boost/serialization/split_free.hpp>
>
> namespace boost {
> namespace serialization {
>
> template<class Archive, class Type, class Key, class Hash, class
> Compare, class Allocator >
> inline void save(
> Archive & ar,
> const std::tr1::unordered_map<Key, Type, Hash, Compare, Allocator>
> &t, const unsigned int /* file_version */
> ){
> boost::serialization::stl::save_collection<
> Archive,
> std::tr1::unordered_map<Key, Type, Hash, Compare, Allocator>
> >(ar, t);
> }
>
> template<class Archive, class Type, class Key, class Hash, class
> Compare, class Allocator >
> inline void load(
> Archive & ar,
> std::tr1::unordered_map<Key, Type, Hash, Compare, Allocator> &t,
> const unsigned int /* file_version */
> ){
> boost::serialization::stl::load_collection<
> Archive,
> std::tr1::unordered_map<Key, Type, Hash, Compare, Allocator>,
> boost::serialization::stl::archive_input_unique<
> Archive, std::tr1::unordered_map<Key, Type, Hash, Compare,
> Allocator> >,
>
> boost::serialization::stl::no_reserve_imp<std::tr1::unordered_map<
> Key, Type, Hash, Compare, Allocator
> >
> >
> >(ar, t);
> }
>
> // split non-intrusive serialization function member into separate
> // non intrusive save/load member functions
> template<class Archive, class Type, class Key, class Hash, class
> Compare, class Allocator >
> inline void serialize(
> Archive & ar,
> std::tr1::unordered_map<Key, Type, Hash, Compare, Allocator> &t,
> const unsigned int file_version
> ){
> boost::serialization::split_free(ar, t, file_version);
> }
>
> // unordered_multimap
> template<class Archive, class Type, class Key, class Hash, class
> Compare, class Allocator >
> inline void save(
> Archive & ar,
> const std::tr1::unordered_multimap<Key, Type, Hash, Compare,
> Allocator> &t,
> const unsigned int /* file_version */
> ){
> boost::serialization::stl::save_collection<
> Archive,
> std::tr1::unordered_multimap<Key, Type, Hash, Compare,
> Allocator> >(ar, t);
> }
>
> template<class Archive, class Type, class Key, class Hash, class
> Compare, class Allocator >
> inline void load(
> Archive & ar,
> std::tr1::unordered_multimap<Key, Type, Hash, Compare, Allocator>
> &t, const unsigned int /* file_version */
> ){
> boost::serialization::stl::load_collection<
> Archive,
> std::tr1::unordered_multimap<Key, Type, Hash, Compare,
> Allocator>, boost::serialization::stl::archive_input_multi<
> Archive, std::tr1::unordered_multimap<Key, Type, Hash,
> Compare, Allocator>
> >,
> boost::serialization::stl::no_reserve_imp<
> std::tr1::unordered_multimap<Key, Type, Hash, Compare,
> Allocator>
> >
> >(ar, t);
> }
>
> // split non-intrusive serialization function member into separate
> // non intrusive save/load member functions
> template<class Archive, class Type, class Key, class Hash, class
> Compare, class Allocator >
> inline void serialize(
> Archive & ar,
> std::tr1::unordered_multimap<Key, Type, Hash, Compare, Allocator>
> &t, const unsigned int file_version
> ){
> boost::serialization::split_free(ar, t, file_version);
> }
>
> } // serialization
> } // namespace boost
>
>
> Thanks in advance,
>
> René Bürgel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk