/**************************************************************************** ** ** https://www.qxorm.com/ ** Copyright (C) 2013 Lionel Marty (contact@qxorm.com) ** ** This file is part of the QxOrm library ** ** This software is provided 'as-is', without any express or implied ** warranty. In no event will the authors be held liable for any ** damages arising from the use of this software ** ** Commercial Usage ** Licensees holding valid commercial QxOrm licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Lionel Marty ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file 'license.gpl3.txt' included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met : http://www.gnu.org/copyleft/gpl.html ** ** If you are unsure which license is appropriate for your use, or ** if you have questions regarding the use of this file, please contact : ** contact@qxorm.com ** ****************************************************************************/ #ifdef _QX_ENABLE_BOOST_SERIALIZATION #ifndef _QX_SERIALIZE_INVOKER_H_ #define _QX_SERIALIZE_INVOKER_H_ #ifdef _MSC_VER #pragma once #endif #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:4996) #pragma warning(disable:4094) #endif // _MSC_VER #include #include #include #include #include #include namespace qx { namespace serialization { namespace detail { template struct base_class { template static inline void save(Archive & ar, const T & t, const unsigned int file_version) { Q_UNUSED(file_version); static_assert(qx::trait::is_qx_registered::value, "qx::trait::is_qx_registered::value"); const char * sTag = QxClass::getSingleton()->getNamePtr(); ar << boost::serialization::make_nvp(sTag, boost::serialization::base_object(t)); } template static inline void load(Archive & ar, T & t, const unsigned int file_version) { Q_UNUSED(file_version); static_assert(qx::trait::is_qx_registered::value, "qx::trait::is_qx_registered::value"); const char * sTag = QxClass::getSingleton()->getNamePtr(); ar >> boost::serialization::make_nvp(sTag, boost::serialization::base_object(t)); } }; template <> struct base_class { template static inline void save(Archive & ar, const T & t, const unsigned int file_version) { Q_UNUSED(ar); Q_UNUSED(t); Q_UNUSED(file_version); } template static inline void load(Archive & ar, T & t, const unsigned int file_version) { Q_UNUSED(ar); Q_UNUSED(t); Q_UNUSED(file_version); } }; template void save(Archive & ar, const T & t, const unsigned int file_version) { typedef typename qx::trait::get_base_class::type qx_type_base_class_tmp; qx::serialization::detail::base_class::save(ar, t, file_version); QxClass::getSingleton()->dataMemberX()->toArchive(& t, ar, file_version); } template void load(Archive & ar, T & t, const unsigned int file_version) { typedef typename qx::trait::get_base_class::type qx_type_base_class_tmp; qx::serialization::detail::base_class::load(ar, t, file_version); QxClass::getSingleton()->dataMemberX()->fromArchive(& t, ar, file_version); } template struct saver { static inline void invoke(Archive & ar, const T & t, const unsigned int file_version) { qx::serialization::detail::save(ar, t, file_version); } }; template struct loader { static inline void invoke(Archive & ar, T & t, const unsigned int file_version) { qx::serialization::detail::load(ar, t, file_version); } }; } // namespace detail } // namespace serialization } // namespace qx #include "../../inl/QxSerialize/QxSerializeInvoker.inl" #ifdef _MSC_VER #pragma warning(pop) #endif // _MSC_VER #endif // _QX_SERIALIZE_INVOKER_H_ #endif // _QX_ENABLE_BOOST_SERIALIZATION