![]() |
QxOrm
1.4.3
C++ Object Relational Mapping library
|
00001 /**************************************************************************** 00002 ** 00003 ** http://www.qxorm.com/ 00004 ** Copyright (C) 2013 Lionel Marty (contact@qxorm.com) 00005 ** 00006 ** This file is part of the QxOrm library 00007 ** 00008 ** This software is provided 'as-is', without any express or implied 00009 ** warranty. In no event will the authors be held liable for any 00010 ** damages arising from the use of this software 00011 ** 00012 ** Commercial Usage 00013 ** Licensees holding valid commercial QxOrm licenses may use this file in 00014 ** accordance with the commercial license agreement provided with the 00015 ** Software or, alternatively, in accordance with the terms contained in 00016 ** a written agreement between you and Lionel Marty 00017 ** 00018 ** GNU General Public License Usage 00019 ** Alternatively, this file may be used under the terms of the GNU 00020 ** General Public License version 3.0 as published by the Free Software 00021 ** Foundation and appearing in the file 'license.gpl3.txt' included in the 00022 ** packaging of this file. Please review the following information to 00023 ** ensure the GNU General Public License version 3.0 requirements will be 00024 ** met : http://www.gnu.org/copyleft/gpl.html 00025 ** 00026 ** If you are unsure which license is appropriate for your use, or 00027 ** if you have questions regarding the use of this file, please contact : 00028 ** contact@qxorm.com 00029 ** 00030 ****************************************************************************/ 00031 00032 #ifndef _QX_DATA_MEMBER_QOBJECT_H_ 00033 #define _QX_DATA_MEMBER_QOBJECT_H_ 00034 00035 #ifdef _MSC_VER 00036 #pragma once 00037 #endif 00038 00046 #include <QtCore/qmetaobject.h> 00047 #include <QtCore/qmetatype.h> 00048 00049 #include <QxDataMember/IxDataMember.h> 00050 00051 #include <QxSerialize/Qt/QxSerialize_QString.h> 00052 #include <QxSerialize/Qt/QxSerialize_QVariant.h> 00053 00054 #define QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(ArchiveInput, ArchiveOutput) \ 00055 virtual void toArchive(const void * pOwner, ArchiveOutput & ar) const; \ 00056 virtual void fromArchive(void * pOwner, ArchiveInput & ar); 00057 00058 namespace qx { 00059 00064 class QX_DLL_EXPORT QxDataMember_QObject : public IxDataMember 00065 { 00066 00067 protected: 00068 00069 const QMetaObject * m_metaObject; 00070 QMetaProperty m_metaProperty; 00071 00072 public: 00073 00074 QxDataMember_QObject(const QMetaObject * pMetaObject, const QString & sKey); 00075 virtual ~QxDataMember_QObject() { ; } 00076 00077 virtual bool isEqual(const void * pOwner1, const void * pOwner2) const; 00078 virtual QString toString(const void * pOwner, const QString & sFormat, int iIndexName = -1) const; 00079 virtual qx_bool fromString(void * pOwner, const QString & s, const QString & sFormat, int iIndexName = -1); 00080 virtual QVariant toVariant(const void * pOwner, const QString & sFormat, int iIndexName = -1, qx::cvt::context::ctx_type ctx = qx::cvt::context::e_no_context) const; 00081 virtual qx_bool fromVariant(void * pOwner, const QVariant & v, const QString & sFormat, int iIndexName = -1, qx::cvt::context::ctx_type ctx = qx::cvt::context::e_no_context); 00082 00083 #ifndef _QX_NO_JSON 00084 virtual QJsonValue toJson(const void * pOwner, const QString & sFormat) const; 00085 virtual qx_bool fromJson(void * pOwner, const QJsonValue & j, const QString & sFormat); 00086 #endif // _QX_NO_JSON 00087 00088 public: 00089 00090 #ifdef _QX_ENABLE_BOOST_SERIALIZATION 00091 00092 #if _QX_SERIALIZE_POLYMORPHIC 00093 QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::polymorphic_iarchive, boost::archive::polymorphic_oarchive) 00094 #endif // _QX_SERIALIZE_POLYMORPHIC 00095 00096 #if _QX_SERIALIZE_BINARY 00097 QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::binary_iarchive, boost::archive::binary_oarchive) 00098 #endif // _QX_SERIALIZE_BINARY 00099 00100 #if _QX_SERIALIZE_TEXT 00101 QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::text_iarchive, boost::archive::text_oarchive) 00102 #endif // _QX_SERIALIZE_TEXT 00103 00104 #if _QX_SERIALIZE_XML 00105 QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::xml_iarchive, boost::archive::xml_oarchive) 00106 #endif // _QX_SERIALIZE_XML 00107 00108 #if _QX_SERIALIZE_PORTABLE_BINARY 00109 QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(eos::portable_iarchive, eos::portable_oarchive) 00110 #endif // _QX_SERIALIZE_PORTABLE_BINARY 00111 00112 #if _QX_SERIALIZE_WIDE_BINARY 00113 QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::binary_wiarchive, boost::archive::binary_woarchive) 00114 #endif // _QX_SERIALIZE_WIDE_BINARY 00115 00116 #if _QX_SERIALIZE_WIDE_TEXT 00117 QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::text_wiarchive, boost::archive::text_woarchive) 00118 #endif // _QX_SERIALIZE_WIDE_TEXT 00119 00120 #if _QX_SERIALIZE_WIDE_XML 00121 QX_DATA_MEMBER_QOBJECT_IMPL_VIRTUAL_ARCHIVE_HPP(boost::archive::xml_wiarchive, boost::archive::xml_woarchive) 00122 #endif // _QX_SERIALIZE_WIDE_XML 00123 00124 #endif // _QX_ENABLE_BOOST_SERIALIZATION 00125 00126 protected: 00127 00128 virtual boost::any getDataPtr(const void * pOwner) const; 00129 virtual boost::any getDataPtr(void * pOwner); 00130 virtual void * getDataVoidPtr(const void * pOwner) const; 00131 virtual void * getDataVoidPtr(void * pOwner); 00132 00133 }; 00134 00135 } // namespace qx 00136 00137 #endif // _QX_DATA_MEMBER_QOBJECT_H_