QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsfeaturesink.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfeaturesink.cpp
3  ------------------
4  begin : April 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "qgsfeaturestore.h"
19 
20 bool QgsFeatureSink::addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags )
21 {
22  QgsFeatureList features;
23  features << feature;
24  bool result = addFeatures( features, flags );
25 
26  if ( !( flags & FastInsert ) )
27  {
28  // need to update the passed feature reference to the updated copy from the features list
29  feature = features.at( 0 );
30  }
31  return result;
32 }
33 
34 bool QgsFeatureSink::addFeatures( QgsFeatureIterator &iterator, QgsFeatureSink::Flags flags )
35 {
36  QgsFeature f;
37  bool result = true;
38  while ( iterator.nextFeature( f ) )
39  {
40  result = result && addFeature( f, flags );
41  }
42  return result;
43 }
44 
QgsFeatureSink::addFeature
virtual bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags())
Adds a single feature to the sink.
Definition: qgsfeaturesink.cpp:20
QgsFeatureList
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:583
QgsFeatureIterator::nextFeature
bool nextFeature(QgsFeature &f)
Definition: qgsfeatureiterator.h:374
QgsFeatureSink::addFeatures
virtual bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags())=0
Adds a list of features to the sink.
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
qgsfeaturestore.h
QgsFeatureIterator
Wrapper for iterator of features from vector data provider or vector layer.
Definition: qgsfeatureiterator.h:265
QgsFeatureSink::FastInsert
@ FastInsert
Use faster inserts, at the cost of updating the passed features to reflect changes made at the provid...
Definition: qgsfeaturesink.h:70