26 d =
new QgsFeaturePrivate(
id );
31 d =
new QgsFeaturePrivate(
id );
59 d->attributes.remove( field );
76 d->ownsGeometry =
false;
97 if ( attrs == d->attributes )
101 d->attributes = attrs;
116 QgsFeaturePrivate* old_d = d.
data();
117 bool ownedGeom = d->ownsGeometry;
121 d->ownsGeometry =
false;
125 if ( old_d != d.
data() )
127 old_d->ownsGeometry = ownedGeom;
129 else if ( ownedGeom )
135 d->ownsGeometry =
true;
164 return &( d->fields );
175 if ( d->valid == validity )
185 d->attributes.resize( fieldCount );
187 for (
int i = 0; i < fieldCount; ++i, ++ptr )
194 if ( idx < 0 || idx >= d->attributes.size() )
201 d->attributes[idx] = value;
208 if ( fieldIdx == -1 )
212 d->attributes[fieldIdx] = value;
219 if ( fieldIdx == -1 )
223 d->attributes[fieldIdx].clear();
229 if ( fieldIdx < 0 || fieldIdx >= d->attributes.count() )
232 return d->attributes[fieldIdx];
239 if ( fieldIdx == -1 )
242 return d->attributes[fieldIdx];
247 return d->fields.fieldNameIndex( fieldName );
273 in >>
id >> attr >> *geometry >> valid;
QgsFeatureId id() const
Get the feature ID for this feature.
bool isValid() const
Returns the validity of this feature.
int fieldNameIndex(const QString &fieldName) const
Utility method to get attribute index from name.
virtual ~QgsFeature()
Destructor.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
bool setAttribute(int field, const QVariant &attr)
Set an attribute's value by field index.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QString tr(const char *sourceText, const char *disambiguation, int n)
QDataStream & operator>>(QDataStream &in, QgsFeature &feature)
Reads a feature from stream in into feature.
static void logMessage(QString message, QString tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
void setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object.
void deleteAttribute(int field)
Deletes an attribute and its value.
void setFeatureId(QgsFeatureId id)
Sets the feature ID for this feature.
QgsAttributes attributes() const
Returns the feature's attributes.
QDataStream & operator<<(QDataStream &out, const QgsFeature &feature)
Writes the feature to stream out.
void initAttributes(int fieldCount)
Initialize this feature with the given number of fields.
const QgsFields * fields() const
Returns the field map associated with the feature.
QgsFeature & operator=(QgsFeature const &rhs)
Assignment operator.
Q_DECL_DEPRECATED void setFields(const QgsFields *fields, bool initAttributes=false)
Assign a field map with the feature to allow attribute access by attribute name.
QgsFeature(QgsFeatureId id=QgsFeatureId())
Constructor for QgsFeature.
QgsGeometry * geometry()
Get the geometry object associated with this feature.
void setValid(bool validity)
Sets the validity of the feature.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
void fromWkb(unsigned char *wkb, size_t length)
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length...
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
Q_DECL_DEPRECATED QgsGeometry * geometryAndOwnership()
Get the geometry object associated with this feature, and transfer ownership of the geometry to the c...
void setGeometryAndOwnership(unsigned char *geom, size_t length)
Set this feature's geometry from WKB.