QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsProcessingFeatureSink Class Reference

QgsProxyFeatureSink subclass which reports feature addition errors to a QgsProcessingContext. More...

#include <qgsprocessingutils.h>

Inheritance diagram for QgsProcessingFeatureSink:
Inheritance graph
[legend]

Public Member Functions

 QgsProcessingFeatureSink (QgsFeatureSink *originalSink, const QString &sinkName, QgsProcessingContext &context, bool ownsOriginalSink=false)
 Constructor for QgsProcessingFeatureSink, accepting an original feature sink originalSink and processing context.
 
 ~QgsProcessingFeatureSink () override
 
bool addFeature (QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
 Adds a single feature to the sink.
 
bool addFeatures (QgsFeatureIterator &iterator, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
 Adds all features from the specified iterator to the sink.
 
bool addFeatures (QgsFeatureList &features, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
 Adds a list of features to the sink.
 
void finalize () override
 Finalizes the sink, flushing any buffered features to the destination.
 
- Public Member Functions inherited from QgsProxyFeatureSink
 QgsProxyFeatureSink (QgsFeatureSink *sink)
 Constructs a new QgsProxyFeatureSink which forwards features onto a destination sink.
 
bool addFeature (QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
 Adds a single feature to the sink.
 
bool addFeatures (QgsFeatureIterator &iterator, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
 Adds all features from the specified iterator to the sink.
 
bool addFeatures (QgsFeatureList &features, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
 Adds a list of features to the sink.
 
QgsFeatureSinkdestinationSink ()
 Returns the destination QgsFeatureSink which the proxy will forward features to.
 
void finalize () override
 Finalizes the sink, flushing any buffered features to the destination.
 
bool flushBuffer () override
 Flushes any internal buffer which may exist in the sink, causing any buffered features to be added to the sink's destination.
 
QString lastError () const override
 Returns the most recent error encountered by the sink, e.g.
 
- Public Member Functions inherited from QgsFeatureSink
virtual ~QgsFeatureSink ()=default
 

Additional Inherited Members

- Public Types inherited from QgsFeatureSink
enum  Flag { FastInsert = 1 << 1 , RollBackOnErrors = 1 << 2 }
 Flags controlling how features are added to a sink. More...
 
typedef QFlags< FlagFlags
 
enum  SinkFlag { RegeneratePrimaryKey = 1 << 1 }
 Flags that can be set on a QgsFeatureSink. More...
 
typedef QFlags< SinkFlagSinkFlags
 
- Protected Attributes inherited from QgsProxyFeatureSink
QgsFeatureSinkmSink = nullptr
 Underlying destination sink.
 

Detailed Description

QgsProxyFeatureSink subclass which reports feature addition errors to a QgsProcessingContext.

Note
Not available in Python bindings.

Definition at line 780 of file qgsprocessingutils.h.

Constructor & Destructor Documentation

◆ QgsProcessingFeatureSink()

QgsProcessingFeatureSink::QgsProcessingFeatureSink ( QgsFeatureSink originalSink,
const QString &  sinkName,
QgsProcessingContext context,
bool  ownsOriginalSink = false 
)

Constructor for QgsProcessingFeatureSink, accepting an original feature sink originalSink and processing context.

Any added features are added to the originalSink, with feature writing errors being reports to context.

The context must exist for the lifetime of this object.

The sinkName is used to identify the destination sink when reporting errors.

Ownership of originalSink is dictated by ownsOriginalSource. If ownsOriginalSink is false, ownership is not transferred, and callers must ensure that originalSink exists for the lifetime of this object. If ownsOriginalSink is true, then this object will take ownership of originalSink.

Definition at line 1997 of file qgsprocessingutils.cpp.

◆ ~QgsProcessingFeatureSink()

QgsProcessingFeatureSink::~QgsProcessingFeatureSink ( )
override

Definition at line 2004 of file qgsprocessingutils.cpp.

Member Function Documentation

◆ addFeature()

bool QgsProcessingFeatureSink::addFeature ( QgsFeature feature,
QgsFeatureSink::Flags  flags = QgsFeatureSink::Flags() 
)
overridevirtual

Adds a single feature to the sink.

Feature addition behavior is controlled by the specified flags.

See also
addFeatures()
Returns
true in case of success and false in case of failure

Reimplemented from QgsFeatureSink.

Definition at line 2026 of file qgsprocessingutils.cpp.

◆ addFeatures() [1/2]

bool QgsProcessingFeatureSink::addFeatures ( QgsFeatureIterator iterator,
QgsFeatureSink::Flags  flags = QgsFeatureSink::Flags() 
)
overridevirtual

Adds all features from the specified iterator to the sink.

Feature addition behavior is controlled by the specified flags.

Returns
true if all features were added successfully, or false if any feature could not be added

Reimplemented from QgsFeatureSink.

Definition at line 2054 of file qgsprocessingutils.cpp.

◆ addFeatures() [2/2]

bool QgsProcessingFeatureSink::addFeatures ( QgsFeatureList features,
QgsFeatureSink::Flags  flags = QgsFeatureSink::Flags() 
)
overridevirtual

Adds a list of features to the sink.

Feature addition behavior is controlled by the specified flags.

See also
addFeature()
Returns
true in case of success and false in case of failure

Implements QgsFeatureSink.

Definition at line 2040 of file qgsprocessingutils.cpp.

◆ finalize()

void QgsProcessingFeatureSink::finalize ( )
overridevirtual

Finalizes the sink, flushing any buffered features to the destination.

Warning
All algorithms which use feature sinks should explicitly call finalize() prior to destroying the sink!
Exceptions
QgsProcessingExceptionif an error occurs while finalizing the sink
Since
QGIS 3.42

Reimplemented from QgsFeatureSink.

Definition at line 2018 of file qgsprocessingutils.cpp.


The documentation for this class was generated from the following files: