22#include <QExplicitlySharedDataPointer>
35class QgsFeaturePrivate;
58#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c01)
59#define sipType_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
65 Q_PROPERTY(
QgsAttributes attributes READ attributes WRITE setAttributes )
66 Q_PROPERTY(
QgsFields fields READ fields WRITE setFields )
67 Q_PROPERTY(
QgsGeometry geometry READ geometry WRITE setGeometry )
72 SIP_PYOBJECT __iter__();
75 PyObject *attrs = sipConvertFromType( &attributes, sipType_QgsAttributes, Py_None );
76 sipRes = PyObject_GetIter( attrs );
79 SIP_PYOBJECT __getitem__(
int key );
82 if ( a0 < 0 || a0 >= attrs.count() )
84 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
89 QVariant *v =
new QVariant( attrs.at( a0 ) );
90 sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
94 SIP_PYOBJECT __getitem__(
const QString &name );
96 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
99 PyErr_SetString( PyExc_KeyError, a0->toLatin1() );
104 QVariant *v =
new QVariant( sipCpp->attribute( fieldIdx ) );
105 sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
109 void __setitem__(
int key, QVariant value / GetWrapper / );
113 if ( a1Wrapper == Py_None )
115 rv = sipCpp->setAttribute( a0, QVariant( QVariant::Int ) );
119 rv = sipCpp->setAttribute( a0, *a1 );
124 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
129 void __setitem__(
const QString &key, QVariant value / GetWrapper / );
131 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
132 if ( fieldIdx == -1 )
134 PyErr_SetString( PyExc_KeyError, a0->toLatin1() );
139 if ( a1Wrapper == Py_None )
141 sipCpp->setAttribute( *a0, QVariant( QVariant::Int ) );
145 sipCpp->setAttribute( fieldIdx, *a1 );
150 void __delitem__(
int key );
152 if ( a0 >= 0 && a0 < sipCpp->attributes().count() )
153 sipCpp->deleteAttribute( a0 );
156 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
161 void __delitem__(
const QString &name );
163 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
164 if ( fieldIdx == -1 )
166 PyErr_SetString( PyExc_KeyError, a0->toLatin1() );
170 sipCpp->deleteAttribute( fieldIdx );
173 long __hash__()
const;
175 sipRes =
qHash( *sipCpp );
268 QVariantMap attributeMap()
const;
282 SIP_PYOBJECT attributeMap() const
SIP_TYPEHINT( Dict[
str, Optional[
object]] );
284 const
int fieldSize = sipCpp->fields().size();
285 const
int attributeSize = sipCpp->attributes().size();
286 if ( fieldSize == 0 && attributeSize != 0 )
288 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Field definition has not been set for feature" ).toUtf8().constData() );
291 else if ( fieldSize != attributeSize )
293 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Feature attribute size (%1) does not match number of fields (%2)" ).arg( attributeSize ).arg( fieldSize ).toUtf8().constData() );
298 QVariantMap *v =
new QVariantMap( sipCpp->attributeMap() );
299 sipRes = sipConvertFromNewType( v, sipType_QVariantMap, Py_None );
308 int attributeCount()
const;
340 bool setAttribute(
int field,
const QVariant &attr );
367 bool setAttribute(
int field,
const QVariant &attr / GetWrapper / );
371 if ( a1Wrapper == Py_None )
373 rv = sipCpp->setAttribute( a0, QVariant( QVariant::Int ) );
377 rv = sipCpp->setAttribute( a0, *a1 );
382 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
399 void initAttributes(
int fieldCount );
414 void resizeAttributes(
int fieldCount );
422 void padAttributes(
int count );
433 void deleteAttribute(
int field );
460 void deleteAttribute(
int field );
462 if ( a0 >= 0 && a0 < sipCpp->attributes().count() )
463 sipCpp->deleteAttribute( a0 );
466 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
480 bool isValid()
const;
489 void setValid(
bool validity );
496 bool hasGeometry()
const;
548 void setGeometry( std::unique_ptr< QgsAbstractGeometry > geometry );
552 sipCpp->setGeometry( std::unique_ptr< QgsAbstractGeometry>( a0 ) );
562 void clearGeometry();
595 bool setAttribute(
const QString &name,
const QVariant &value );
626 void setAttribute(
const QString &name,
const QVariant &value / GetWrapper / );
628 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
629 if ( fieldIdx == -1 )
631 PyErr_SetString( PyExc_KeyError, a0->toLatin1() );
636 if ( a1Wrapper == Py_None )
638 sipCpp->setAttribute( *a0, QVariant( QVariant::Int ) );
642 sipCpp->setAttribute( fieldIdx, *a1 );
659 bool deleteAttribute(
const QString &name );
691 bool deleteAttribute(
const QString &name );
693 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
694 if ( fieldIdx == -1 )
696 PyErr_SetString( PyExc_KeyError, a0->toLatin1() );
702 sipCpp->deleteAttribute( fieldIdx );
719 QVariant attribute(
const QString &name )
const;
747 SIP_PYOBJECT attribute(
const QString &name )
const;
749 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
750 if ( fieldIdx == -1 )
752 PyErr_SetString( PyExc_KeyError, a0->toLatin1() );
757 QVariant *v =
new QVariant( sipCpp->attribute( fieldIdx ) );
758 sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
772 QVariant attribute(
int fieldIdx )
const;
799 SIP_PYOBJECT attribute(
int fieldIdx )
const;
802 if ( a0 < 0 || a0 >= sipCpp->attributes().count() )
804 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
809 QVariant *v =
new QVariant( sipCpp->attribute( a0 ) );
810 sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
825 bool isUnsetValue(
int fieldIdx )
const;
835 bool isUnsetValue(
int fieldIdx )
const;
838 if ( a0 < 0 || a0 >= sipCpp->attributes().count() )
840 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
845 sipRes = sipCpp->isUnsetValue( a0 );
876 int fieldNameIndex(
const QString &fieldName )
const;
887 int approximateMemoryUsage()
const;
890 operator QVariant()
const
892 return QVariant::fromValue( *
this );
897 QExplicitlySharedDataPointer<QgsFeaturePrivate> d;
Abstract base class for all geometries.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
A rectangle specified with double values.
Abstract base class for all rendered symbols.
#define SIP_TYPEHINT(type)
#define SIP_PYARGDEFAULT(value)
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
CORE_EXPORT uint qHash(const QgsFeature &key, uint seed=0)
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
CORE_EXPORT QDataStream & operator<<(QDataStream &out, const QgsFeature &feature)
Writes the feature to stream out. QGIS version compatibility is not guaranteed.
CORE_EXPORT QDataStream & operator>>(QDataStream &in, QgsFeature &feature)
Reads a feature from stream in into feature. QGIS version compatibility is not guaranteed.
QList< QgsFeature > QgsFeatureList
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)