home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qsqlrecord.h < prev    next >
C/C++ Source or Header  |  2001-08-20  |  5KB  |  130 lines

  1. /****************************************************************************
  2. **
  3. ** Definition of QSqlRecord class
  4. **
  5. ** Created : 2000-11-03
  6. **
  7. ** Copyright (C) 2000 Trolltech AS.  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 AS 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.  
  49. class QSqlRecordPrivate;
  50.  
  51. class QSqlRecordShared : public QShared
  52. {
  53. public:
  54.     QSqlRecordShared( QSqlRecordPrivate* sqlRecordPrivate )
  55.     : d( sqlRecordPrivate )
  56.     {}
  57.     virtual ~QSqlRecordShared();
  58.     QSqlRecordPrivate* d;
  59. };
  60.  
  61. class Q_EXPORT QSqlRecord
  62. {
  63. public:
  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 );
  79.     bool                 isNull( const QString& name );
  80.  
  81.     int                  position( const QString& name ) const;
  82.     QString              fieldName( int i ) const;
  83.     QSqlField*           field( int i );
  84.     QSqlField*           field( const QString& name );
  85.     const QSqlField*     field( int i ) const;
  86.     const QSqlField*     field( const QString& name ) const;
  87.  
  88.     virtual void         append( const QSqlField& field );
  89.     virtual void         insert( int pos, const QSqlField& field );
  90.     virtual void         remove( int pos );
  91.  
  92.     bool                 isEmpty() const;
  93.     bool                 contains( const QString& name ) const;
  94.     virtual void         clear();
  95.     virtual void         clearValues( bool nullify = FALSE );
  96.     uint                 count() const;
  97.     virtual QString      toString( const QString& prefix = QString::null,
  98.                    const QString& sep = "," ) const;
  99.     virtual QStringList  toStringList( const QString& prefix = QString::null ) const;
  100.  
  101. private:
  102.     QString              createField( int i, const QString& prefix ) const;
  103.     void                 deref();
  104.     bool                 checkDetach();
  105.     QSqlRecordShared*    sh;
  106. };
  107.  
  108. /******************************************/
  109. /*******     QSqlRecordInfo Class    ******/
  110. /******************************************/
  111.  
  112. typedef QValueList<QSqlFieldInfo> QSqlFieldInfoList;
  113.  
  114. class Q_EXPORT QSqlRecordInfo: public QSqlFieldInfoList
  115. {
  116. public:
  117.     QSqlRecordInfo(): QSqlFieldInfoList() {}
  118.     QSqlRecordInfo( const QSqlFieldInfoList& other ): QSqlFieldInfoList( other ) {}
  119.     QSqlRecordInfo( const QSqlRecord& other );
  120.  
  121.     size_type contains( const QString& fieldName ) const;
  122.     QSqlFieldInfo find( const QString& fieldName ) const;
  123.     QSqlRecord toRecord() const;
  124.  
  125. };
  126.  
  127.  
  128. #endif    // QT_NO_SQL
  129. #endif
  130.