/
sipifyheader.h
497 lines (401 loc) · 15.2 KB
/
sipifyheader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
/***************************************************************************
sipifyheader.h - Demo for sipify.pl
--------------------------------------
Date : 28.03.2017
Copyright : (C) 2017 Denis Rouzaud
email : denis.rouzaud@gmail.com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef SIPIFYHEADER_H
#define SIPIFYHEADER_H
#include "qgis_core.h"
#include <QtClass>
#ifdef SIP_RUN
% ModuleHeaderCode
#include <qgsnetworkspeedstrategy.h>
#include <qgsnetworkdistancestrategy.h>
% End
#endif
#include "sipifyheader.h"
// one shall include qgis.h to use SIP annotations
#include "qgis.h"
class QgsForwardDeclaration;
/***************************************************************************
* This is some random block comment that will not be displayed.
* Block comments shall will placed upon class, method, enum without
* any blank lines in between.
****************************************************************************/
// typedef have no Docstring, so commenting here will not be used
#ifdef SIP_RUN
typedef qint64 QgsFeatureId;
#else
typedef WhatEver ShouldNotBeDisplayed;
#endif
typedef QSet<QgsFeatureId SIP_PYALTERNATIVETYPE( qint64 )> QgsFeatureIds;
typedef QMap<QgsFeatureId SIP_PYALTERNATIVETYPE( qint64 ), QgsAttributeMap SIP_PYALTERNATIVETYPE( 'QMap<int, QVariant>' )> QgsChangedAttributesMap;
typedef QMap<QgsFeatureId, QgsAttributeMap> SIP_PYALTERNATIVETYPE( 'QMap<qint64, QMap<int, QVariant> >' ) QgsChangedAttributesMap;
typedef QMap<QgsFeatureId, QPair<QMap<Something, Complex> >> SIP_PYALTERNATIVETYPE( 'QMap<qint64, QMap<int, QVariant>>' ) QgsChangedAttributesMap;
/**
* \ingroup core
* A super QGIS class
*/
#ifndef SIP_RUN // following will be hidden
class CORE_EXPORT QgsSuperClass : public QtClass<QVariant>
{
public:
//! A constructor with definition in header
QgsSuperClass()
: QtClass<QVariant>()
{}
};
#else // following will be displayed in generated file
typedef QVector<QVariant> QgsSuperClass;
% MappedType QgsSuperClass
{
// The annotations are modified by astyle (these will be fixed by sipify.pl)
% TypeHeaderCode
#include <qgssipifyheader.h>
% End
% ConvertFromTypeCode
// Create the list.
PyObject *l;
return l;
% End
}
#endif
/**
* \ingroup core
* Documentation goes here
*
* Here's some comment mentioning another class QgsAutoAwesomemater::makeAwesome.
* \note some other note
* \since QGIS 3.0
*/
class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBaseClass
{
#ifdef SIP_RUN
SIP_CONVERT_TO_SUBCLASS_CODE
if ( sipCpp->headerType() == QgsSipifyHeader::Special )
sipType = sipType_QgsSpecialSipifyHeader;
else
sipType = sipType_QgsStandardSipifyHeader;
SIP_END
#endif
public:
//! This is an enum
enum MyEnum
{
Success = 0, //!< Edit operation was successful
NoSuccess = 1, //!< Edit operation resulted in an empty geometry
ImaginarySuccess = 1 << 3, //!< Edit operation resulted in an imaginary geometry
RecursiveSuccess = 1 << 4, //!< Edit operation resulted in an n-dimensional wormhole
SuccessCombination = Success | ImaginarySuccess, //!< Holy Graal
PythonName SIP_PYNAME( DifferentName ), //!< Different python name
};
Q_DECLARE_FLAGS( Flags, MyEnum )
enum OneLiner { Success, NoSuccess };
static const inline QgsSettingsEntryEnumFlag<QgsSnappingConfig::SnappingTypes> settingsDigitizingDefaultSnapType = QgsSettingsEntryEnumFlag<QgsSnappingConfig::SnappingTypes>( QStringLiteral( "/qgis/digitizing/default_snap_type" ), QgsSettings::NoSection, QgsSnappingConfig::VertexFlag );
/**
* Docstring headers for structs are not supported by sip (as of 4.18) and
* therefore this docstring must not to be copied to the sipfile.
*/
struct Data
{
Data( QgsMapLayer *layer, Qstring name )
: mLayer( layer )
, mName( name )
{}
QString mName;
int mCount = 100;
QgsMapLayer *mLayer = nullptr;
QList<QAction *> contextMenuActions = QList<QAction *>();
};
static const int MONTHS = 60 * 60 * 24 * 30; // something
//! A constructor with definition in header
explicit QgsSipifyHeader()
: QtClass<QVariant>()
, QgsBaseClass()
{}
/*
* A classic constructor with arguments
*/
QgsSipifyHeader( QWidget *parent SIP_TRANSFERTHIS = nullptr );
//! A constructor with no empty `()`
QgsSipifyHeader( bool a = true )
: mMember( nullptr )
{}
//! A constructor with some special character types
QgsSipifyHeader( QList<Point> a, const Issues &b = Issues::weDontHaveIssues(), QgsClass *b = nullptr )
: mMember( nullptr )
{}
Constructor() : mHasNamedNodes( false ) {}
virtual ~Destructor() { qDeleteAll( mList ); }
Constructor( const QString &name,
bool optional = false,
const QVariant &defaultValue = QVariant() )
: mName( name )
, mOptional( optional )
, mDefaultValue( defaultValue )
{}
//! Default constructor
QgsSipifyHeader() = default;
//! Assignment operator should be removed in sip
QgsSipifyHeader &operator=( const QgsSipifyHeader other );
//! Comparison operator should be kept
bool operator==( const QgsSipifyHeader other );
//! A multiline method signature
void multilineMethod( const QgsPointXY &startPoint,
QgsFeatureId featureId,
QgsVectorLayer *vl,
QgsSnappingResult::SnappingType snap_to ) const;
// Adding SIP_SKIP at the end of a line will discard this line
bool thisShouldBeSkipped() const SIP_SKIP;
void nonAnnotatedMethodFollowingSkip();
bool myMultiLineSkipped( const QList<int, QString> &list1,
const QList<int, QString> &list2,
const QList<int, QString> &list3 ) SIP_SKIP;
//! Factory annotation
virtual QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
SomeObject *createAnother() SIP_FACTORY { return something; }
SomeObject *createAnother2() override SIP_FACTORY { return something; }
/**
* My long doc string
* is not very interesting!
*/
void LongDocStringMethod();
/**
* \brief some brief
* My long doc \a string
* is not very interesting!
* Here's some comment mentioning another class QgsAutoAwesomemater::makeLessAwesome.
*/
void LongDocStringMethodWithBrief();
/**
* I return a pointer. If something bad happens, I return NULLPTR.
* \returns pointer to something cool
*/
MyPointer *pointerReturnValue();
bool isOKwithErrMesg( QString &ErrMsg SIP_OUT );
void InOutParam( bool &ok = true SIP_INOUT );
void setDiagramRenderer( QgsDiagramRenderer *r SIP_TRANSFER );
void differentDefaultValue( bool defaultValue = true SIP_PYARGDEFAULT( false ), QWidget *parent = nullptr, QString msg = QString() SIP_PYARGDEFAULT( "hello" ) );
void differentType( QList<QgsFeatureId> SIP_PYALTERNATIVETYPE( QList<qint64> ) & list );
//! complex default value and type (i.e. containing commas) should be given as a string with single quotes
void complexDefaultValueAndType( QList<QPair<QgsFeatureId SIP_PYALTERNATIVETYPE( qint64 ), QMap<int, QString>>> list = QList<QPair<QgsFeatureId, QMap<int, QString>>>() SIP_PYARGDEFAULT( 'QList<QPair<qint64, QMap<int, QString>>>()' ) );
inline int inlineKeyWordShouldNotAppear();
QString labelForRange( double lower, double upper ) const SIP_PYNAME( labelForLowerUpper );
void setComposition( QgsComposition *c SIP_KEEPREFERENCE );
void removeProxyFactory( QNetworkProxyFactory *factory SIP_TRANSFERBACK );
bool removeFunctionBody( const QList<int, QString> &list, QgsVectorLayer *vl, Some::Thing _part = -1 /*default =-1*/ ) { doSomething; return true; } // some comments
static inline QgsMapLayer *skippedMethodWithBody() SIP_SKIP
{
OhNoYouShouldnotHaveReadThis();
if ( ThisIsTrue() )
{
return false;
}
}
void multilineBodyAndDefinition( const QList<int,
QString> &list,
QgsVectorLayer *vl,
Some::Thing _part = -1 /*default =-1*/ )
{
doSomething;
return true;
}
//! Removing function body with namespaced return value
QgsRaster::RasterBuildPyramids buildPyramidsFlag() const { return mBuildPyramidsFlag; }
//! Removing function body with virtual const reference
virtual const QgsLayerMetadata &metadata() const { return mMetadata; }
//! Mulitline body
bool myMultiLineBody()
{
if ( isTrue() )
{
return false;
}
else
{
return true;
}
}
bool deletedFunction() = delete; // some comments
virtual int overriddenProperty() override { return 42; } // if in doubt, comment it out
int overrideWithoutVirtual() override;
void overrideWithoutVirtualMultLine( const QList<int, QString> &list1,
const QList<int, QString> &list2 ) override;
QString returnTypeString() const;
double returnTypeDouble() const;
QList< QgsAnnotation * > returnTypeList();
QVector< QgsAnnotation > returnTypeVector();
QStringList returnTypeStringList();
QSet<QgsActionScope> returnTypeSet();
This<Member> shouldBeIncluded;
Q_INVOKABLE static QString invokableMethod();
bool initializedMember{ false };
struct CORE_EXPORT PublicStruct
{
explicit PublicStruct( int _part = -1, int _ring = -1, int _vertex = -1, VertexType _type = SegmentVertex )
: part( _part )
, ring( _ring )
, vertex( _vertex )
, type( _type )
{}
bool isValid( const QgsAbstractGeometry *geom ) const
{
return ( part >= 0 && part < geom->partCount() ) &&
( ring < geom->ringCount( part ) ) &&
( vertex < 0 || vertex < geom->vertexCount( part, ring ) );
}
int part;
int ring;
int vertex;
VertexType type;
}
void combinedAnnotations() SIP_FACTORY SIP_PYNAME( otherName );
void multiAnnotationArg( SomeClass **object SIP_OUT SIP_TRANSFERBACK, int &another SIP_OUT );
//! remove argument
void simple( bool test SIP_PYARGREMOVE );
void method( bool myArg SIP_PYARGREMOVE = test );
void test( QgsMapLayer *vl SIP_PYARGREMOVE = nullptr );
void avoidIntersections( const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures SIP_PYARGREMOVE = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) );
void position( bool single_remove SIP_PYARGREMOVE );
void position( bool first_remove SIP_PYARGREMOVE, bool keep );
void position( bool keep, bool middle_remove SIP_PYARGREMOVE, bool keep );
void position( bool keep, bool last_remove SIP_PYARGREMOVE );
static void SIP_PYALTERNATIVETYPE( SIP_PYLIST ) changeReturnType( QVector<int> *resultTree = 0, QVector<double> &resultCost = 0 );
//! Some comment
Whatever &operator[]( int i ) SIP_FACTORY;
#ifdef SIP_RUN
% MethodCode
....
% End
#endif
#if 0
#if Whatever
void X();
#else
void Y();
#endif
#else
void ZshouldBeShown();
#endif
void methodCodeWithMultiLineDef();
#ifdef SIP_RUN
% MethodCode
if ( QgsWkbTypes::flatType( a0 ) != QgsWkbTypes::Point )
{
multiLineDef( PyExc_ValueError,
QString( "%1 is not nice" ).arg( QgsWkbTypes::displayString( a0 ) ).toUtf8().constData() );
}
else
{
sipCpp = new sipQgsPoint( a0, a1, a2, a3, a4 );
}
% End
#endif
protected:
bool thisShouldBeListed();
Whatever skipMember;
Whatever::Something *alsoSkipMember = nullptr;
mutable Whatever alsoSkipThis;
Some<Other> memberToSkip;
QList<QgsMapLayer *> list2skip;
QMap<QString, Qt::CheckState> map2skip;
FilterType mFilter = FilterNone;
QgsFeatureId mFilterFid = -1;
QgsFeatureIds mFilterFids;
std::unique_ptr< QgsExpression > mFilterExpression;
long mLimit = -1;
InvalidGeometryCheck mInvalidGeometryFilter = GeometryNoCheck;
std::function< void( const QgsFeature & ) > mInvalidGeometryCallback;
static QHash<QString, Help> sFunctionHelpTexts;
friend class QgsOgcUtils;
template<typename> friend class QgsAbstractFeatureIteratorFromSource;
const QgsAbstractGeometry *mGeometry = 0;
mutable unsigned char *mP;
private:
void privateMethodAreNotShown();
#ifdef SIP_RUN
void privateMethodSIPRUNareShown();
#endif
public:
void FallBackToPublic();
private:
void PrivateAgain();
/* Single line block comments shouldn't break the parser */
void ShowThisPrivateOne() SIP_FORCE;
struct ProcessFeatureWrapper
{
QgsGeometrySnapper *instance = nullptr;
double snapTolerance;
SnapMode mode;
explicit ProcessFeatureWrapper( QgsGeometrySnapper *_instance, double snapTolerance, SnapMode mode )
: instance( _instance )
, snapTolerance( snapTolerance )
, mode( mode )
{}
void operator()( QgsFeature &feature ) { return instance->processFeature( feature, snapTolerance, mode ); }
};
enum PointFlag { SnappedToRefNode, SnappedToRefSegment, Unsnapped };
};
/**
* \class ClassWithPrivateInheritanceOnly
* \ingroup core
* Documentation goes here
*/
class CORE_EXPORT ClassWithPrivateInheritanceOnly : private QgsBaseClass SIP_ABSTRACT
{
public:
//! A constructor with definition in header on several lines
explicit ClassWithPrivateInheritanceOnly()
: QtClass<QVariant>()
, QgsBaseClass()
{
doWhatYouLike();
haveFun();
}
};
/**
* \class AbstractClass
* \ingroup core
* Documentation goes here
*/
class CORE_EXPORT AbstractClass SIP_ABSTRACT
{
public:
//! A constructor
explicit AbstractClass()
{
}
private:
/**
* This method should be overridden by subclasses but not exposed to the public
* or protected API.
*/
virtual QString reason() = 0;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsSipifyHeader::Flags )
class CORE_EXPORT TemplateInheritance1 : public QgsTemplate<Something>
{
}
class CORE_EXPORT TemplateInheritance2 : public QList<Something>, private SomethingElse
{
}
class CORE_EXPORT TemplateInheritance3 : public QgsTemplate<Something>, public SomethingElse
{
}
class CORE_EXPORT TemplateInheritance4 : public SomethingElse1, public QList<Something>, public SomethingElse2
{
}
class CORE_EXPORT TemplateInheritance5 : public SomethingElse, public QList<Something>
{
}
#endif