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>();
 
 
 
  155  % ConvertFromTypeCode
 
  159  if ( ( l = PyList_New( sipCpp->size() ) ) == NULL )
 
  163  for ( 
int i = 0; i < sipCpp->size(); ++i )
 
  165    const QVariant v = sipCpp->at( i );
 
  166    PyObject *tobj = NULL;
 
  169      Py_INCREF( Py_None );
 
  175      PyObject *vartype = sipConvertFromEnum( v.type(), sipType_QVariant_Type );
 
  176      PyObject *args = PyTuple_Pack( 1, vartype );
 
  177      PyTypeObject *typeObj = sipTypeAsPyTypeObject( sipType_QVariant );
 
  178      tobj = PyObject_Call( ( PyObject * )typeObj, args, 
nullptr );
 
  180      Py_DECREF( vartype );
 
  184      switch ( v.userType() )
 
  186        case QMetaType::Type::Int:
 
  187          tobj = PyLong_FromLong( v.toInt() );
 
  190        case QMetaType::Type::UInt:
 
  191          tobj = PyLong_FromUnsignedLong( v.toUInt() );
 
  194        case QMetaType::Type::Long:
 
  195        case QMetaType::Type::LongLong:
 
  196          tobj = PyLong_FromLongLong( v.toLongLong() );
 
  199        case QMetaType::Type::ULong:
 
  200        case QMetaType::Type::ULongLong:
 
  201          tobj = PyLong_FromUnsignedLongLong( v.toULongLong() );
 
  204        case QMetaType::Type::Bool:
 
  205          tobj = PyBool_FromLong( v.toBool() ? 1 : 0 );
 
  208        case QMetaType::Type::Float:
 
  209        case QMetaType::Type::Double:
 
  210          tobj = PyFloat_FromDouble( v.toDouble() );
 
  213        case QMetaType::Type::QString:
 
  214          tobj = PyUnicode_FromString( v.toString().toUtf8().constData() );
 
  219          QVariant *newV = 
new QVariant( v );
 
  220          tobj = sipConvertFromNewType( newV, sipType_QVariant, sipTransferObj );
 
  231    PyList_SET_ITEM( l, i, tobj );
 
  239  if ( sipIsErr == NULL )
 
  241    if ( !PyList_Check( sipPy ) )
 
  244    for ( SIP_SSIZE_T i = 0; i < PyList_GET_SIZE( sipPy ); ++i )
 
  245      if ( !sipCanConvertToType( PyList_GET_ITEM( sipPy, i ), sipType_QVariant, SIP_NOT_NONE ) )
 
  251  SIP_SSIZE_T listSize = PyList_GET_SIZE( sipPy );
 
  255  const QVariant nullVariant( QVariant::Int );
 
  257  QVariant *outData = qv->data();
 
  259  for ( SIP_SSIZE_T i = 0; i < listSize; ++i )
 
  261    PyObject *obj = PyList_GET_ITEM( sipPy, i );
 
  262    if ( obj == Py_None )
 
  267    else if ( PyBool_Check( obj ) )
 
  269      *outData++ = QVariant( PyObject_IsTrue( obj ) == 1 );
 
  271    else if ( PyLong_Check( obj ) )
 
  273      *outData++ = QVariant( PyLong_AsLongLong( obj ) );
 
  275    else if ( PyFloat_Check( obj ) )
 
  277      *outData++ = QVariant( PyFloat_AsDouble( obj ) );
 
  279    else if ( PyUnicode_Check( obj ) )
 
  281      *outData++ = QVariant( QString::fromUtf8( PyUnicode_AsUTF8( obj ) ) );
 
  286      QVariant *t = 
reinterpret_cast<QVariant *
>( sipConvertToType( obj, sipType_QVariant, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr ) );
 
  290        sipReleaseType( t, sipType_QVariant, state );
 
  297      sipReleaseType( t, sipType_QVariant, state );
 
  303  return sipGetState( sipTransferObj );
 
  319  % ConvertFromTypeCode
 
  323  if ( ( l = PyList_New( sipCpp->size() ) ) == NULL )
 
  327  for ( 
int i = 0; i < sipCpp->size(); ++i )
 
  329    const QVariant v = sipCpp->at( i );
 
  330    PyObject *tobj = NULL;
 
  334      Py_INCREF( Py_None );
 
  339      switch ( v.userType() )
 
  341        case QMetaType::Type::Int:
 
  342          tobj = PyLong_FromLong( v.toInt() );
 
  345        case QMetaType::Type::UInt:
 
  346          tobj = PyLong_FromUnsignedLong( v.toUInt() );
 
  349        case QMetaType::Type::Long:
 
  350        case QMetaType::Type::LongLong:
 
  351          tobj = PyLong_FromLongLong( v.toLongLong() );
 
  354        case QMetaType::Type::ULong:
 
  355        case QMetaType::Type::ULongLong:
 
  356          tobj = PyLong_FromUnsignedLongLong( v.toULongLong() );
 
  359        case QMetaType::Type::Bool:
 
  360          tobj = PyBool_FromLong( v.toBool() ? 1 : 0 );
 
  363        case QMetaType::Type::Float:
 
  364        case QMetaType::Type::Double:
 
  365          tobj = PyFloat_FromDouble( v.toDouble() );
 
  368        case QMetaType::Type::QString:
 
  369          tobj = PyUnicode_FromString( v.toString().toUtf8().constData() );
 
  374          QVariant *newV = 
new QVariant( v );
 
  375          tobj = sipConvertFromNewType( newV, sipType_QVariant, sipTransferObj );
 
  386    PyList_SET_ITEM( l, i, tobj );
 
  394  if ( sipIsErr == NULL )
 
  396    if ( !PyList_Check( sipPy ) )
 
  399    for ( SIP_SSIZE_T i = 0; i < PyList_GET_SIZE( sipPy ); ++i )
 
  400      if ( !sipCanConvertToType( PyList_GET_ITEM( sipPy, i ), sipType_QVariant, SIP_NOT_NONE ) )
 
  406  SIP_SSIZE_T listSize = PyList_GET_SIZE( sipPy );
 
  410  const QVariant nullVariant( QVariant::Int );
 
  412  QVariant *outData = qv->data();
 
  414  for ( SIP_SSIZE_T i = 0; i < listSize; ++i )
 
  416    PyObject *obj = PyList_GET_ITEM( sipPy, i );
 
  417    if ( obj == Py_None )
 
  422    else if ( PyBool_Check( obj ) )
 
  424      *outData++ = QVariant( PyObject_IsTrue( obj ) == 1 );
 
  426    else if ( PyLong_Check( obj ) )
 
  428      *outData++ = QVariant( PyLong_AsLongLong( obj ) );
 
  430    else if ( PyFloat_Check( obj ) )
 
  432      *outData++ = QVariant( PyFloat_AsDouble( obj ) );
 
  434    else if ( PyUnicode_Check( obj ) )
 
  436      *outData++ = QVariant( QString::fromUtf8( PyUnicode_AsUTF8( obj ) ) );
 
  441      QVariant *t = 
reinterpret_cast<QVariant *
>( sipConvertToType( obj, sipType_QVariant, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr ) );
 
  445        sipReleaseType( t, sipType_QVariant, state );
 
  452      sipReleaseType( t, sipType_QVariant, state );
 
  458  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