C.hpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef BOOST_SERIALIZATION_TEST_A_HPP
  2. #define BOOST_SERIALIZATION_TEST_A_HPP
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER)
  5. # pragma once
  6. #endif
  7. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  8. // C.hpp
  9. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
  10. // Use, modification and distribution is subject to the Boost Software
  11. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. // See http://www.boost.org for updates, documentation, and revision history.
  14. #include <boost/config.hpp>
  15. #include <boost/serialization/traits.hpp>
  16. #include <boost/serialization/split.hpp>
  17. #include "B.hpp"
  18. ///////////////////////////////////////////////////////
  19. // Contained class
  20. class C
  21. {
  22. private:
  23. friend class boost::serialization::access;
  24. template<class Archive>
  25. void save(Archive &ar, boost::archive::version_type file_version) const;
  26. template<class Archive>
  27. void load(Archive & ar, boost::archive::version_type file_version);
  28. BOOST_SERIALIZATION_MEMBER_SPLIT()
  29. B b;
  30. public:
  31. bool operator==(const C &rhs) const;
  32. };
  33. BOOST_CLASS_VERSION(C, 1)
  34. inline bool C::operator==(const C &rhs) const
  35. {
  36. return b == rhs.b;
  37. }
  38. template<class Archive>
  39. inline void save(Archive &ar, boost::archive::version_type file_version) const
  40. {
  41. ar << b;
  42. }
  43. template<class Archive>
  44. inline void load(Archive & ar, boost::archive::version_type file_version){
  45. {
  46. switch(file_version){
  47. case 1:
  48. ar >> b;
  49. break;
  50. case 2:
  51. default:
  52. assert(false);
  53. break;
  54. }
  55. }
  56. #endif // BOOST_SERIALIZATION_TEST_C_HPP