string.hpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef BOOST_SERIALIZATION_STRING_HPP
  2. #define BOOST_SERIALIZATION_STRING_HPP
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  5. # pragma once
  6. #endif
  7. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  8. // serialization/string.hpp:
  9. // serialization for stl string templates
  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. #include <string>
  16. #include <boost/config.hpp>
  17. #include <boost/serialization/level.hpp>
  18. BOOST_CLASS_IMPLEMENTATION(std::string, boost::serialization::primitive_type)
  19. #ifndef BOOST_NO_STD_WSTRING
  20. BOOST_CLASS_IMPLEMENTATION(std::wstring, boost::serialization::primitive_type)
  21. #endif
  22. // left over from a previous incarnation - strings are now always primitive types
  23. #if 0
  24. #include <string>
  25. #include <boost/serialization/collections_save_imp.hpp>
  26. #include <boost/serialization/collections_load_imp.hpp>
  27. #include <boost/serialization/split_free.hpp>
  28. namespace boost {
  29. namespace serialization {
  30. // basic_string - general case
  31. template<class Archive, class U, class Allocator>
  32. inline void save(
  33. Archive & ar,
  34. const std::basic_string<U, Allocator> &t,
  35. const unsigned int file_version
  36. ){
  37. boost::serialization::stl::save_collection<
  38. Archive, std::basic_string<U, Allocator>
  39. >(ar, t);
  40. }
  41. template<class Archive, class U, class Allocator>
  42. inline void load(
  43. Archive & ar,
  44. std::basic_string<U, Allocator> &t,
  45. const unsigned int file_version
  46. ){
  47. boost::serialization::stl::load_collection<
  48. Archive,
  49. std::basic_string<U, Allocator>,
  50. boost::serialization::stl::archive_input_seq<
  51. Archive,
  52. std::basic_string<U, Allocator>
  53. >,
  54. boost::serialization::stl::reserve_imp<
  55. std::basic_string<U, Allocator>
  56. >
  57. >(ar, t);
  58. }
  59. // split non-intrusive serialization function member into separate
  60. // non intrusive save/load member functions
  61. template<class Archive, class U, class Allocator>
  62. inline void serialize(
  63. Archive & ar,
  64. std::basic_string<U, Allocator> & t,
  65. const unsigned int file_version
  66. ){
  67. boost::serialization::split_free(ar, t, file_version);
  68. }
  69. } // serialization
  70. } // namespace boost
  71. #include <boost/serialization/collection_traits.hpp>
  72. BOOST_SERIALIZATION_COLLECTION_TRAITS(std::vector)
  73. #endif
  74. #endif // BOOST_SERIALIZATION_STRING_HPP