QgsField Class Reference
[QGIS core library]

Encapsulate a field in an attribute table or data source. More...

#include <qgsfield.h>

List of all members.

Public Member Functions

 QgsField (QString name=QString(), QVariant::Type type=QVariant::Invalid, QString typeName=QString(), int len=0, int prec=0, QString comment=QString())
 Constructor.
 ~QgsField ()
 Destructor.
bool operator== (const QgsField &other) const
const QString & name () const
 Gets the name of the field.
QVariant::Type type () const
 Gets variant type of the field as it will be retrieved from data source.
const QString & typeName () const
 Gets the field type.
int length () const
 Gets the length of the field.
int precision () const
 Gets the precision of the field.
const QString & comment () const
 Returns the field comment.
void setName (const QString &nam)
 Set the field name.
void setType (QVariant::Type type)
 Set variant type.
void setTypeName (const QString &typ)
 Set the field type.
void setLength (int len)
 Set the field length.
void setPrecision (int prec)
 Set the field precision.
void setComment (const QString &comment)
 Set the field comment.

Private Attributes

QString mName
 Name.
QVariant::Type mType
 Variant type.
QString mTypeName
 Type name from provider.
int mLength
 Length.
int mPrecision
 Precision.
QString mComment
 Comment.


Detailed Description

Encapsulate a field in an attribute table or data source.

QgsField stores metadata about an attribute field, including name, type length, and if applicable, precision.

Definition at line 29 of file qgsfield.h.


Constructor & Destructor Documentation

QgsField::QgsField ( QString  name = QString(),
QVariant::Type  type = QVariant::Invalid,
QString  typeName = QString(),
int  len = 0,
int  prec = 0,
QString  comment = QString() 
)

Constructor.

Constructs a new QgsField object.

Parameters:
name Field name
type Field variant type, currently supported: String / Int / Double
typeName Field type (eg. char, varchar, text, int, serial, double). Field types are usually unique to the source and are stored exactly as returned from the data store.
len Field length
prec Field precision. Usually decimal places but may also be used in conjunction with other fields types (eg. variable character fields)
comment Comment for the field

Definition at line 36 of file qgsfield.cpp.

QgsField::~QgsField (  ) 

Destructor.

Definition at line 43 of file qgsfield.cpp.


Member Function Documentation

bool QgsField::operator== ( const QgsField other  )  const

Definition at line 47 of file qgsfield.cpp.

References mLength, mName, mPrecision, mType, and mTypeName.

const QString & QgsField::name (  )  const

Gets the name of the field.

Definition at line 53 of file qgsfield.cpp.

References mName.

Referenced by QgsVectorLayer::addAttribute(), QgsOverlayAnalyzer::combineFieldLists(), and QgsVectorFileWriter::QgsVectorFileWriter().

QVariant::Type QgsField::type (  )  const

const QString & QgsField::typeName (  )  const

Gets the field type.

Field types vary depending on the data source. Examples are char, int, double, blob, geometry, etc. The type is stored exactly as the data store reports it, with no attenpt to standardize the value.

Returns:
QString containing the field type

Definition at line 63 of file qgsfield.cpp.

References mTypeName.

int QgsField::length (  )  const

Gets the length of the field.

Returns:
int containing the length of the field

Definition at line 68 of file qgsfield.cpp.

References mLength.

Referenced by QgsVectorDataProvider::supportedType().

int QgsField::precision (  )  const

Gets the precision of the field.

Not all field types have a related precision.

Returns:
int containing the precision or zero if not applicable to the field type.

Definition at line 73 of file qgsfield.cpp.

References mPrecision.

Referenced by QgsVectorDataProvider::supportedType().

const QString & QgsField::comment (  )  const

Returns the field comment.

Definition at line 78 of file qgsfield.cpp.

References mComment.

void QgsField::setName ( const QString &  nam  ) 

Set the field name.

Parameters:
nam Name of the field

Definition at line 83 of file qgsfield.cpp.

References mName.

void QgsField::setType ( QVariant::Type  type  ) 

Set variant type.

Definition at line 88 of file qgsfield.cpp.

References mType.

void QgsField::setTypeName ( const QString &  typ  ) 

Set the field type.

Parameters:
typ Field type

Definition at line 93 of file qgsfield.cpp.

References mTypeName.

void QgsField::setLength ( int  len  ) 

Set the field length.

Parameters:
len Length of the field

Definition at line 98 of file qgsfield.cpp.

References mLength.

void QgsField::setPrecision ( int  prec  ) 

Set the field precision.

Parameters:
prec Precision of the field

Definition at line 102 of file qgsfield.cpp.

References mPrecision.

void QgsField::setComment ( const QString &  comment  ) 

Set the field comment.

Definition at line 107 of file qgsfield.cpp.

References mComment.


Member Data Documentation

QString QgsField::mName [private]

Name.

Definition at line 127 of file qgsfield.h.

Referenced by name(), operator==(), and setName().

QVariant::Type QgsField::mType [private]

Variant type.

Definition at line 130 of file qgsfield.h.

Referenced by operator==(), setType(), and type().

QString QgsField::mTypeName [private]

Type name from provider.

Definition at line 133 of file qgsfield.h.

Referenced by operator==(), setTypeName(), and typeName().

int QgsField::mLength [private]

Length.

Definition at line 136 of file qgsfield.h.

Referenced by length(), operator==(), and setLength().

int QgsField::mPrecision [private]

Precision.

Definition at line 139 of file qgsfield.h.

Referenced by operator==(), precision(), and setPrecision().

QString QgsField::mComment [private]

Comment.

Definition at line 142 of file qgsfield.h.

Referenced by comment(), and setComment().


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

Generated on Sat Feb 4 19:17:33 2012 for Quantum GIS API Documentation by  doxygen 1.5.6