[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyQt] SIP template
From: Rouzaud Denis <denis.rouzaud () gmail ! com>
Date: 2017-05-16 19:49:57
Message-ID: 61F83D00-89C4-4FCB-8CFD-A7D61B6D9C04 () gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Dear all,
I am facing an issue with correcty implementing a template (container)) in SIP.
Let's say I have
qgsoptional:
template<class T>
class QgsOptional
{
public:
QgsOptional( const T &data, bool enabled )
: mEnabled( enabled )
, mData( data )
{}
private:
bool mEnabled;
T mData;
};
qgsoptionalexpression.h:
class QgsOptionalExpression : public QgsOptional<QgsExpression>
{
public:
QgsOptionalExpression();
}
Now, I'd like to create the SIP file for QgsOptioalExpression. I tried with what I \
found in another topic [0]:
class QgsOptionalExpression
{
%TypeHeaderCode
#include "qgsoptional.h"
typedef QgsOptional<QgsExpression> QgsOptionalExpression;
%End
public:
QgsOptionalExpression();
}
But this gives me this error:
python/core/qgsoptionalexpression.sip:29:36: error: typedef redefinition with \
different types ('QgsOptional' vs 'QgsOptionalExpression') typedef QgsOptional \
QgsOptionalExpression; The error points that the definition is already included in \
the header qgsoptionalepxression.h while I am actually not including it here (also \
gave it a try with including it).
I understand the point, but how shall I tackle this?
If I remove the inheritance, I'm of course not getting any of the container methods.
I also gave it a try with a ModuleHeaderCode:
%ModuleHeaderCode
#include "qgsoptional.h"
#include "qgsexpression.h"
typedef QgsOptional<QgsExpression> QgsOptionalExpression;
%End
But it fails with the same kind of error, complaining the type is already defined in \
the header (also with or without including it in the TypeHeaderCode.
Any idea how to solve this?
Thanks a lot!
Denis
[0] https://www.riverbankcomputing.com/pipermail/pyqt/2015-May/035893.html \
<https://www.riverbankcomputing.com/pipermail/pyqt/2015-May/035893.html>
[Attachment #5 (unknown)]
<html><head><meta http-equiv="Content-Type" content="text/html \
charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; \
-webkit-line-break: after-white-space;" class=""><span class=""></span><span \
class="">Dear all,</span><span class=""><br class=""><br class=""></span><span \
class="">I am facing an issue with correcty implementing a template (container)) in \
SIP.<br class=""></span><span class=""><br class=""></span><span class="">Let's say I \
have<br class=""></span><span class=""><br class=""></span><span \
class="">qgsoptional:<br class=""></span><span \
class="">template<class T><br class="">class QgsOptional<br \
class="">{<br class=""> public:<br class=""> \
QgsOptional( const T &data, bool enabled )<br \
class=""> : mEnabled( enabled )<br \
class=""> , mData( data )<br class=""> \
{}<br class=""> private:<br class=""> \
bool mEnabled;<br class=""> T mData;<br \
class="">};<br class=""><br class="">qgsoptionalexpression.h:<br class=""><br \
class="">class QgsOptionalExpression : public QgsOptional<QgsExpression><br \
class="">{<br class=""> public:<br class=""> \
QgsOptionalExpression();<br class="">}<br class=""><br class=""><br \
class=""></span><span class="">Now, I'd like to create the SIP file for \
QgsOptioalExpression. I tried with what I found in another topic [0]:</span><div \
class=""><br class=""></div><div class=""><span class="">class \
QgsOptionalExpression<br class="">{<br class="">%TypeHeaderCode<br class="">#include \
"qgsoptional.h"<br class="">typedef QgsOptional<QgsExpression> \
QgsOptionalExpression;<br class="">%End<br class=""> public:<br class=""> \
QgsOptionalExpression();<br class="">}</span></div><div class=""><span \
class=""><br class=""></span></div><div class=""><span class="">But this gives me \
this error:</span></div><div class=""><span style="color: rgb(38, 50, 56); \
font-family: Roboto, Arial, sans-serif; font-size: 13px; font-variant-ligatures: \
normal; orphans: 2; widows: 2;" class="">python/core/qgsoptionalexpression.sip:29:36: \
error: typedef redefinition with different types ('QgsOptional' vs \
'QgsOptionalExpression')</span><br style="color: rgb(38, 50, 56); font-family: \
Roboto, Arial, sans-serif; font-size: 13px; font-variant-ligatures: normal; orphans: \
2; widows: 2;" class=""><span style="color: rgb(38, 50, 56); font-family: Roboto, \
Arial, sans-serif; font-size: 13px; font-variant-ligatures: normal; orphans: 2; \
widows: 2;" class="">typedef QgsOptional QgsOptionalExpression;</span></div><div \
style="orphans: 2; widows: 2;" class=""><font color="#263238" face="Roboto, Arial, \
sans-serif" size="2" class="">The error points that the definition is already \
included in the header qgsoptionalepxression.h while I am actually not including it \
here (also gave it a try with including it).</font></div><div style="orphans: 2; \
widows: 2;" class=""><font color="#263238" face="Roboto, Arial, sans-serif" size="2" \
class=""><br class=""></font></div><div style="orphans: 2; widows: 2;" class=""><font \
color="#263238" face="Roboto, Arial, sans-serif" size="2" class="">I understand the \
point, but how shall I tackle this?</font></div><div style="orphans: 2; widows: 2;" \
class=""><font color="#263238" face="Roboto, Arial, sans-serif" size="2" class="">If \
I remove the inheritance, I'm of course not getting any of the container \
methods.</font></div><div style="orphans: 2; widows: 2;" class=""><font \
color="#263238" face="Roboto, Arial, sans-serif" size="2" class="">I also gave it a \
try with a ModuleHeaderCode:</font></div><div style="orphans: 2; widows: 2;" \
class=""><font color="#263238" face="Roboto, Arial, sans-serif" size="2" class=""><br \
class=""></font></div><div style="orphans: 2; widows: 2;" class=""><font \
color="#263238" face="Roboto, Arial, sans-serif" size="2" class=""><div \
class=""> %ModuleHeaderCode</div><div class=""> #include \
"qgsoptional.h"</div><div class=""> #include "qgsexpression.h"</div><div \
class=""> typedef QgsOptional<QgsExpression> \
QgsOptionalExpression;</div><div class=""> %End</div><div class=""><br \
class=""></div><div class="">But it fails with the same kind of error, complaining \
the type is already defined in the header (also with or without including it in the \
TypeHeaderCode.</div><div class=""><br class=""></div><div class=""><br \
class=""></div><div class="">Any idea how to solve this?</div><div class="">Thanks a \
lot!</div><div class=""><br class=""></div><div class="">Denis</div></font></div><div \
class=""><br class=""></div><div class=""><span class=""><br \
class=""></span></div><div class=""><span class="">[0] </span><a \
href="https://www.riverbankcomputing.com/pipermail/pyqt/2015-May/035893.html" \
class="">https://www.riverbankcomputing.com/pipermail/pyqt/2015-May/035893.html</a><span \
class=""><br class=""></span><span class=""><br class=""></span><span class=""><br \
class=""></span><span class=""><br class=""></span><span class=""><br \
class=""></span></div></body></html>
[Attachment #6 (text/plain)]
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic