source: trunk/include/qsqlrecord.h

Last change on this file was 196, checked in by rudi, 14 years ago

Add SQL module (currently it isn't build by default, however it's needed for QtDesigner)

File size: 4.8 KB
Line 
1/****************************************************************************
2**
3** Definition of QSqlRecord class
4**
5** Created : 2000-11-03
6**
7** Copyright (C) 2005-2007 Trolltech ASA. All rights reserved.
8**
9** This file is part of the sql module of the Qt GUI Toolkit.
10**
11** This file may be distributed under the terms of the Q Public License
12** as defined by Trolltech ASA of Norway and appearing in the file
13** LICENSE.QPL included in the packaging of this file.
14**
15** This file may be distributed and/or modified under the terms of the
16** GNU General Public License version 2 as published by the Free Software
17** Foundation and appearing in the file LICENSE.GPL included in the
18** packaging of this file.
19**
20** Licensees holding valid Qt Enterprise Edition licenses may use this
21** file in accordance with the Qt Commercial License Agreement provided
22** with the Software.
23**
24** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26**
27** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
28** information about Qt Commercial License Agreements.
29** See http://www.trolltech.com/qpl/ for QPL licensing information.
30** See http://www.trolltech.com/gpl/ for GPL licensing information.
31**
32** Contact info@trolltech.com if any conditions of this licensing are
33** not clear to you.
34**
35**********************************************************************/
36
37#ifndef QSQLRECORD_H
38#define QSQLRECORD_H
39
40#ifndef QT_H
41#include "qstring.h"
42#include "qstringlist.h"
43#include "qvariant.h"
44#include "qsqlfield.h"
45#endif // QT_H
46
47#ifndef QT_NO_SQL
48
49class QSqlRecordPrivate;
50
51class QSqlRecordShared : public QShared
52{
53public:
54 QSqlRecordShared( QSqlRecordPrivate* sqlRecordPrivate )
55 : d( sqlRecordPrivate )
56 {}
57 virtual ~QSqlRecordShared();
58 QSqlRecordPrivate* d;
59};
60
61class Q_EXPORT QSqlRecord
62{
63public:
64 QSqlRecord();
65 QSqlRecord( const QSqlRecord& other );
66 QSqlRecord& operator=( const QSqlRecord& other );
67 virtual ~QSqlRecord();
68 virtual QVariant value( int i ) const;
69 virtual QVariant value( const QString& name ) const;
70 virtual void setValue( int i, const QVariant& val );
71 virtual void setValue( const QString& name, const QVariant& val );
72 bool isGenerated( int i ) const;
73 bool isGenerated( const QString& name ) const;
74 virtual void setGenerated( const QString& name, bool generated );
75 virtual void setGenerated( int i, bool generated );
76 virtual void setNull( int i );
77 virtual void setNull( const QString& name );
78 bool isNull( int i ); // remove in 4.0
79 bool isNull( const QString& name ); // remove in 4.0
80 bool isNull( int i ) const;
81 bool isNull( const QString& name ) const;
82
83 int position( const QString& name ) const;
84 QString fieldName( int i ) const;
85 QSqlField* field( int i );
86 QSqlField* field( const QString& name );
87 const QSqlField* field( int i ) const;
88 const QSqlField* field( const QString& name ) const;
89
90 virtual void append( const QSqlField& field );
91 virtual void insert( int pos, const QSqlField& field );
92 virtual void remove( int pos );
93
94 bool isEmpty() const;
95 bool contains( const QString& name ) const;
96 virtual void clear();
97 virtual void clearValues( bool nullify = FALSE );
98 uint count() const;
99 virtual QString toString( const QString& prefix = QString::null,
100 const QString& sep = "," ) const;
101 virtual QStringList toStringList( const QString& prefix = QString::null ) const;
102
103private:
104 QString createField( int i, const QString& prefix ) const;
105 void deref();
106 bool checkDetach();
107 QSqlRecordShared* sh;
108};
109
110/******************************************/
111/******* QSqlRecordInfo Class ******/
112/******************************************/
113
114#if defined(Q_TEMPLATEDLL)
115// MOC_SKIP_BEGIN
116Q_TEMPLATE_EXTERN template class Q_EXPORT QValueList<QSqlFieldInfo>;
117// MOC_SKIP_END
118#endif
119
120typedef QValueList<QSqlFieldInfo> QSqlFieldInfoList;
121
122class Q_EXPORT QSqlRecordInfo: public QSqlFieldInfoList
123{
124public:
125 QSqlRecordInfo(): QSqlFieldInfoList() {}
126 QSqlRecordInfo( const QSqlFieldInfoList& other ): QSqlFieldInfoList( other ) {}
127 QSqlRecordInfo( const QSqlRecord& other );
128
129 size_type contains( const QString& fieldName ) const;
130 QSqlFieldInfo find( const QString& fieldName ) const;
131 QSqlRecord toRecord() const;
132
133};
134
135
136#endif // QT_NO_SQL
137#endif
Note: See TracBrowser for help on using the repository browser.