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 );
624 void setAttribute(
const QString &name,
const QVariant &value / GetWrapper / );
626 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
627 if ( fieldIdx == -1 )
629 PyErr_SetString( PyExc_KeyError, a0->toLatin1() );
634 if ( a1Wrapper == Py_None )
636 sipCpp->setAttribute( *a0, QVariant( QVariant::Int ) );
640 sipCpp->setAttribute( fieldIdx, *a1 );
657 bool deleteAttribute(
const QString &name );
689 bool deleteAttribute(
const QString &name );
691 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
692 if ( fieldIdx == -1 )
694 PyErr_SetString( PyExc_KeyError, a0->toLatin1() );
700 sipCpp->deleteAttribute( fieldIdx );
717 QVariant attribute(
const QString &name )
const;
745 SIP_PYOBJECT attribute(
const QString &name )
const;
747 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
748 if ( fieldIdx == -1 )
750 PyErr_SetString( PyExc_KeyError, a0->toLatin1() );
755 QVariant *v =
new QVariant( sipCpp->attribute( fieldIdx ) );
756 sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
770 QVariant attribute(
int fieldIdx )
const;
797 SIP_PYOBJECT attribute(
int fieldIdx )
const;
800 if ( a0 < 0 || a0 >= sipCpp->attributes().count() )
802 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
807 QVariant *v =
new QVariant( sipCpp->attribute( a0 ) );
808 sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
823 bool isUnsetValue(
int fieldIdx )
const;
833 bool isUnsetValue(
int fieldIdx )
const;
836 if ( a0 < 0 || a0 >= sipCpp->attributes().count() )
838 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
843 sipRes = sipCpp->isUnsetValue( a0 );
874 int fieldNameIndex(
const QString &fieldName )
const;
885 int approximateMemoryUsage()
const;
888 operator QVariant()
const
890 return QVariant::fromValue( *
this );
895 QExplicitlySharedDataPointer<QgsFeaturePrivate> d;