Problems with compiling when using 1 to n relationship

Forum for posting problems using QxOrm library

Problems with compiling when using 1 to n relationship

Postby JOJO » Sat Jun 18, 2016 12:27 pm

My QxOrm library works very well without any relations defined.

As soon i use relations i got the problem that the builder says:
QxOrm/include/QxSerialize/QDataStream/QxSerializeQDataStream_boost_shared_ptr.h:55: Error: no match for 'operator<<' (operand types are 'QDataStream' and '<DAO_CLASS>')
if (t) { stream << (* t); }


The same error message appears with operator operator>>.

I did the relationship the same way as the tutorial on the homepage of QxOrm and the tests in the downloaded sources it do.

Is that maybe a known error message? Can anybody help me to interpret this error message? After some time trying out to fix the problem, i have no idea what i can do.

Class 1:
Code: Select all
#ifndef _CLASS_CLASS1_H_
#define _CLASS_CLASS1_H_

#include <QxPrecompiled.h>   // Precompiled-header with '#include <QxOrm.h>' and '#include "export.h"'
#include <QxOrm.h>
#include <QxMemLeak.h>     // Automatic memory leak detection

class Class2;

class QX_DLL_EXPORT Class1
{
public:
   typedef boost::shared_ptr<Class2> class2_ptr;

   long id;
   QString name;
   int duration;
   class2_ptr class2;

   Class1() : id(0) { ; }
   virtual ~Class1() { ; }
};

QX_REGISTER_HPP(Class1, qx::trait::no_base_class_defined, 1)

typedef boost::shared_ptr<Class1> class1_ptr;
typedef QList<class1_ptr> list_class1;

/* This macro is necessary to register 'drug' class in QxOrm context */
/* param 1 : the current class to register => 'drug' */
/* param 2 : the base class, if no base class, use the qx trait => 'qx::trait::no_base_class_defined' */
/* param 3 : the class version used by serialization to provide 'ascendant compatibility' */

#endif // _CLASS_CLASS1_H_


Class2:
Code: Select all
#ifndef _CLASS_CLASS2_H_
#define _CLASS_CLASS2_H_

#include "class1.h"

#include <QxPrecompiled.h>   // Precompiled-header with '#include <QxOrm.h>' and '#include "export.h"'
#include <QxOrm.h>
#include <QxMemLeak.h>     // Automatic memory leak detection

class QX_DLL_EXPORT Class2
{
public:

   long id;
   QString name;
   list_class1 class1;

   Class2() : id(0) { ; }
   virtual ~Class2() { ; }
};

QX_REGISTER_HPP(Class2, qx::trait::no_base_class_defined, 1)


typedef boost::shared_ptr<Class2> Class2_ptr;
typedef QList<Class2_ptr> list_class2;

/* This macro is necessary to register 'drug' class in QxOrm context */
/* param 1 : the current class to register => 'drug' */
/* param 2 : the base class, if no base class, use the qx trait => 'qx::trait::no_base_class_defined' */
/* param 3 : the class version used by serialization to provide 'ascendant compatibility' */

#endif // _CLASS_CLASS2_H_
JOJO
 
Posts: 7
Joined: Mon Jun 13, 2016 8:40 am

Re: Problems with compiling when using 1 to n relationship

Postby qxorm » Sun Jun 19, 2016 8:34 am

Hello,

In your include file, you wrote :
Code: Select all
#include <QxPrecompiled.h>   // Precompiled-header with '#include <QxOrm.h>' and '#include "export.h"'
#include <QxOrm.h>
#include <QxMemLeak.h>     // Automatic memory leak detection


This is wrong !
First, never include a precompiled header file in a *.h file : a precompiled header must be included in a source *.cpp file.
And QxOrm.h should be in your precompiled header already ==> so do not include it here.
And about QxMemLeak.h : include it in your *.cpp file, not in the header file.

Note : I would recommend to create your first C++ classes with QxEntityEditor : it could help you to understand how to create relationships or other features of QxOrm library.
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 6 guests

cron