hash_collections_load_imp.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef BOOST_SERIALIZATION_HASH_COLLECTIONS_LOAD_IMP_HPP
  2. #define BOOST_SERIALIZATION_HASH_COLLECTIONS_LOAD_IMP_HPP
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  5. # pragma once
  6. # pragma warning (disable : 4786) // too long name, harmless warning
  7. #endif
  8. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  9. // hash_collections_load_imp.hpp: serialization for loading stl collections
  10. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
  11. // Use, modification and distribution is subject to the Boost Software
  12. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. // See http://www.boost.org for updates, documentation, and revision history.
  15. // helper function templates for serialization of hashed collections
  16. #include <boost/config.hpp>
  17. #include <boost/serialization/nvp.hpp>
  18. #include <boost/serialization/collections_load_imp.hpp>
  19. namespace boost{
  20. namespace serialization {
  21. namespace stl {
  22. //////////////////////////////////////////////////////////////////////
  23. // implementation of serialization for STL containers
  24. //
  25. template<class Archive, class Container, class InputFunction>
  26. inline void load_hash_collection(Archive & ar, Container &s)
  27. {
  28. s.clear();
  29. // retrieve number of elements
  30. unsigned int count;
  31. unsigned int item_version(0);
  32. unsigned int bucket_count;;
  33. ar >> BOOST_SERIALIZATION_NVP(count);
  34. if(3 < ar.get_library_version()){
  35. ar >> BOOST_SERIALIZATION_NVP(bucket_count);
  36. ar >> BOOST_SERIALIZATION_NVP(item_version);
  37. }
  38. #if ! defined(__MWERKS__)
  39. s.resize(bucket_count);
  40. #endif
  41. InputFunction ifunc;
  42. while(count-- > 0){
  43. ifunc(ar, s, item_version);
  44. }
  45. }
  46. } // namespace stl
  47. } // namespace serialization
  48. } // namespace boost
  49. #endif //BOOST_SERIALIZATION_HASH_COLLECTIONS_LOAD_IMP_HPP