QxSerialize_std_tuple.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /****************************************************************************
  2. **
  3. ** https://www.qxorm.com/
  4. ** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
  5. **
  6. ** This file is part of the QxOrm library
  7. **
  8. ** This software is provided 'as-is', without any express or implied
  9. ** warranty. In no event will the authors be held liable for any
  10. ** damages arising from the use of this software
  11. **
  12. ** Commercial Usage
  13. ** Licensees holding valid commercial QxOrm licenses may use this file in
  14. ** accordance with the commercial license agreement provided with the
  15. ** Software or, alternatively, in accordance with the terms contained in
  16. ** a written agreement between you and Lionel Marty
  17. **
  18. ** GNU General Public License Usage
  19. ** Alternatively, this file may be used under the terms of the GNU
  20. ** General Public License version 3.0 as published by the Free Software
  21. ** Foundation and appearing in the file 'license.gpl3.txt' included in the
  22. ** packaging of this file. Please review the following information to
  23. ** ensure the GNU General Public License version 3.0 requirements will be
  24. ** met : http://www.gnu.org/copyleft/gpl.html
  25. **
  26. ** If you are unsure which license is appropriate for your use, or
  27. ** if you have questions regarding the use of this file, please contact :
  28. ** contact@qxorm.com
  29. **
  30. ****************************************************************************/
  31. #ifdef _QX_ENABLE_BOOST_SERIALIZATION
  32. #ifndef _QX_SERIALIZE_STD_TUPLE_H_
  33. #define _QX_SERIALIZE_STD_TUPLE_H_
  34. #ifdef _MSC_VER
  35. #pragma once
  36. #endif
  37. #include <boost/serialization/serialization.hpp>
  38. #include <boost/serialization/split_free.hpp>
  39. #include <boost/serialization/nvp.hpp>
  40. namespace boost {
  41. namespace serialization {
  42. template <class Archive, typename T0, typename T1>
  43. inline void serialize(Archive & ar, std::tuple<T0, T1> & t, const unsigned int file_version)
  44. {
  45. Q_UNUSED(file_version);
  46. ar & boost::serialization::make_nvp("tuple_1", std::get<0>(t));
  47. ar & boost::serialization::make_nvp("tuple_2", std::get<1>(t));
  48. }
  49. template <class Archive, typename T0, typename T1, typename T2>
  50. inline void serialize(Archive & ar, std::tuple<T0, T1, T2> & t, const unsigned int file_version)
  51. {
  52. Q_UNUSED(file_version);
  53. ar & boost::serialization::make_nvp("tuple_1", std::get<0>(t));
  54. ar & boost::serialization::make_nvp("tuple_2", std::get<1>(t));
  55. ar & boost::serialization::make_nvp("tuple_3", std::get<2>(t));
  56. }
  57. template <class Archive, typename T0, typename T1, typename T2, typename T3>
  58. inline void serialize(Archive & ar, std::tuple<T0, T1, T2, T3> & t, const unsigned int file_version)
  59. {
  60. Q_UNUSED(file_version);
  61. ar & boost::serialization::make_nvp("tuple_1", std::get<0>(t));
  62. ar & boost::serialization::make_nvp("tuple_2", std::get<1>(t));
  63. ar & boost::serialization::make_nvp("tuple_3", std::get<2>(t));
  64. ar & boost::serialization::make_nvp("tuple_4", std::get<3>(t));
  65. }
  66. template <class Archive, typename T0, typename T1, typename T2, typename T3, typename T4>
  67. inline void serialize(Archive & ar, std::tuple<T0, T1, T2, T3, T4> & t, const unsigned int file_version)
  68. {
  69. Q_UNUSED(file_version);
  70. ar & boost::serialization::make_nvp("tuple_1", std::get<0>(t));
  71. ar & boost::serialization::make_nvp("tuple_2", std::get<1>(t));
  72. ar & boost::serialization::make_nvp("tuple_3", std::get<2>(t));
  73. ar & boost::serialization::make_nvp("tuple_4", std::get<3>(t));
  74. ar & boost::serialization::make_nvp("tuple_5", std::get<4>(t));
  75. }
  76. template <class Archive, typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
  77. inline void serialize(Archive & ar, std::tuple<T0, T1, T2, T3, T4, T5> & t, const unsigned int file_version)
  78. {
  79. Q_UNUSED(file_version);
  80. ar & boost::serialization::make_nvp("tuple_1", std::get<0>(t));
  81. ar & boost::serialization::make_nvp("tuple_2", std::get<1>(t));
  82. ar & boost::serialization::make_nvp("tuple_3", std::get<2>(t));
  83. ar & boost::serialization::make_nvp("tuple_4", std::get<3>(t));
  84. ar & boost::serialization::make_nvp("tuple_5", std::get<4>(t));
  85. ar & boost::serialization::make_nvp("tuple_6", std::get<5>(t));
  86. }
  87. template <class Archive, typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
  88. inline void serialize(Archive & ar, std::tuple<T0, T1, T2, T3, T4, T5, T6> & t, const unsigned int file_version)
  89. {
  90. Q_UNUSED(file_version);
  91. ar & boost::serialization::make_nvp("tuple_1", std::get<0>(t));
  92. ar & boost::serialization::make_nvp("tuple_2", std::get<1>(t));
  93. ar & boost::serialization::make_nvp("tuple_3", std::get<2>(t));
  94. ar & boost::serialization::make_nvp("tuple_4", std::get<3>(t));
  95. ar & boost::serialization::make_nvp("tuple_5", std::get<4>(t));
  96. ar & boost::serialization::make_nvp("tuple_6", std::get<5>(t));
  97. ar & boost::serialization::make_nvp("tuple_7", std::get<6>(t));
  98. }
  99. template <class Archive, typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
  100. inline void serialize(Archive & ar, std::tuple<T0, T1, T2, T3, T4, T5, T6, T7> & t, const unsigned int file_version)
  101. {
  102. Q_UNUSED(file_version);
  103. ar & boost::serialization::make_nvp("tuple_1", std::get<0>(t));
  104. ar & boost::serialization::make_nvp("tuple_2", std::get<1>(t));
  105. ar & boost::serialization::make_nvp("tuple_3", std::get<2>(t));
  106. ar & boost::serialization::make_nvp("tuple_4", std::get<3>(t));
  107. ar & boost::serialization::make_nvp("tuple_5", std::get<4>(t));
  108. ar & boost::serialization::make_nvp("tuple_6", std::get<5>(t));
  109. ar & boost::serialization::make_nvp("tuple_7", std::get<6>(t));
  110. ar & boost::serialization::make_nvp("tuple_8", std::get<7>(t));
  111. }
  112. template <class Archive, typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
  113. inline void serialize(Archive & ar, std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> & t, const unsigned int file_version)
  114. {
  115. Q_UNUSED(file_version);
  116. ar & boost::serialization::make_nvp("tuple_1", std::get<0>(t));
  117. ar & boost::serialization::make_nvp("tuple_2", std::get<1>(t));
  118. ar & boost::serialization::make_nvp("tuple_3", std::get<2>(t));
  119. ar & boost::serialization::make_nvp("tuple_4", std::get<3>(t));
  120. ar & boost::serialization::make_nvp("tuple_5", std::get<4>(t));
  121. ar & boost::serialization::make_nvp("tuple_6", std::get<5>(t));
  122. ar & boost::serialization::make_nvp("tuple_7", std::get<6>(t));
  123. ar & boost::serialization::make_nvp("tuple_8", std::get<7>(t));
  124. ar & boost::serialization::make_nvp("tuple_9", std::get<8>(t));
  125. }
  126. template <class Archive, typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
  127. inline void serialize(Archive & ar, std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> & t, const unsigned int file_version)
  128. {
  129. Q_UNUSED(file_version);
  130. ar & boost::serialization::make_nvp("tuple_1", std::get<0>(t));
  131. ar & boost::serialization::make_nvp("tuple_2", std::get<1>(t));
  132. ar & boost::serialization::make_nvp("tuple_3", std::get<2>(t));
  133. ar & boost::serialization::make_nvp("tuple_4", std::get<3>(t));
  134. ar & boost::serialization::make_nvp("tuple_5", std::get<4>(t));
  135. ar & boost::serialization::make_nvp("tuple_6", std::get<5>(t));
  136. ar & boost::serialization::make_nvp("tuple_7", std::get<6>(t));
  137. ar & boost::serialization::make_nvp("tuple_8", std::get<7>(t));
  138. ar & boost::serialization::make_nvp("tuple_9", std::get<8>(t));
  139. ar & boost::serialization::make_nvp("tuple_10", std::get<9>(t));
  140. }
  141. } // namespace boost
  142. } // namespace serialization
  143. #endif // _QX_SERIALIZE_STD_TUPLE_H_
  144. #endif // _QX_ENABLE_BOOST_SERIALIZATION