19 #include "qgis_core.h" 22 #include <QExplicitlySharedDataPointer> 34 class QgsFeaturePrivate;
50 #define FID_IS_NEW(fid) (fid<0) 51 #define FID_TO_NUMBER(fid) static_cast<qint64>(fid) 52 #define FID_TO_STRING(fid) QString::number( fid ) 53 #define STRING_TO_FID(str) (str).toLongLong() 65 #if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c01) 66 #define sipType_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant)) 72 Q_PROPERTY(
QgsAttributes attributes READ attributes WRITE setAttributes )
73 Q_PROPERTY(
QgsFields fields READ fields WRITE setFields )
78 SIP_PYOBJECT __iter__();
81 PyObject *attrs = sipConvertFromType( &attributes, sipType_QgsAttributes, Py_None );
82 sipRes = PyObject_GetIter( attrs );
85 SIP_PYOBJECT __getitem__(
int key );
88 if ( a0 < 0 || a0 >= attrs.count() )
90 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
95 QVariant *v =
new QVariant( attrs.at( a0 ) );
96 sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
100 SIP_PYOBJECT __getitem__(
const QString &name );
102 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
103 if ( fieldIdx == -1 )
105 PyErr_SetString( PyExc_KeyError, a0->toAscii() );
110 QVariant *v =
new QVariant( sipCpp->attribute( fieldIdx ) );
111 sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
115 void __setitem__(
int key, QVariant value / GetWrapper / );
119 if ( a1Wrapper == Py_None )
121 rv = sipCpp->setAttribute( a0, QVariant( QVariant::Int ) );
125 rv = sipCpp->setAttribute( a0, *a1 );
130 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
135 void __setitem__(
const QString &key, QVariant value / GetWrapper / );
137 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
138 if ( fieldIdx == -1 )
140 PyErr_SetString( PyExc_KeyError, a0->toAscii() );
145 if ( a1Wrapper == Py_None )
147 sipCpp->setAttribute( *a0, QVariant( QVariant::Int ) );
151 sipCpp->setAttribute( fieldIdx, *a1 );
156 void __delitem__(
int key );
158 if ( a0 >= 0 && a0 < sipCpp->attributes().count() )
159 sipCpp->deleteAttribute( a0 );
162 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
167 void __delitem__(
const QString &name );
169 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
170 if ( fieldIdx == -1 )
172 PyErr_SetString( PyExc_KeyError, a0->toAscii() );
176 sipCpp->deleteAttribute( fieldIdx );
266 bool setAttribute(
int field,
const QVariant &attr );
268 bool setAttribute(
int field,
const QVariant &attr / GetWrapper / );
272 if ( a1Wrapper == Py_None )
274 rv = sipCpp->setAttribute( a0, QVariant( QVariant::Int ) );
278 rv = sipCpp->setAttribute( a0, *a1 );
283 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
295 void initAttributes(
int fieldCount );
304 void deleteAttribute(
int field );
307 if ( a0 >= 0 && a0 < sipCpp->attributes().count() )
308 sipCpp->deleteAttribute( a0 );
311 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
323 bool isValid()
const;
330 void setValid(
bool validity );
337 bool hasGeometry()
const;
361 void clearGeometry();
392 bool setAttribute(
const QString &name,
const QVariant &value );
394 void setAttribute(
const QString &name,
const QVariant &value / GetWrapper / );
396 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
397 if ( fieldIdx == -1 )
399 PyErr_SetString( PyExc_KeyError, a0->toAscii() );
404 if ( a1Wrapper == Py_None )
406 sipCpp->setAttribute( *a0, QVariant( QVariant::Int ) );
410 sipCpp->setAttribute( fieldIdx, *a1 );
425 bool deleteAttribute(
const QString &name );
428 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
429 if ( fieldIdx == -1 )
431 PyErr_SetString( PyExc_KeyError, a0->toAscii() );
437 sipCpp->deleteAttribute( fieldIdx );
453 QVariant attribute(
const QString &name )
const;
455 SIP_PYOBJECT attribute(
const QString &name )
const;
457 int fieldIdx = sipCpp->fieldNameIndex( *a0 );
458 if ( fieldIdx == -1 )
460 PyErr_SetString( PyExc_KeyError, a0->toAscii() );
465 QVariant *v =
new QVariant( sipCpp->attribute( fieldIdx ) );
466 sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
481 QVariant attribute(
int fieldIdx )
const;
483 SIP_PYOBJECT attribute(
int fieldIdx )
const;
486 if ( a0 < 0 || a0 >= sipCpp->attributes().count() )
488 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
493 QVariant *v =
new QVariant( sipCpp->attribute( a0 ) );
494 sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
507 int fieldNameIndex(
const QString &fieldName )
const;
510 operator QVariant()
const 512 return QVariant::fromValue( *
this );
517 QExplicitlySharedDataPointer<QgsFeaturePrivate> d;
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
A rectangle specified with double values.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QSet< QgsFeatureId > QgsFeatureIds
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(QModelIndex)
void seed(uint32_t value)
Encapsulate a field in an attribute table or data source.
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)