QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
QgsFields Class Reference

Container of fields for a vector layer. More...

#include <qgsfield.h>

Classes

struct  Field
 

Public Types

enum  FieldOrigin {
  OriginUnknown, OriginProvider, OriginJoin, OriginEdit,
  OriginExpression
}
 
typedef struct QgsFields::Field Field
 

Public Member Functions

void clear ()
 Remove all fields. More...
 
bool append (const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
 Append a field. The field must have unique name, otherwise it is rejected (returns false) More...
 
bool appendExpressionField (const QgsField &field, int originIndex)
 Append an expression field. The field must have unique name, otherwise it is rejected (returns false) More...
 
void remove (int fieldIdx)
 Remove a field with the given index. More...
 
void extend (const QgsFields &other)
 Extend with fields from another QgsFields container. More...
 
bool isEmpty () const
 Check whether the container is empty. More...
 
int count () const
 Return number of items. More...
 
int size () const
 Return number of items. More...
 
bool exists (int i) const
 Return if a field index is valid. More...
 
const QgsFieldoperator[] (int i) const
 Get field at particular index (must be in range 0..N-1) More...
 
QgsFieldoperator[] (int i)
 Get field at particular index (must be in range 0..N-1) More...
 
const QgsFieldat (int i) const
 Get field at particular index (must be in range 0..N-1) More...
 
const QgsFieldfield (int fieldIdx) const
 Get field at particular index (must be in range 0..N-1) More...
 
const QgsFieldfield (const QString &name) const
 Get field at particular index (must be in range 0..N-1) More...
 
FieldOrigin fieldOrigin (int fieldIdx) const
 Get field's origin (value from an enumeration) More...
 
int fieldOriginIndex (int fieldIdx) const
 Get field's origin index (its meaning is specific to each type of origin) More...
 
int indexFromName (const QString &name) const
 Look up field's index from name. Returns -1 on error. More...
 
int fieldNameIndex (const QString &fieldName) const
 Look up field's index from name - case insensitive TODO: sort out case sensitive (indexFromName()) vs insensitive (fieldNameIndex()) calls. More...
 
QgsAttributeList allAttributesList () const
 Utility function to get list of attribute indexes. More...
 
QList< QgsFieldtoList () const
 Utility function to return a list of QgsField instances. More...
 
bool operator== (const QgsFields &other) const
 
bool operator!= (const QgsFields &other) const
 

Protected Attributes

QVector< FieldmFields
 internal storage of the container More...
 
QHash< QString, int > mNameToIndex
 map for quick resolution of name to index More...
 

Detailed Description

Container of fields for a vector layer.

In addition to storing a list of QgsField instances, it also:

Member Typedef Documentation

Member Function Documentation

QgsAttributeList QgsFields::allAttributesList ( ) const

Utility function to get list of attribute indexes.

Note
added in 2.4
bool QgsFields::append ( const QgsField field,
FieldOrigin  origin = OriginProvider,
int  originIndex = -1 
)

Append a field. The field must have unique name, otherwise it is rejected (returns false)

bool QgsFields::appendExpressionField ( const QgsField field,
int  originIndex 
)

Append an expression field. The field must have unique name, otherwise it is rejected (returns false)

const QgsField& QgsFields::at ( int  i) const
inline

Get field at particular index (must be in range 0..N-1)

void QgsFields::clear ( )

Remove all fields.

int QgsFields::count ( ) const
inline

Return number of items.

bool QgsFields::exists ( int  i) const
inline

Return if a field index is valid.

Parameters
iIndex of the field which needs to be checked
Returns
True if the field exists
void QgsFields::extend ( const QgsFields other)

Extend with fields from another QgsFields container.

const QgsField& QgsFields::field ( int  fieldIdx) const
inline

Get field at particular index (must be in range 0..N-1)

const QgsField& QgsFields::field ( const QString &  name) const
inline

Get field at particular index (must be in range 0..N-1)

int QgsFields::fieldNameIndex ( const QString &  fieldName) const

Look up field's index from name - case insensitive TODO: sort out case sensitive (indexFromName()) vs insensitive (fieldNameIndex()) calls.

Note
added in 2.4
FieldOrigin QgsFields::fieldOrigin ( int  fieldIdx) const
inline

Get field's origin (value from an enumeration)

int QgsFields::fieldOriginIndex ( int  fieldIdx) const
inline

Get field's origin index (its meaning is specific to each type of origin)

int QgsFields::indexFromName ( const QString &  name) const
inline

Look up field's index from name. Returns -1 on error.

bool QgsFields::isEmpty ( ) const
inline

Check whether the container is empty.

bool QgsFields::operator!= ( const QgsFields other) const
inline
Note
added in 2.6
bool QgsFields::operator== ( const QgsFields other) const
inline
Note
added in 2.6
const QgsField& QgsFields::operator[] ( int  i) const
inline

Get field at particular index (must be in range 0..N-1)

QgsField& QgsFields::operator[] ( int  i)
inline

Get field at particular index (must be in range 0..N-1)

void QgsFields::remove ( int  fieldIdx)

Remove a field with the given index.

int QgsFields::size ( ) const
inline

Return number of items.

QList< QgsField > QgsFields::toList ( ) const

Utility function to return a list of QgsField instances.

Member Data Documentation

QVector<Field> QgsFields::mFields
protected

internal storage of the container

QHash<QString, int> QgsFields::mNameToIndex
protected

map for quick resolution of name to index


The documentation for this class was generated from the following files: