~ubuntu-branches/ubuntu/hardy/qgis/hardy

« back to all changes in this revision

Viewing changes to src/core/qgsfield.h

  • Committer: Bazaar Package Importer
  • Author(s): William Grant
  • Date: 2007-05-06 13:42:32 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070506134232-pyli6t388w5asd8x
Tags: 0.8.0-3ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
  - debian/rules, debian/qgis.install, debian/qgis.dirs debian/qgis.desktop:
    Add and install .desktop.
* debian/qgis.desktop: Remove Applications category; it's not real.
* Modify Maintainer value to match Debian-Maintainer-Field Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
               qgsfield.h - Describes a field in a layer or table
 
3
                     --------------------------------------
 
4
               Date                 : 01-Jan-2004
 
5
               Copyright            : (C) 2004 by Gary E.Sherman
 
6
               email                : sherman at mrcc.com
 
7
 ***************************************************************************
 
8
 *                                                                         *
 
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.                                   *
 
13
 *                                                                         *
 
14
 ***************************************************************************/
 
15
/* $Id: qgsfield.h 4502 2006-01-08 01:18:20Z timlinux $ */
 
16
 
 
17
#ifndef QGSFIELD_H
 
18
#define QGSFIELD_H
 
19
 
 
20
#include <qstring.h>
 
21
 
 
22
/**
 
23
  \class QgsField
 
24
  \brief Class to encapsulate a field in an attribute table or data source.
 
25
 
 
26
  QgsField stores metadata about an attribute field, including name, type
 
27
  length, and if applicable, precision.
 
28
 */
 
29
 
 
30
class QgsField
 
31
{
 
32
public:
 
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.
 
42
     */
 
43
  QgsField(QString nam = "", QString typ = "", int len = 0, int prec = 0, bool num = false);
 
44
 
 
45
  //! Destructor
 
46
   ~QgsField();
 
47
 
 
48
   bool operator==(const QgsField other) const;
 
49
   bool operator!=(const QgsField other) const;
 
50
 
 
51
  //! Gets the name of the field
 
52
  QString const & name() const;
 
53
 
 
54
 
 
55
    /** 
 
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
 
60
     */
 
61
  QString const & type() const;
 
62
 
 
63
 
 
64
    /**
 
65
      Gets the length of the field.
 
66
      @return int containing the length of the field
 
67
     */
 
68
  int length() const;
 
69
 
 
70
 
 
71
    /**
 
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.
 
74
     */
 
75
  int precision() const;
 
76
 
 
77
    /**
 
78
     Returns true if field contains numeric values. This information is set by provider.
 
79
     */
 
80
  bool isNumeric() const;
 
81
 
 
82
 
 
83
    /**
 
84
      Set the field name.
 
85
      @param nam Name of the field
 
86
     */
 
87
  void setName(QString const & nam);
 
88
 
 
89
    /**
 
90
      Set the field type.
 
91
      @param typ Field type
 
92
     */
 
93
  void setType(QString const & typ);
 
94
 
 
95
    /**
 
96
      Set the field length.
 
97
      @param len Length of the field
 
98
     */
 
99
  void setLength(int len);
 
100
 
 
101
    /**
 
102
      Set the field precision.
 
103
      @param prec Precision of the field
 
104
     */
 
105
  void setPrecision(int prec);
 
106
 
 
107
    /**
 
108
      Set whether field is numeric
 
109
      */
 
110
  void setNumeric(bool num);
 
111
 
 
112
private:
 
113
 
 
114
  //! Name
 
115
  QString mName;
 
116
 
 
117
  //! Type
 
118
  QString mType;
 
119
 
 
120
  //! Length
 
121
  int mLength;
 
122
 
 
123
  //! Precision
 
124
  int mPrecision;
 
125
 
 
126
  //! Numeric
 
127
  bool mNumeric;
 
128
 
 
129
}; // class QgsField
 
130
 
 
131
#endif