QgsProxyFeatureSink class

A simple feature sink which proxies feature addition on to another feature sink.

This class is designed to allow factory methods which always return new QgsFeatureSink objects. Since it is not always possible to create an entirely new QgsFeatureSink (e.g. if the feature sink is a layer's data provider), a new QgsProxyFeatureSink can instead be returned which forwards features on to the destination sink. The proxy sink can be safely deleted without affecting the destination sink.

Base classes

class QgsFeatureSink
An interface for objects which accept features via addFeature(s) methods.

Derived classes

class QgsProcessingFeatureSink
QgsProxyFeatureSink subclass which reports feature addition errors to a QgsProcessingContext.

Constructors, destructors, conversion operators

QgsProxyFeatureSink(QgsFeatureSink* sink)
Constructs a new QgsProxyFeatureSink which forwards features onto a destination sink.

Public functions

auto addFeature(QgsFeature& feature, QgsFeatureSink::Flags flags = nullptr) -> bool override
Adds a single feature to the sink.
auto addFeatures(QgsFeatureList& features, QgsFeatureSink::Flags flags = nullptr) -> bool override
Adds a list of features to the sink.
auto addFeatures(QgsFeatureIterator& iterator, QgsFeatureSink::Flags flags = nullptr) -> bool override
Adds all features from the specified iterator to the sink.
auto destinationSink() -> QgsFeatureSink*
Returns the destination QgsFeatureSink which the proxy will forward features to.

Function documentation

bool QgsProxyFeatureSink::addFeature(QgsFeature& feature, QgsFeatureSink::Flags flags = nullptr) override

Adds a single feature to the sink.

Returns true in case of success and false in case of failure

Feature addition behavior is controlled by the specified flags.

bool QgsProxyFeatureSink::addFeatures(QgsFeatureList& features, QgsFeatureSink::Flags flags = nullptr) override

Adds a list of features to the sink.

Returns true in case of success and false in case of failure

Feature addition behavior is controlled by the specified flags.

bool QgsProxyFeatureSink::addFeatures(QgsFeatureIterator& iterator, QgsFeatureSink::Flags flags = nullptr) override

Adds all features from the specified iterator to the sink.

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

Feature addition behavior is controlled by the specified flags.