summaryrefslogtreecommitdiffstats
path: root/doc/html/qsqlfieldinfo.html
blob: 744acaed05a52a4d0520a3d0674886d25a0d829f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/sql/qsqlfield.cpp:304 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QSqlFieldInfo Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QSqlFieldInfo Class Reference<br><small>[<a href="sql.html">sql module</a>]</small></h1>

<p>The QSqlFieldInfo class stores meta data associated with a SQL field.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qsqlfield-h.html">qsqlfield.h</a>&gt;</tt>
<p><a href="qsqlfieldinfo-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#QSqlFieldInfo"><b>QSqlFieldInfo</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name = QString::null, QVariant::Type&nbsp;typ = QVariant::Invalid, int&nbsp;required = -1, int&nbsp;len = -1, int&nbsp;prec = -1, const&nbsp;QVariant&nbsp;&amp;&nbsp;defValue = QVariant ( ), int&nbsp;typeID = 0, bool&nbsp;generated = TRUE, bool&nbsp;trim = FALSE, bool&nbsp;calculated = FALSE )</li>
<li class=fn><a href="#QSqlFieldInfo-2"><b>QSqlFieldInfo</b></a> ( const&nbsp;QSqlFieldInfo&nbsp;&amp;&nbsp;other )</li>
<li class=fn><a href="#QSqlFieldInfo-3"><b>QSqlFieldInfo</b></a> ( const&nbsp;QSqlField&nbsp;&amp;&nbsp;other, bool&nbsp;generated = TRUE )</li>
<li class=fn>virtual <a href="#~QSqlFieldInfo"><b>~QSqlFieldInfo</b></a> ()</li>
<li class=fn>QSqlFieldInfo &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QSqlFieldInfo&nbsp;&amp;&nbsp;other )</li>
<li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const&nbsp;QSqlFieldInfo&nbsp;&amp;&nbsp;f ) const</li>
<li class=fn>QSqlField <a href="#toField"><b>toField</b></a> () const</li>
<li class=fn>int <a href="#isRequired"><b>isRequired</b></a> () const</li>
<li class=fn>QVariant::Type <a href="#type"><b>type</b></a> () const</li>
<li class=fn>int <a href="#length"><b>length</b></a> () const</li>
<li class=fn>int <a href="#precision"><b>precision</b></a> () const</li>
<li class=fn>QVariant <a href="#defaultValue"><b>defaultValue</b></a> () const</li>
<li class=fn>QString <a href="#name"><b>name</b></a> () const</li>
<li class=fn>int <a href="#typeID"><b>typeID</b></a> () const</li>
<li class=fn>bool <a href="#isGenerated"><b>isGenerated</b></a> () const</li>
<li class=fn>bool <a href="#isTrim"><b>isTrim</b></a> () const</li>
<li class=fn>bool <a href="#isCalculated"><b>isCalculated</b></a> () const</li>
<li class=fn>virtual void <a href="#setTrim"><b>setTrim</b></a> ( bool&nbsp;trim )</li>
<li class=fn>virtual void <a href="#setGenerated"><b>setGenerated</b></a> ( bool&nbsp;gen )</li>
<li class=fn>virtual void <a href="#setCalculated"><b>setCalculated</b></a> ( bool&nbsp;calc )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


The QSqlFieldInfo class stores meta data associated with a SQL field.
<p> 

<p> QSqlFieldInfo objects only store meta data; field values are
stored in <a href="qsqlfield.html">QSqlField</a> objects.
<p> All values must be set in the constructor, and may be retrieved
using <a href="#isRequired">isRequired</a>(), <a href="#type">type</a>(), <a href="#length">length</a>(), <a href="#precision">precision</a>(), <a href="#defaultValue">defaultValue</a>(),
<a href="#name">name</a>(), <a href="#isGenerated">isGenerated</a>() and <a href="#typeID">typeID</a>().
<p>See also <a href="database.html">Database Classes</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QSqlFieldInfo"></a>QSqlFieldInfo::QSqlFieldInfo ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name = QString::null, <a href="qvariant.html#Type-enum">QVariant::Type</a>&nbsp;typ = QVariant::Invalid, int&nbsp;required = -1, int&nbsp;len = -1, int&nbsp;prec = -1, const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;defValue = QVariant ( ), int&nbsp;typeID = 0, bool&nbsp;generated = TRUE, bool&nbsp;trim = FALSE, bool&nbsp;calculated = FALSE )
</h3>
Constructs a QSqlFieldInfo with the following parameters:
<center><table cellpadding="4" cellspacing="2" border="0">
<tr bgcolor="#f0f0f0"> <td valign="top"><em>name</em>  <td valign="top">the name of the field.
<tr bgcolor="#d0d0d0"> <td valign="top"><em>typ</em>   <td valign="top">the field's type in a <a href="qvariant.html">QVariant</a>.
<tr bgcolor="#f0f0f0"> <td valign="top"><em>required</em>  <td valign="top">greater than 0 if the field is required, 0
if its value can be NULL and less than 0 if it cannot be
determined whether the field is required or not.
<tr bgcolor="#d0d0d0"> <td valign="top"><em>len</em>  <td valign="top">the length of the field. Note that for
non-character types some databases return either the length in
bytes or the number of digits. -1 signifies that the length cannot
be determined.
<tr bgcolor="#f0f0f0"> <td valign="top"><em>prec</em>  <td valign="top">the precision of the field, or -1 if the field
has no precision or it cannot be determined.
<tr bgcolor="#d0d0d0"> <td valign="top"><em>defValue</em>  <td valign="top">the default value that is inserted into
the table if none is specified by the user. QVariant() if there is
no default value or it cannot be determined.
<tr bgcolor="#f0f0f0"> <td valign="top"><em>typeID</em>  <td valign="top">the internal typeID of the database system
(only useful for low-level programming). 0 if unknown.
<tr bgcolor="#d0d0d0"> <td valign="top"><em>generated</em>  <td valign="top">TRUE indicates that this field should be
included in auto-generated SQL statments, e.g. in <a href="qsqlcursor.html">QSqlCursor</a>.
<tr bgcolor="#f0f0f0"> <td valign="top"><em>trim</em>  <td valign="top">TRUE indicates that widgets should remove
trailing whitespace from character fields. This does not affect
the field value but only its representation inside widgets.
<tr bgcolor="#d0d0d0"> <td valign="top"><em>calculated</em>  <td valign="top">TRUE indicates that the value of this
field is calculated. The value of calculated fields can by
modified by subclassing QSqlCursor and overriding
<a href="qsqlcursor.html#calculateField">QSqlCursor::calculateField</a>().
</table></center>

<h3 class=fn><a name="QSqlFieldInfo-2"></a>QSqlFieldInfo::QSqlFieldInfo ( const&nbsp;<a href="qsqlfieldinfo.html">QSqlFieldInfo</a>&nbsp;&amp;&nbsp;other )
</h3>
Constructs a copy of <em>other</em>.

<h3 class=fn><a name="QSqlFieldInfo-3"></a>QSqlFieldInfo::QSqlFieldInfo ( const&nbsp;<a href="qsqlfield.html">QSqlField</a>&nbsp;&amp;&nbsp;other, bool&nbsp;generated = TRUE )
</h3>
Creates a QSqlFieldInfo object with the type and the name of the
<a href="qsqlfield.html">QSqlField</a> <em>other</em>. If <em>generated</em> is TRUE this field will be
included in auto-generated SQL statments, e.g. in <a href="qsqlcursor.html">QSqlCursor</a>.

<h3 class=fn><a name="~QSqlFieldInfo"></a>QSqlFieldInfo::~QSqlFieldInfo ()<tt> [virtual]</tt>
</h3>
Destroys the object and frees any allocated resources.

<h3 class=fn><a href="qvariant.html">QVariant</a> <a name="defaultValue"></a>QSqlFieldInfo::defaultValue () const
</h3>
Returns the field's default value or an empty <a href="qvariant.html">QVariant</a> if the
field has no default value or the value couldn't be determined.
The default value is the value inserted in the database when it
is not explicitly specified by the user.

<h3 class=fn>bool <a name="isCalculated"></a>QSqlFieldInfo::isCalculated () const
</h3>
Returns TRUE if the field is calculated; otherwise returns FALSE.
<p> <p>See also <a href="#setCalculated">setCalculated</a>().

<h3 class=fn>bool <a name="isGenerated"></a>QSqlFieldInfo::isGenerated () const
</h3>
Returns TRUE if the field should be included in auto-generated
SQL statments, e.g. in <a href="qsqlcursor.html">QSqlCursor</a>; otherwise returns FALSE.
<p> <p>See also <a href="#setGenerated">setGenerated</a>().

<h3 class=fn>int <a name="isRequired"></a>QSqlFieldInfo::isRequired () const
</h3>
Returns a value greater than 0 if the field is required (NULL
values are not allowed), 0 if it isn't required (NULL values are
allowed) or less than 0 if it cannot be determined whether the
field is required or not.

<h3 class=fn>bool <a name="isTrim"></a>QSqlFieldInfo::isTrim () const
</h3>
Returns TRUE if trailing whitespace should be removed from
character fields; otherwise returns FALSE.
<p> <p>See also <a href="#setTrim">setTrim</a>().

<h3 class=fn>int <a name="length"></a>QSqlFieldInfo::length () const
</h3>
Returns the field's length. For fields storing text the return
value is the maximum number of characters the field can hold. For
non-character fields some database systems return the number of
bytes needed or the number of digits allowed. If the length cannot
be determined -1 is returned.

<h3 class=fn><a href="qstring.html">QString</a> <a name="name"></a>QSqlFieldInfo::name () const
</h3>
Returns the name of the field in the SQL table.

<p>Examples: <a href="sql.html#x2260">sql/overview/subclass3/main.cpp</a> and <a href="sql.html#x2264">sql/overview/subclass4/main.cpp</a>.
<h3 class=fn><a href="qsqlfieldinfo.html">QSqlFieldInfo</a>&nbsp;&amp; <a name="operator-eq"></a>QSqlFieldInfo::operator= ( const&nbsp;<a href="qsqlfieldinfo.html">QSqlFieldInfo</a>&nbsp;&amp;&nbsp;other )
</h3>
Assigns <em>other</em> to this field info and returns a reference to it.

<h3 class=fn>bool <a name="operator-eq-eq"></a>QSqlFieldInfo::operator== ( const&nbsp;<a href="qsqlfieldinfo.html">QSqlFieldInfo</a>&nbsp;&amp;&nbsp;f ) const
</h3>
Returns TRUE if this fieldinfo is equal to <em>f</em>; otherwise returns
FALSE.
<p> Two field infos are considered equal if all their attributes
match.

<h3 class=fn>int <a name="precision"></a>QSqlFieldInfo::precision () const
</h3>
Returns the field's precision or -1 if the field has no precision
or it cannot be determined.

<h3 class=fn>void <a name="setCalculated"></a>QSqlFieldInfo::setCalculated ( bool&nbsp;calc )<tt> [virtual]</tt>
</h3>
<em>calc</em> set to TRUE indicates that this field is a calculated
field. The value of calculated fields can by modified by subclassing
<a href="qsqlcursor.html">QSqlCursor</a> and overriding <a href="qsqlcursor.html#calculateField">QSqlCursor::calculateField</a>().
<p> <p>See also <a href="#isCalculated">isCalculated</a>().

<h3 class=fn>void <a name="setGenerated"></a>QSqlFieldInfo::setGenerated ( bool&nbsp;gen )<tt> [virtual]</tt>
</h3>
<em>gen</em> set to FALSE indicates that this field should not appear
in auto-generated SQL statements (for example in <a href="qsqlcursor.html">QSqlCursor</a>).
<p> <p>See also <a href="#isGenerated">isGenerated</a>().

<h3 class=fn>void <a name="setTrim"></a>QSqlFieldInfo::setTrim ( bool&nbsp;trim )<tt> [virtual]</tt>
</h3>
If <em>trim</em> is TRUE widgets should remove trailing whitespace from
character fields. This does not affect the field value but only
its representation inside widgets.
<p> <p>See also <a href="#isTrim">isTrim</a>().

<h3 class=fn><a href="qsqlfield.html">QSqlField</a> <a name="toField"></a>QSqlFieldInfo::toField () const
</h3>
Returns an empty <a href="qsqlfield.html">QSqlField</a> based on the information in this
QSqlFieldInfo.

<h3 class=fn><a href="qvariant.html#Type-enum">QVariant::Type</a> <a name="type"></a>QSqlFieldInfo::type () const
</h3>
Returns the field's type or QVariant::Invalid if the type is
unknown.

<h3 class=fn>int <a name="typeID"></a>QSqlFieldInfo::typeID () const
</h3>
Returns the internal type identifier as returned from the database
system. The return value is 0 if the type is unknown.
<p> <b>Warning:</b> This information is only useful for low-level database
programming and is <em>not</em> database independent.

<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt 3.3.8</div>
</table></div></address></body>
</html>