Page 1 of 1

XML serialisation

PostPosted: Thu Jan 06, 2011 8:41 am
by ruddy32
Hi,
I would like to set an object using an XML stream with some missing object attributes. I get an error doing this.
Is it possible to do it using QxOrm 1.1.3?
Thanks

Re: XML serialisation

PostPosted: Thu Jan 06, 2011 9:06 am
by ruddy32
This is done by settings the bSerialize flag to false in QxClass::add() method. Right?

Re: XML serialisation

PostPosted: Thu Jan 06, 2011 2:32 pm
by QxOrm admin
Hi,

If you want to serialize/deserialize an object without some attributes defined in your qx mapping function, you have to use this method :
template <typename V> IxDataMember * data(V T::* pData, const QString & sKey, long lVersion, bool bSerialize);

For example :
In the code below, when you serialize/deserialize an object of type CPerson, attributes "lastName" and "sex" are ignored by serialization process.

Code: Select all
namespace qx {
template <> void register_class(QxClass<qx::test::CPerson> & t)
{
   t.id(& qx::test::CPerson::m_lPersonId, "idPerson", 0);
   t.data(& qx::test::CPerson::m_sFirstName, "firstName", 0);
   t.data(& qx::test::CPerson::m_sLastName, "lastName", 0, false);
   t.data(& qx::test::CPerson::m_eSex, "sex", 0, false);
}}