QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches
QxBoostSerializeRegisterHelper.h
Go to the documentation of this file.
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
32#ifdef _QX_ENABLE_BOOST_SERIALIZATION
33#ifndef _QX_BOOST_SERIALIZE_REGISTER_HELPER_H_
34#define _QX_BOOST_SERIALIZE_REGISTER_HELPER_H_
35
36#ifdef _MSC_VER
37#pragma once
38#endif
39
42
43#define QX_BOOST_SERIALIZE_REGISTER_HELPER_IMPLEMENT_VIRTUAL_ARCHIVE(ArchiveIn, ArchiveOut) \
44virtual void helper(ArchiveIn & ar) const { private_helper(ar); } \
45virtual void helper(ArchiveOut & ar) const { private_helper(ar); }
46
47namespace qx {
48
49template <class T>
51{
52
53public:
54
57
58 virtual void helper() const { private_helper(); }
59
60#if _QX_SERIALIZE_POLYMORPHIC
61 QX_BOOST_SERIALIZE_REGISTER_HELPER_IMPLEMENT_VIRTUAL_ARCHIVE(boost::archive::polymorphic_iarchive, boost::archive::polymorphic_oarchive)
62#endif // _QX_SERIALIZE_POLYMORPHIC
63
64#if _QX_SERIALIZE_BINARY
65 QX_BOOST_SERIALIZE_REGISTER_HELPER_IMPLEMENT_VIRTUAL_ARCHIVE(boost::archive::binary_iarchive, boost::archive::binary_oarchive)
66#endif // _QX_SERIALIZE_BINARY
67
68#if _QX_SERIALIZE_TEXT
69 QX_BOOST_SERIALIZE_REGISTER_HELPER_IMPLEMENT_VIRTUAL_ARCHIVE(boost::archive::text_iarchive, boost::archive::text_oarchive)
70#endif // _QX_SERIALIZE_TEXT
71
72#if _QX_SERIALIZE_XML
73 QX_BOOST_SERIALIZE_REGISTER_HELPER_IMPLEMENT_VIRTUAL_ARCHIVE(boost::archive::xml_iarchive, boost::archive::xml_oarchive)
74#endif // _QX_SERIALIZE_XML
75
76#if _QX_SERIALIZE_PORTABLE_BINARY
78#endif // _QX_SERIALIZE_PORTABLE_BINARY
79
80#if _QX_SERIALIZE_WIDE_BINARY
81 QX_BOOST_SERIALIZE_REGISTER_HELPER_IMPLEMENT_VIRTUAL_ARCHIVE(boost::archive::binary_wiarchive, boost::archive::binary_woarchive)
82#endif // _QX_SERIALIZE_WIDE_BINARY
83
84#if _QX_SERIALIZE_WIDE_TEXT
85 QX_BOOST_SERIALIZE_REGISTER_HELPER_IMPLEMENT_VIRTUAL_ARCHIVE(boost::archive::text_wiarchive, boost::archive::text_woarchive)
86#endif // _QX_SERIALIZE_WIDE_TEXT
87
88#if _QX_SERIALIZE_WIDE_XML
89 QX_BOOST_SERIALIZE_REGISTER_HELPER_IMPLEMENT_VIRTUAL_ARCHIVE(boost::archive::xml_wiarchive, boost::archive::xml_woarchive)
90#endif // _QX_SERIALIZE_WIDE_XML
91
92private:
93
94 template <class Archive>
95 inline void private_helper(Archive & ar) const
96 {
99 qx::QxBoostSerializeHelper<T>::init_guid(static_cast<T *>(NULL));
100 }
101
102 inline void private_helper() const
103 {
105 qx::QxBoostSerializeHelper<T>::init_guid(static_cast<T *>(NULL));
106 }
107
108};
109
110} // namespace qx
111
112#if _QX_USE_BOOST_SERIALIZE_REGISTER_HELPER
113#define QX_REGISTER_BOOST_SERIALIZE_HELPER_COMPLEX_CLASS_NAME(className, classNameFormatted) \
114extern qx::QxBoostSerializeRegisterHelper< className > G_QX_REGISTER_BOOST_SERIALIZE_HELPER_##classNameFormatted;
115#define QX_REGISTER_BOOST_SERIALIZE_HELPER(className) \
116QX_REGISTER_BOOST_SERIALIZE_HELPER_COMPLEX_CLASS_NAME(className, className)
117#else
118#define QX_REGISTER_BOOST_SERIALIZE_HELPER_COMPLEX_CLASS_NAME(className, classNameFormatted) /* Nothing */
119#define QX_REGISTER_BOOST_SERIALIZE_HELPER(className) /* Nothing */
120#endif // _QX_USE_BOOST_SERIALIZE_REGISTER_HELPER
121
122#if _QX_USE_BOOST_SERIALIZE_REGISTER_HELPER
123#define QX_REGISTER_BOOST_SERIALIZE_HELPER_COMPLEX_CLASS_NAME_CPP(className, classNameFormatted) \
124qx::QxBoostSerializeRegisterHelper< className > G_QX_REGISTER_BOOST_SERIALIZE_HELPER_##classNameFormatted(QString(#className));
125#define QX_REGISTER_BOOST_SERIALIZE_HELPER_CPP(className) \
126QX_REGISTER_BOOST_SERIALIZE_HELPER_COMPLEX_CLASS_NAME_CPP(className, className)
127#else
128#define QX_REGISTER_BOOST_SERIALIZE_HELPER_COMPLEX_CLASS_NAME_CPP(className, classNameFormatted) /* Nothing */
129#define QX_REGISTER_BOOST_SERIALIZE_HELPER_CPP(className) /* Nothing */
130#endif // _QX_USE_BOOST_SERIALIZE_REGISTER_HELPER
131
132#endif // _QX_BOOST_SERIALIZE_REGISTER_HELPER_H_
133#endif // _QX_ENABLE_BOOST_SERIALIZATION
#define QX_BOOST_SERIALIZE_REGISTER_HELPER_IMPLEMENT_VIRTUAL_ARCHIVE(ArchiveIn, ArchiveOut)
Portable binary input archive using little endian format.
Portable binary output archive using little endian format.
static void register_type_helper(Archive &ar, const T *t)
static void void_cast_register_helper(const T *t)
static void init_guid(const T *t)
Root namespace for all QxOrm library features.