Skip to content

Commit

Permalink
remove comments from sipfiles (QgsVectorLayer and QgsFeature)
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Mar 30, 2017
1 parent 0bdaf4f commit ba6f736
Show file tree
Hide file tree
Showing 2 changed files with 206 additions and 1,305 deletions.
170 changes: 23 additions & 147 deletions python/core/qgsfeature.sip
Expand Up @@ -20,7 +20,7 @@ typedef QVector<QVariant> QgsAttributes;
// Set the list elements.
for ( int i = 0; i < sipCpp->size(); ++i )
{
QVariant* v = new QVariant( sipCpp->at( i ) );
QVariant *v = new QVariant( sipCpp->at( i ) );
PyObject *tobj;

if ( ( tobj = sipConvertFromNewType( v, sipType_QVariant,Py_None ) ) == NULL )
Expand Down Expand Up @@ -51,12 +51,12 @@ typedef QVector<QVariant> QgsAttributes;
return 1;
}

QgsAttributes* qv = new QgsAttributes;
QgsAttributes *qv = new QgsAttributes;

for (SIP_SSIZE_T i = 0; i < PyList_GET_SIZE(sipPy); ++i)
{
int state;
PyObject* obj = PyList_GET_ITEM(sipPy, i);
PyObject *obj = PyList_GET_ITEM(sipPy, i);
QVariant *t;
if ( obj == Py_None )
{
Expand Down Expand Up @@ -143,12 +143,12 @@ class QgsFeature
}
else
{
QVariant* v = new QVariant( attrs.at(a0) );
QVariant *v = new QVariant( attrs.at(a0) );
sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
}
%End

SIP_PYOBJECT __getitem__(const QString& name);
SIP_PYOBJECT __getitem__(const QString &name);
%MethodCode
int fieldIdx = sipCpp->fieldNameIndex(*a0);
if (fieldIdx == -1)
Expand All @@ -158,7 +158,7 @@ class QgsFeature
}
else
{
QVariant* v = new QVariant( sipCpp->attribute(fieldIdx) );
QVariant *v = new QVariant( sipCpp->attribute(fieldIdx) );
sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
}
%End
Expand All @@ -183,7 +183,7 @@ class QgsFeature
}
%End

void __setitem__(const QString& key, QVariant value /GetWrapper/);
void __setitem__(const QString &key, QVariant value /GetWrapper/);
%MethodCode
int fieldIdx = sipCpp->fieldNameIndex(*a0);
if (fieldIdx == -1)
Expand Down Expand Up @@ -215,7 +215,7 @@ class QgsFeature
}
%End

void __delitem__(const QString& name);
void __delitem__(const QString &name);
%MethodCode
int fieldIdx = sipCpp->fieldNameIndex(*a0);
if (fieldIdx == -1)
Expand All @@ -227,60 +227,23 @@ class QgsFeature
sipCpp->deleteAttribute(fieldIdx);
%End

/** Constructor for QgsFeature
* @param id feature id
*/
QgsFeature( qint64 id = 0 );

/** Constructor for QgsFeature
* @param fields feature's fields
* @param id feature id
*/
QgsFeature( const QgsFields& fields, qint64 id = 0 );
QgsFeature( const QgsFields &fields, qint64 id = 0 );

/** Copy constructor
*/
QgsFeature( const QgsFeature & rhs );
QgsFeature( const QgsFeature &rhs );

~QgsFeature();

/** Get the feature ID for this feature.
* @returns feature ID
* @see setId()
*/
QgsFeatureId id() const;

/** Sets the feature ID for this feature.
* @param id feature id
* @see id
*/
void setId( QgsFeatureId id );

/** Returns the feature's attributes.
* @link attributes @endlink method.
* @returns list of feature's attributes
* @see setAttributes
* @note added in QGIS 2.9
* @note Alternatively in Python: iterate feature, eg. @code [attr for attr in feature] @endcode
*/
QgsAttributes attributes() const;

/** Sets the feature's attributes.
* @param attrs attribute list
* @see setAttribute
* @see attributes
*/
void setAttributes( const QgsAttributes& attrs );

/** Set an attribute's value by field index.
* @param field the index of the field to set
* @param attr the value of the attribute
* @return false, if the field index does not exist
* @note For Python: raises a KeyError exception instead of returning false
* @note Alternatively in Python: @code feature[field] = attr @endcode
* @see setAttributes
*/
bool setAttribute( int field, const QVariant& attr /GetWrapper/);
void setAttributes( const QgsAttributes &attrs );

bool setAttribute( int field, const QVariant &attr /GetWrapper/);
%MethodCode
bool rv;

Expand All @@ -302,17 +265,8 @@ class QgsFeature
sipRes = rv;
%End

/** Initialize this feature with the given number of fields. Discard any previously set attribute data.
* @param fieldCount Number of fields to initialize
*/
void initAttributes( int fieldCount );

/** Deletes an attribute and its value.
* @param field the index of the field
* @see setAttribute
* @note For Python: raises a KeyError exception if the field is not found
* @note Alternatively in Python: @code del feature[field] @endcode
*/
void deleteAttribute( int field );
%MethodCode
if ( a0 >= 0 && a0 < sipCpp->attributes().count() )
Expand All @@ -324,71 +278,23 @@ class QgsFeature
}
%End

/** Returns the validity of this feature. This is normally set by
* the provider to indicate some problem that makes the feature
* invalid or to indicate a null feature.
* @see setValid
*/
bool isValid() const;

/** Sets the validity of the feature.
* @param validity set to true if feature is valid
* @see isValid
*/
void setValid( bool validity );

/** Returns true if the feature has an associated geometry.
* @see geometry()
* @note added in QGIS 3.0.
*/
bool hasGeometry() const;

/** Returns the geometry associated with this feature. If the feature has no geometry,
* an empty QgsGeometry object will be returned.
* @see hasGeometry()
* @see setGeometry()
*/
QgsGeometry geometry() const;

/** Set the feature's geometry.
* @param geometry new feature geometry
* @see geometry()
* @see clearGeometry()
*/
void setGeometry( const QgsGeometry& geometry );

/** Removes any geometry associated with the feature.
* @see setGeometry()
* @see hasGeometry()
* @note added in QGIS 3.0
*/
void setGeometry( const QgsGeometry &geometry );

void clearGeometry();

/** Assign a field map with the feature to allow attribute access by attribute name.
* @param fields The attribute fields which this feature holds
* @param initAttributes If true, attributes are initialized. Clears any data previously assigned.
* C++: Defaults to false
* Python: Defaults to true
* @note added in QGIS 2.9
* @see fields
*/
void setFields( const QgsFields& fields, bool initAttributes = true );

/** Returns the field map associated with the feature.
* @see setFields
*/
void setFields( const QgsFields &fields, bool initAttributes = true );

QgsFields fields() const;

/** Insert a value into attribute. Returns false if attribute name could not be converted to index.
* Field map must be associated using @link setFields @endlink before this method can be used.
* @param name The name of the field to set
* @param value The value to set
* @return false if attribute name could not be converted to index (C++ only)
* @note For Python: raises a KeyError exception instead of returning false
* @note Alternatively in Python: @code feature[name] = attr @endcode
* @see setFields
*/
void setAttribute( const QString& name, const QVariant& value /GetWrapper/ );
void setAttribute( const QString &name, const QVariant &value /GetWrapper/ );
%MethodCode
int fieldIdx = sipCpp->fieldNameIndex(*a0);
if (fieldIdx == -1)
Expand All @@ -409,15 +315,7 @@ class QgsFeature
}
%End

/** Removes an attribute value by field name. Field map must be associated using @link setFields @endlink
* before this method can be used.
* @param name The name of the field to delete
* @return false if attribute name could not be converted to index (C++ only)
* @note For Python: raises a KeyError exception instead of returning false
* @note Alternatively in Python: @code del feature[name] @endcode
* @see setFields
*/
bool deleteAttribute( const QString& name );
bool deleteAttribute( const QString &name );
%MethodCode
int fieldIdx = sipCpp->fieldNameIndex(*a0);
if (fieldIdx == -1)
Expand All @@ -433,15 +331,7 @@ class QgsFeature
}
%End

/** Lookup attribute value from attribute name. Field map must be associated using @link setFields @endlink
* before this method can be used.
* @param name The name of the attribute to get
* @return The value of the attribute (C++: Invalid variant if no such name exists )
* @note For Python: raises a KeyError exception if the field is not found
* @note Alternatively in Python: @code feature[name] @endcode
* @see setFields
*/
SIP_PYOBJECT attribute( const QString& name ) const;
SIP_PYOBJECT attribute( const QString &name ) const;
%MethodCode
int fieldIdx = sipCpp->fieldNameIndex(*a0);
if (fieldIdx == -1)
Expand All @@ -451,19 +341,11 @@ class QgsFeature
}
else
{
QVariant* v = new QVariant( sipCpp->attribute(fieldIdx) );
QVariant *v = new QVariant( sipCpp->attribute(fieldIdx) );
sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
}
%End

/** Lookup attribute value from its index. Field map must be associated using @link setFields @endlink
* before this method can be used.
* @param fieldIdx The index of the attribute to get
* @return The value of the attribute (C++: Invalid variant if no such index exists )
* @note For Python: raises a KeyError exception if the field is not found
* @note Alternatively in Python: @code feature[fieldIdx] @endcode
* @see setFields
*/
SIP_PYOBJECT attribute( int fieldIdx ) const;
%MethodCode
{
Expand All @@ -474,19 +356,13 @@ class QgsFeature
}
else
{
QVariant* v = new QVariant( sipCpp->attribute(a0) );
QVariant *v = new QVariant( sipCpp->attribute(a0) );
sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
}
}
%End

/** Utility method to get attribute index from name. Field map must be associated using @link setFields @endlink
* before this method can be used.
* @param fieldName name of field to get attribute index of
* @returns -1 if field does not exist or field map is not associated.
* @see setFields
*/
int fieldNameIndex( const QString& fieldName ) const;
int fieldNameIndex( const QString &fieldName ) const;

//! Allows direct construction of QVariants from features.
operator QVariant() const;
Expand Down

0 comments on commit ba6f736

Please sign in to comment.