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

  1. /****************************************************************************
  2. **
  3. ** Definition of QSqlField 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 QSQLFIELD_H
  38. #define QSQLFIELD_H
  39.  
  40. #ifndef QT_H
  41. #include "qstring.h"
  42. #include "qvariant.h"
  43. #endif // QT_H
  44.  
  45. #if !defined( QT_MODULE_SQL ) || defined( QT_LICENSE_PROFESSIONAL )
  46. #define QM_EXPORT_SQL
  47. #else
  48. #define QM_EXPORT_SQL Q_EXPORT
  49. #endif
  50.  
  51. #ifndef QT_NO_SQL
  52.  
  53. class QSqlFieldPrivate;
  54.  
  55. class QM_EXPORT_SQL QSqlField
  56. {
  57. public:
  58.     QSqlField( const QString& fieldName = QString::null, QVariant::Type type = QVariant::Invalid );
  59.     QSqlField( const QSqlField& other );
  60.     QSqlField& operator=( const QSqlField& other );
  61.     bool operator==(const QSqlField& other) const;
  62.     virtual ~QSqlField();
  63.  
  64.     virtual void    setValue( const QVariant& value );
  65.     virtual QVariant    value() const;
  66.     virtual void    setName( const QString& name );
  67.     QString        name() const;
  68.     virtual void    setNull();
  69.     bool        isNull() const;
  70.     virtual void    setReadOnly( bool readOnly );
  71.     bool        isReadOnly() const;
  72.     void        clear( bool nullify = TRUE );
  73.     QVariant::Type    type() const;
  74.  
  75. private:
  76.     QString       nm;
  77.     QVariant      val;
  78.     uint          ro: 1;
  79.     uint          nul: 1;
  80.     QSqlFieldPrivate* d;
  81. };
  82.  
  83. inline QVariant QSqlField::value() const
  84. { return val; }
  85.  
  86. inline QString QSqlField::name() const
  87. { return nm; }
  88.  
  89. inline bool QSqlField::isNull() const
  90. { return nul; }
  91.  
  92. inline bool QSqlField::isReadOnly() const
  93. { return ro; }
  94.  
  95. inline QVariant::Type QSqlField::type() const
  96. { return val.type(); }
  97.  
  98.  
  99. /******************************************/
  100. /*******     QSqlFieldInfo Class     ******/
  101. /******************************************/
  102.  
  103. struct QSqlFieldInfoPrivate;
  104.  
  105. class QM_EXPORT_SQL QSqlFieldInfo
  106. {
  107. public:
  108.     QSqlFieldInfo( const QString& name = QString::null,
  109.            QVariant::Type typ = QVariant::Invalid,
  110.            int required = -1,
  111.            int len = -1,
  112.            int prec = -1,
  113.            const QVariant& defValue = QVariant(),
  114.            int sqlType = 0,
  115.            bool generated = TRUE,
  116.            bool trim = FALSE,
  117.            bool calculated = FALSE );
  118.     QSqlFieldInfo( const QSqlFieldInfo & other );
  119.     QSqlFieldInfo( const QSqlField & other, bool generated = TRUE );
  120.     virtual ~QSqlFieldInfo();
  121.     QSqlFieldInfo& operator=( const QSqlFieldInfo& other );
  122.     bool operator==( const QSqlFieldInfo& f ) const;
  123.  
  124.     QSqlField        toField() const;
  125.     int            isRequired() const;
  126.     QVariant::Type    type() const;
  127.     int            length() const;
  128.     int            precision() const;
  129.     QVariant        defaultValue() const;
  130.     QString        name() const;
  131.     int            typeID() const;
  132.     bool        isGenerated() const;
  133.     bool        isTrim() const;
  134.     bool        isCalculated() const;
  135.  
  136.     virtual void    setTrim( bool trim );
  137.     virtual void    setGenerated( bool gen );
  138.     virtual void    setCalculated( bool calc );
  139.  
  140. private:
  141.     QSqlFieldInfoPrivate* d;
  142. };
  143.  
  144.  
  145. #endif    // QT_NO_SQL
  146. #endif
  147.