1
/***************************************************************************
2
qgsfield.h - Describes a field in a layer or table
3
--------------------------------------
5
Copyright : (C) 2004 by Gary E.Sherman
6
email : sherman at mrcc.com
7
***************************************************************************
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
14
***************************************************************************/
15
/* $Id: qgsfield.h 4502 2006-01-08 01:18:20Z timlinux $ */
24
\brief Class to encapsulate a field in an attribute table or data source.
26
QgsField stores metadata about an attribute field, including name, type
27
length, and if applicable, precision.
33
/** Constructor. Constructs a new QgsField object.
34
* @param nam Field name
35
* @param typ Field type (eg. char, varchar, text, int, serial, double).
36
Field types are usually unique to the source and are stored exactly
37
as returned from the data store.
38
* @param len Field length
39
* @param prec Field precision. Usually decimal places but may also be
40
* used in conjunction with other fields types (eg. variable character fields)
41
* @param num Has to be true if field contains numeric values.
43
QgsField(QString nam = "", QString typ = "", int len = 0, int prec = 0, bool num = false);
48
bool operator==(const QgsField other) const;
49
bool operator!=(const QgsField other) const;
51
//! Gets the name of the field
52
QString const & name() const;
56
Gets the field type. Field types vary depending on the data source. Examples
57
are char, int, double, blob, geometry, etc. The type is stored exactly as
58
the data store reports it, with no attenpt to standardize the value.
59
@return QString containing the field type
61
QString const & type() const;
65
Gets the length of the field.
66
@return int containing the length of the field
72
Gets the precision of the field. Not all field types have a related precision.
73
@return int containing the precision or zero if not applicable to the field type.
75
int precision() const;
78
Returns true if field contains numeric values. This information is set by provider.
80
bool isNumeric() const;
85
@param nam Name of the field
87
void setName(QString const & nam);
93
void setType(QString const & typ);
97
@param len Length of the field
99
void setLength(int len);
102
Set the field precision.
103
@param prec Precision of the field
105
void setPrecision(int prec);
108
Set whether field is numeric
110
void setNumeric(bool num);