Skip to content

Commit a87e8d1

Browse files
authoredMay 3, 2017
Merge pull request #4493 from arnaud-morvan/sipify_core_classes_2
Sipify core classes 2
2 parents cdb947c + 04a9264 commit a87e8d1

File tree

5 files changed

+244
-89
lines changed

5 files changed

+244
-89
lines changed
 

‎python/auto_sip.blacklist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ core/qgseditorwidgetsetup.sip
99
core/qgserror.sip
1010
core/qgsexpressioncontext.sip
1111
core/qgsexpressioncontextgenerator.sip
12-
core/qgsfeaturefilterprovider.sip
13-
core/qgsfeatureiterator.sip
1412
core/qgsfeaturerequest.sip
1513
core/qgsgeometrysimplifier.sip
1614
core/qgsgeometryvalidator.sip
Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,54 @@
1-
/** \ingroup core
2-
* \class QgsFeatureFilterProvider
3-
* Abstract interface for use by classes that filter the features of a layer.
4-
* A QgsFeatureFilterProvider provides a method for modifying a QgsFeatureRequest in place to apply
5-
* additional filters to the request.
6-
* \note added in QGIS 2.14
7-
**/
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/qgsfeaturefilterprovider.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
13+
14+
15+
816
class QgsFeatureFilterProvider
917
{
10-
%TypeHeaderCode
11-
#include <qgsfeaturefilterprovider.h>
18+
%Docstring
19+
Abstract interface for use by classes that filter the features of a layer.
20+
A QgsFeatureFilterProvider provides a method for modifying a QgsFeatureRequest in place to apply
21+
additional filters to the request.
22+
.. versionadded:: 2.14
23+
*
1224
%End
1325

26+
%TypeHeaderCode
27+
#include "qgsfeaturefilterprovider.h"
28+
%End
1429
public:
1530

16-
/** Add additional filters to the feature request to further restrict the features returned by the request.
17-
* Derived classes must implement this method.
18-
* @param layer the layer to filter
19-
* @param featureRequest the feature request to update
20-
*/
31+
2132
virtual void filterFeatures( const QgsVectorLayer *layer, QgsFeatureRequest &featureRequest ) const = 0;
33+
%Docstring
34+
Add additional filters to the feature request to further restrict the features returned by the request.
35+
Derived classes must implement this method.
36+
\param layer the layer to filter
37+
\param featureRequest the feature request to update
38+
%End
2239

23-
/** Create a clone of the feature filter provider
24-
* @return a new clone
25-
*/
2640
virtual QgsFeatureFilterProvider *clone() const = 0 /Factory/;
41+
%Docstring
42+
Create a clone of the feature filter provider
43+
:return: a new clone
44+
:rtype: QgsFeatureFilterProvider
45+
%End
2746
};
47+
48+
/************************************************************************
49+
* This file has been generated automatically from *
50+
* *
51+
* src/core/qgsfeaturefilterprovider.h *
52+
* *
53+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
54+
************************************************************************/

‎python/core/qgsfeatureiterator.sip

Lines changed: 149 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,208 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/qgsfeatureiterator.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
111
class QgsAbstractFeatureIterator
212
{
13+
%Docstring
14+
Internal feature iterator to be implemented within data providers
15+
%End
16+
317
%TypeHeaderCode
4-
#include <qgsfeatureiterator.h>
18+
#include "qgsfeatureiterator.h"
519
%End
620
public:
721

8-
//! Status of expression compilation for filter expression requests
922
enum CompileStatus
1023
{
11-
NoCompilation, /*!< Expression could not be compiled or not attempt was made to compile expression */
12-
PartiallyCompiled, /*!< Expression was partially compiled, but extra checks need to be applied to features*/
13-
Compiled, /*!< Expression was fully compiled and delegated to data provider source*/
24+
NoCompilation,
25+
PartiallyCompiled,
26+
Compiled,
1427
};
1528

16-
//! base class constructor - stores the iteration parameters
1729
QgsAbstractFeatureIterator( const QgsFeatureRequest &request );
30+
%Docstring
31+
base class constructor - stores the iteration parameters
32+
%End
1833

19-
//! destructor makes sure that the iterator is closed properly
2034
virtual ~QgsAbstractFeatureIterator();
35+
%Docstring
36+
destructor makes sure that the iterator is closed properly
37+
%End
2138

22-
//! fetch next feature, return true on success
2339
virtual bool nextFeature( QgsFeature &f );
40+
%Docstring
41+
fetch next feature, return true on success
42+
:rtype: bool
43+
%End
2444

25-
//! reset the iterator to the starting position
2645
virtual bool rewind() = 0;
27-
//! end of iterating: free the resources / lock
46+
%Docstring
47+
reset the iterator to the starting position
48+
:rtype: bool
49+
%End
2850
virtual bool close() = 0;
51+
%Docstring
52+
end of iterating: free the resources / lock
53+
:rtype: bool
54+
%End
55+
2956

30-
/** Returns the status of expression compilation for filter expression requests.
31-
* @note added in QGIS 2.16
32-
*/
3357
CompileStatus compileStatus() const;
58+
%Docstring
59+
Returns the status of expression compilation for filter expression requests.
60+
.. versionadded:: 2.16
61+
:rtype: CompileStatus
62+
%End
3463

3564
protected:
36-
/**
37-
* If you write a feature iterator for your provider, this is the method you
38-
* need to implement!!
39-
*
40-
* @param f The feature to write to
41-
* @return true if a feature was written to f
42-
*/
65+
4366
virtual bool fetchFeature( QgsFeature &f ) = 0;
67+
%Docstring
68+
If you write a feature iterator for your provider, this is the method you
69+
need to implement!!
70+
71+
\param f The feature to write to
72+
:return: true if a feature was written to f
73+
:rtype: bool
74+
%End
4475

45-
/**
46-
* By default, the iterator will fetch all features and check if the feature
47-
* matches the expression.
48-
* If you have a more sophisticated metodology (SQL request for the features...)
49-
* and you check for the expression in your fetchFeature method, you can just
50-
* redirect this call to fetchFeature so the default check will be omitted.
51-
*
52-
* @param f The feature to write to
53-
* @return true if a feature was written to f
54-
*/
5576
virtual bool nextFeatureFilterExpression( QgsFeature &f );
77+
%Docstring
78+
By default, the iterator will fetch all features and check if the feature
79+
matches the expression.
80+
If you have a more sophisticated metodology (SQL request for the features...)
81+
and you check for the expression in your fetchFeature method, you can just
82+
redirect this call to fetchFeature so the default check will be omitted.
83+
84+
\param f The feature to write to
85+
:return: true if a feature was written to f
86+
:rtype: bool
87+
%End
5688

57-
/**
58-
* By default, the iterator will fetch all features and check if the id
59-
* is in the request.
60-
* If you have a more sophisticated metodology (SQL request for the features...)
61-
* and you are sure, that any feature you return from fetchFeature will match
62-
* if the request was FilterFids you can just redirect this call to fetchFeature
63-
* so the default check will be omitted.
64-
*
65-
* @param f The feature to write to
66-
* @return true if a feature was written to f
67-
*/
6889
virtual bool nextFeatureFilterFids( QgsFeature &f );
90+
%Docstring
91+
By default, the iterator will fetch all features and check if the id
92+
is in the request.
93+
If you have a more sophisticated metodology (SQL request for the features...)
94+
and you are sure, that any feature you return from fetchFeature will match
95+
if the request was FilterFids you can just redirect this call to fetchFeature
96+
so the default check will be omitted.
97+
98+
\param f The feature to write to
99+
:return: true if a feature was written to f
100+
:rtype: bool
101+
%End
102+
103+
104+
105+
106+
void ref();
107+
%Docstring
108+
Add reference
109+
%End
110+
void deref();
111+
%Docstring
112+
Remove reference, delete if refs == 0
113+
%End
114+
69115

70-
void ref(); //!< add reference
71-
void deref(); //!< remove reference, delete if refs == 0
72116

73-
//! Setup the simplification of geometries to fetch using the specified simplify method
74117
virtual bool prepareSimplification( const QgsSimplifyMethod &simplifyMethod );
118+
%Docstring
119+
Setup the simplification of geometries to fetch using the specified simplify method
120+
:rtype: bool
121+
%End
122+
75123
};
76124

77125

78126
class QgsFeatureIterator
79127
{
80-
%TypeHeaderCode
81-
#include <qgsfeatureiterator.h>
128+
%Docstring
129+
Wrapper for iterator of features from vector data provider or vector layer
82130
%End
83131

132+
%TypeHeaderCode
133+
#include "qgsfeatureiterator.h"
134+
%End
84135
public:
136+
85137
QgsFeatureIterator *__iter__();
138+
%Docstring
139+
:rtype: QgsFeatureIterator
140+
%End
86141
%MethodCode
87-
sipRes = sipCpp;
142+
sipRes = sipCpp;
88143
%End
89144

90-
SIP_PYOBJECT __next__();
145+
SIP_PYOBJECT __next__();
91146
%MethodCode
92-
QgsFeature *f = new QgsFeature;
93-
if (sipCpp->nextFeature(*f))
94-
sipRes = sipConvertFromType(f, sipType_QgsFeature, Py_None);
95-
else
96-
{
97-
delete f;
98-
PyErr_SetString(PyExc_StopIteration,"");
99-
}
147+
QgsFeature *f = new QgsFeature;
148+
if ( sipCpp->nextFeature( *f ) )
149+
sipRes = sipConvertFromType( f, sipType_QgsFeature, Py_None );
150+
else
151+
{
152+
delete f;
153+
PyErr_SetString( PyExc_StopIteration, "" );
154+
}
100155
%End
101156

102-
//! construct invalid iterator
103157
QgsFeatureIterator();
104-
//! construct a valid iterator
105-
// QgsFeatureIterator( QgsAbstractFeatureIterator *iter );
106-
//! copy constructor copies the iterator, increases ref.count
158+
%Docstring
159+
construct invalid iterator
160+
%End
107161
QgsFeatureIterator( const QgsFeatureIterator &fi );
108-
//! destructor deletes the iterator if it has no more references
162+
%Docstring
163+
copy constructor copies the iterator, increases ref.count
164+
%End
109165
~QgsFeatureIterator();
166+
%Docstring
167+
destructor deletes the iterator if it has no more references
168+
%End
110169

111-
// QgsFeatureIterator &operator=(const QgsFeatureIterator &other);
112170

113171
bool nextFeature( QgsFeature &f );
172+
%Docstring
173+
:rtype: bool
174+
%End
114175
bool rewind();
176+
%Docstring
177+
:rtype: bool
178+
%End
115179
bool close();
180+
%Docstring
181+
:rtype: bool
182+
%End
116183

117-
//! find out whether the iterator is still valid or closed already
118184
bool isClosed() const;
185+
%Docstring
186+
find out whether the iterator is still valid or closed already
187+
:rtype: bool
188+
%End
189+
119190

120-
/** Returns the status of expression compilation for filter expression requests.
121-
* @note added in QGIS 2.16
122-
*/
123191
QgsAbstractFeatureIterator::CompileStatus compileStatus() const;
192+
%Docstring
193+
Returns the status of expression compilation for filter expression requests.
194+
.. versionadded:: 2.16
195+
:rtype: QgsAbstractFeatureIterator.CompileStatus
196+
%End
197+
124198

125199
};
200+
201+
202+
/************************************************************************
203+
* This file has been generated automatically from *
204+
* *
205+
* src/core/qgsfeatureiterator.h *
206+
* *
207+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
208+
************************************************************************/

‎src/core/qgsfeaturefilterprovider.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@ class CORE_EXPORT QgsFeatureFilterProvider
4040
{
4141
public:
4242

43+
#ifndef SIP_RUN
44+
4345
//! Constructor
4446
QgsFeatureFilterProvider() {}
4547

4648
virtual ~QgsFeatureFilterProvider() = default;
4749

50+
#endif
51+
4852
/** Add additional filters to the feature request to further restrict the features returned by the request.
4953
* Derived classes must implement this method.
5054
* \param layer the layer to filter

‎src/core/qgsfeatureiterator.h

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "qgsfeaturerequest.h"
2020
#include "qgsindexedfeature.h"
2121

22+
#ifndef SIP_RUN
2223

2324
/** \ingroup core
2425
* Interface that can be optionally attached to an iterator so its
@@ -33,6 +34,8 @@ class CORE_EXPORT QgsInterruptionChecker
3334
virtual bool mustStop() const = 0;
3435
};
3536

37+
#endif
38+
3639
/** \ingroup core
3740
* Internal feature iterator to be implemented within data providers
3841
*/
@@ -62,6 +65,8 @@ class CORE_EXPORT QgsAbstractFeatureIterator
6265
//! end of iterating: free the resources / lock
6366
virtual bool close() = 0;
6467

68+
#ifndef SIP_RUN
69+
6570
/** Attach an object that can be queried regularly by the iterator to check
6671
* if it must stopped. This is mostly useful for iterators where a single
6772
* nextFeature()/fetchFeature() iteration might be very long. A typical use case is the
@@ -71,6 +76,7 @@ class CORE_EXPORT QgsAbstractFeatureIterator
7176
* \note not available in Python bindings
7277
*/
7378
virtual void setInterruptionChecker( QgsInterruptionChecker *interruptionChecker );
79+
#endif
7480

7581
/** Returns the status of expression compilation for filter expression requests.
7682
* \since QGIS 2.16
@@ -131,8 +137,10 @@ class CORE_EXPORT QgsAbstractFeatureIterator
131137
//! reference counting (to allow seamless copying of QgsFeatureIterator instances)
132138
//! TODO QGIS3: make this private
133139
int refs;
134-
void ref(); //!< Add reference
135-
void deref(); //!< Remove reference, delete if refs == 0
140+
//! Add reference
141+
void ref();
142+
//! Remove reference, delete if refs == 0
143+
void deref();
136144
friend class QgsFeatureIterator;
137145

138146
//! Number of features already fetched by iterator
@@ -171,7 +179,7 @@ class CORE_EXPORT QgsAbstractFeatureIterator
171179
void setupOrderBy( const QList<QgsFeatureRequest::OrderByClause> &orderBys );
172180
};
173181

174-
182+
#ifndef SIP_RUN
175183

176184
/** \ingroup core
177185
* Helper template that cares of two things: 1. automatic deletion of source if owned by iterator, 2. notification of open/closed iterator.
@@ -203,17 +211,41 @@ class QgsAbstractFeatureIteratorFromSource : public QgsAbstractFeatureIterator
203211
bool mOwnSource;
204212
};
205213

214+
#endif
215+
206216
/**
207217
* \ingroup core
208218
* Wrapper for iterator of features from vector data provider or vector layer
209219
*/
210220
class CORE_EXPORT QgsFeatureIterator
211221
{
212222
public:
223+
224+
#ifdef SIP_RUN
225+
QgsFeatureIterator *__iter__();
226+
% MethodCode
227+
sipRes = sipCpp;
228+
% End
229+
230+
SIP_PYOBJECT __next__();
231+
% MethodCode
232+
QgsFeature *f = new QgsFeature;
233+
if ( sipCpp->nextFeature( *f ) )
234+
sipRes = sipConvertFromType( f, sipType_QgsFeature, Py_None );
235+
else
236+
{
237+
delete f;
238+
PyErr_SetString( PyExc_StopIteration, "" );
239+
}
240+
% End
241+
#endif
242+
213243
//! construct invalid iterator
214244
QgsFeatureIterator();
245+
#ifndef SIP_RUN
215246
//! construct a valid iterator
216247
QgsFeatureIterator( QgsAbstractFeatureIterator *iter );
248+
#endif
217249
//! copy constructor copies the iterator, increases ref.count
218250
QgsFeatureIterator( const QgsFeatureIterator &fi );
219251
//! destructor deletes the iterator if it has no more references
@@ -228,6 +260,8 @@ class CORE_EXPORT QgsFeatureIterator
228260
//! find out whether the iterator is still valid or closed already
229261
bool isClosed() const;
230262

263+
#ifndef SIP_RUN
264+
231265
/** Attach an object that can be queried regularly by the iterator to check
232266
* if it must stopped. This is mostly useful for iterators where a single
233267
* nextFeature()/fetchFeature() iteration might be very long. A typical use case is the
@@ -237,19 +271,26 @@ class CORE_EXPORT QgsFeatureIterator
237271
*/
238272
void setInterruptionChecker( QgsInterruptionChecker *interruptionChecker );
239273

274+
#endif
275+
240276
/** Returns the status of expression compilation for filter expression requests.
241277
* \since QGIS 2.16
242278
*/
243279
QgsAbstractFeatureIterator::CompileStatus compileStatus() const { return mIter->compileStatus(); }
244280

281+
#ifndef SIP_RUN
282+
245283
friend bool operator== ( const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2 );
246284
friend bool operator!= ( const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2 );
247285

248286
protected:
249287
QgsAbstractFeatureIterator *mIter = nullptr;
288+
289+
#endif
290+
250291
};
251292

252-
////////
293+
#ifndef SIP_RUN
253294

254295
inline QgsFeatureIterator::QgsFeatureIterator()
255296
: mIter( nullptr )
@@ -318,4 +359,6 @@ inline void QgsFeatureIterator::setInterruptionChecker( QgsInterruptionChecker *
318359
mIter->setInterruptionChecker( interruptionChecker );
319360
}
320361

362+
#endif
363+
321364
#endif // QGSFEATUREITERATOR_H

0 commit comments

Comments
 (0)
Please sign in to comment.