19 #include "qgis_core.h" 22 #include <QExplicitlySharedDataPointer> 35 class 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->toAscii() );
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->toAscii() );
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->toAscii() );
170 sipCpp->deleteAttribute( fieldIdx );
260 bool setAttribute(
int field,
const QVariant &attr );
262 bool setAttribute(
int field,
const QVariant &attr / GetWrapper / );
266 if ( a1Wrapper == Py_None )
268 rv = sipCpp->setAttribute( a0, QVariant( QVariant::Int ) );
272 rv = sipCpp->setAttribute( a0, *a1 );
277 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
289 void initAttributes(
int fieldCount );
298 void deleteAttribute(
int field );
301 if ( a0 >= 0 && a0 < sipCpp->attributes().count() )
302 sipCpp->deleteAttribute( a0 );
305 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
317 bool isValid()
const;
324 void setValid(
bool validity );
331 bool hasGeometry()
const;
376 void setGeometry( std::unique_ptr< QgsAbstractGeometry > geometry );
380 sipCpp->setGeometry( std::unique_ptr< QgsAbstractGeometry>( a0 ) );
390 void clearGeometry();
421 bool setAttribute(
const QString &name,
const QVariant &value );
423 void setAttribute(
const QString &name,
const QVariant &value / GetWrapper / );
425 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
426 if ( fieldIdx == -1 )
428 PyErr_SetString( PyExc_KeyError, a0->toAscii() );
433 if ( a1Wrapper == Py_None )
435 sipCpp->setAttribute( *a0, QVariant( QVariant::Int ) );
439 sipCpp->setAttribute( fieldIdx, *a1 );
454 bool deleteAttribute(
const QString &name );
457 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
458 if ( fieldIdx == -1 )
460 PyErr_SetString( PyExc_KeyError, a0->toAscii() );
466 sipCpp->deleteAttribute( fieldIdx );
482 QVariant attribute(
const QString &name )
const;
484 SIP_PYOBJECT attribute(
const QString &name )
const;
486 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
487 if ( fieldIdx == -1 )
489 PyErr_SetString( PyExc_KeyError, a0->toAscii() );
494 QVariant *v =
new QVariant( sipCpp->attribute( fieldIdx ) );
495 sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
510 QVariant attribute(
int fieldIdx )
const;
512 SIP_PYOBJECT attribute(
int fieldIdx )
const;
515 if ( a0 < 0 || a0 >= sipCpp->attributes().count() )
517 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
522 QVariant *v =
new QVariant( sipCpp->attribute( a0 ) );
523 sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
536 int fieldNameIndex(
const QString &fieldName )
const;
539 operator QVariant()
const 541 return QVariant::fromValue( *
this );
546 QExplicitlySharedDataPointer<QgsFeaturePrivate> d;
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
A rectangle specified with double values.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QList< QgsFeature > QgsFeatureList
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
Encapsulate a field in an attribute table or data source.
Abstract base class for all geometries.
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
uint qHash(const QgsFeature &key, uint seed=0)
CORE_EXPORT QDataStream & operator>>(QDataStream &in, QgsFeature &feature)
Reads a feature from stream in into feature. QGIS version compatibility is not guaranteed.
CORE_EXPORT QDataStream & operator<<(QDataStream &out, const QgsFeature &feature)
Writes the feature to stream out. QGIS version compatibility is not guaranteed.
#define SIP_PYARGDEFAULT(value)