18#ifndef QGSATTRIBUTES_H
19#define QGSATTRIBUTES_H
30#include <QExplicitlySharedDataPointer>
40class QgsFeaturePrivate;
49typedef QMap<int, QgsField> QgsFieldMap;
71 : QVector<QVariant>( size )
80 : QVector<QVariant>( size, v )
88 : QVector<QVariant>( v )
102 if ( size() != v.size() )
104 const QVariant *b = constData();
105 const QVariant *i = b + size();
106 const QVariant *j = v.constData() + size();
131 if ( index < 0 || index >= size() )
134 return at( index ).userType() == qMetaTypeId<QgsUnsetAttributeValue>();
152 % ConvertFromTypeCode
156 if ( ( l = PyList_New( sipCpp->size() ) ) == NULL )
160 for (
int i = 0; i < sipCpp->size(); ++i )
162 QVariant *v =
new QVariant( sipCpp->at( i ) );
165 if ( ( tobj = sipConvertFromNewType( v, sipType_QVariant, Py_None ) ) == NULL )
173 PyList_SET_ITEM( l, i, tobj );
181 if ( sipIsErr == NULL )
183 if ( !PyList_Check( sipPy ) )
186 for ( SIP_SSIZE_T i = 0; i < PyList_GET_SIZE( sipPy ); ++i )
187 if ( !sipCanConvertToType( PyList_GET_ITEM( sipPy, i ), sipType_QVariant, SIP_NOT_NONE ) )
193 SIP_SSIZE_T listSize = PyList_GET_SIZE( sipPy );
197 const QVariant nullVariant( QVariant::Int );
199 QVariant *outData = qv->data();
201 for ( SIP_SSIZE_T i = 0; i < listSize; ++i )
203 PyObject *obj = PyList_GET_ITEM( sipPy, i );
204 if ( obj == Py_None )
209 else if ( PyBool_Check( obj ) )
211 *outData++ = QVariant( PyObject_IsTrue( obj ) == 1 );
213 else if ( PyLong_Check( obj ) )
215 *outData++ = QVariant( PyLong_AsLongLong( obj ) );
217 else if ( PyFloat_Check( obj ) )
219 *outData++ = QVariant( PyFloat_AsDouble( obj ) );
221 else if ( PyUnicode_Check( obj ) )
223 *outData++ = QVariant( QString::fromUtf8( PyUnicode_AsUTF8( obj ) ) );
228 QVariant *t =
reinterpret_cast<QVariant *
>( sipConvertToType( obj, sipType_QVariant, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr ) );
232 sipReleaseType( t, sipType_QVariant, state );
239 sipReleaseType( t, sipType_QVariant, state );
245 return sipGetState( sipTransferObj );
bool operator!=(const QgsAttributes &v) const
QgsAttributes(int size)
Create a new vector of attributes with the given size.
bool isUnsetValue(int index) const
Returns true if the attribute at the specified index is an unset value.
QgsAttributes(int size, const QVariant &v)
Constructs a vector with an initial size of size elements.
bool operator==(const QgsAttributes &v) const
Compares two vectors of attributes.
QgsAttributes(const QVector< QVariant > &v)
Copies another vector of attributes.
CORE_EXPORT QgsAttributeMap toMap() const
Returns a QgsAttributeMap of the attribute values.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
A rectangle specified with double values.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
CORE_EXPORT uint qHash(const QgsAttributes &attributes)
Hash for QgsAttributes.
QMap< int, QString > QgsFieldNameMap
QMap< int, QVariant > QgsAttributeMap