21 #include "qgis_core.h"
24 class QgsFieldsPrivate;
77 int originIndex = -1 ;
103 bool append(
const QgsField &field,
FieldOrigin origin = OriginProvider,
int originIndex = -1 );
109 bool rename(
int fieldIdx,
const QString &name );
112 bool appendExpressionField(
const QgsField &field,
int originIndex );
115 void remove(
int fieldIdx );
118 if ( a0 < 0 || a0 >= sipCpp->count() )
120 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
125 sipCpp->remove( a0 );
134 bool isEmpty()
const;
142 sipRes = sipCpp->count();
146 int __bool__()
const;
159 QStringList names()
const;
166 bool exists(
int i )
const;
177 SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->count() );
181 sipRes =
new QgsField( sipCpp->operator[]( idx ) );
189 if ( a0 < 0 || a0 >= sipCpp->count() )
191 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
196 sipRes =
new QgsField( sipCpp->at( a0 ) );
205 if ( a0 < 0 || a0 >= sipCpp->count() )
207 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
212 sipRes =
new QgsField( sipCpp->field( a0 ) );
221 int fieldIdx = sipCpp->indexFromName( *a0 );
222 if ( fieldIdx == -1 )
224 PyErr_SetString( PyExc_KeyError, a0->toLatin1() );
229 sipRes =
new QgsField( sipCpp->field( *a0 ) );
235 FieldOrigin fieldOrigin(
int fieldIdx )
const;
238 if ( a0 < 0 || a0 >= sipCpp->count() )
240 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
245 sipRes = sipCpp->fieldOrigin( a0 );
251 int fieldOriginIndex(
int fieldIdx )
const;
254 if ( a0 < 0 || a0 >= sipCpp->count() )
256 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
261 sipRes = sipCpp->fieldOriginIndex( a0 );
277 int indexFromName(
const QString &fieldName )
const;
290 int indexOf(
const QString &fieldName )
const;
306 int lookupField(
const QString &fieldName )
const;
315 QList<QgsField> toList()
const;
326 QIcon iconForField(
int fieldIdx )
const SIP_FACTORY;
329 if ( a0 < 0 || a0 >= sipCpp->count() )
331 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
336 sipRes =
new QIcon( sipCpp->iconForField( a0 ) );
342 operator QVariant()
const
344 return QVariant::fromValue( *
this );
349 void __setitem__(
int key,
const QgsField &field );
351 int idx = ( int )sipConvertFromSequenceIndex( a0, sipCpp->count() );
355 ( *sipCpp )[idx] = *a1;
364 class const_iterator;
370 typedef std::random_access_iterator_tag iterator_category;
371 typedef qptrdiff difference_type;
382 inline QgsField &operator[]( difference_type j )
const {
return d[j].
field; }
383 inline bool operator==(
const iterator &o )
const noexcept {
return d == o.d; }
384 inline bool operator!=(
const iterator &o )
const noexcept {
return d != o.d; }
385 inline bool operator<(
const iterator &other )
const noexcept {
return d < other.d; }
386 inline bool operator<=(
const iterator &other )
const noexcept {
return d <= other.d; }
387 inline bool operator>(
const iterator &other )
const noexcept {
return d > other.d; }
388 inline bool operator>=(
const iterator &other )
const noexcept {
return d >= other.d; }
390 inline iterator &operator++() { ++d;
return *
this; }
391 inline iterator operator++(
int ) {
QgsFields::Field *n = d; ++d;
return n; }
392 inline iterator &operator--() { d--;
return *
this; }
393 inline iterator operator--(
int ) {
QgsFields::Field *n = d; d--;
return n; }
394 inline iterator &operator+=( difference_type j ) { d += j;
return *
this; }
395 inline iterator &operator-=( difference_type j ) { d -= j;
return *
this; }
396 inline iterator
operator+( difference_type j )
const {
return iterator( d + j ); }
397 inline iterator
operator-( difference_type j )
const {
return iterator( d - j ); }
398 inline int operator-( iterator j )
const {
return int( d - j.d ); }
400 friend class iterator;
407 typedef std::random_access_iterator_tag iterator_category;
408 typedef qptrdiff difference_type;
410 inline const_iterator()
415 inline const_iterator(
const const_iterator &o )
417 inline explicit const_iterator(
const iterator &o )
420 inline const QgsField *operator->()
const {
return &d->
field; }
421 inline const QgsField &operator[]( difference_type j )
const noexcept {
return d[j].
field; }
422 inline bool operator==(
const const_iterator &o )
const noexcept {
return d == o.d; }
423 inline bool operator!=(
const const_iterator &o )
const noexcept {
return d != o.d; }
424 inline bool operator<(
const const_iterator &other )
const noexcept {
return d < other.d; }
425 inline bool operator<=(
const const_iterator &other )
const noexcept {
return d <= other.d; }
426 inline bool operator>(
const const_iterator &other )
const noexcept {
return d > other.d; }
427 inline bool operator>=(
const const_iterator &other )
const noexcept {
return d >= other.d; }
428 inline const_iterator &operator++() { ++d;
return *
this; }
429 inline const_iterator operator++(
int ) {
const QgsFields::Field *n = d; ++d;
return n; }
430 inline const_iterator &operator--() { d--;
return *
this; }
431 inline const_iterator operator--(
int ) {
const QgsFields::Field *n = d; --d;
return n; }
432 inline const_iterator &operator+=( difference_type j ) { d += j;
return *
this; }
433 inline const_iterator &operator-=( difference_type j ) { d -= j;
return *
this; }
434 inline const_iterator
operator+( difference_type j )
const {
return const_iterator( d + j ); }
435 inline const_iterator
operator-( difference_type j )
const {
return const_iterator( d - j ); }
436 inline int operator-( const_iterator j )
const {
return int( d - j.d ); }
438 const_iterator &operator= (
const const_iterator & ) =
delete;
440 friend class const_iterator;
450 const_iterator constBegin() const noexcept;
458 const_iterator constEnd() const noexcept;
466 const_iterator begin() const noexcept;
474 const_iterator end() const noexcept;
497 QSharedDataPointer<QgsFieldsPrivate> d;
508 #endif // QGSFIELDS_H