Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:09:18

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QSQLFIELD_H
0005 #define QSQLFIELD_H
0006 
0007 #include <QtSql/qtsqlglobal.h>
0008 #include <QtCore/qshareddata.h>
0009 #include <QtCore/qvariant.h>
0010 #include <QtCore/qstring.h>
0011 
0012 QT_BEGIN_NAMESPACE
0013 
0014 
0015 class QSqlFieldPrivate;
0016 QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QSqlFieldPrivate, Q_SQL_EXPORT)
0017 
0018 class Q_SQL_EXPORT QSqlField
0019 {
0020 public:
0021     enum RequiredStatus { Unknown = -1, Optional = 0, Required = 1 };
0022 
0023     explicit QSqlField(const QString& fieldName = QString(), QMetaType type = QMetaType(), const QString &tableName = QString());
0024 
0025     QSqlField(const QSqlField& other);
0026     QSqlField& operator=(const QSqlField& other);
0027     QSqlField(QSqlField &&other) noexcept = default;
0028     QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QSqlField)
0029     ~QSqlField();
0030 
0031     void swap(QSqlField &other) noexcept { val.swap(other.val); d.swap(other.d); }
0032 
0033     bool operator==(const QSqlField& other) const;
0034     inline bool operator!=(const QSqlField &other) const { return !operator==(other); }
0035 
0036     void setValue(const QVariant& value);
0037     inline QVariant value() const
0038     { return val; }
0039     void setName(const QString& name);
0040     QString name() const;
0041     void setTableName(const QString &tableName);
0042     QString tableName() const;
0043     bool isNull() const;
0044     void setReadOnly(bool readOnly);
0045     bool isReadOnly() const;
0046     void clear();
0047     bool isAutoValue() const;
0048 
0049     QMetaType metaType() const;
0050     void setMetaType(QMetaType type);
0051 
0052 #if QT_DEPRECATED_SINCE(6, 0)
0053     QT_WARNING_PUSH
0054     QT_WARNING_DISABLE_DEPRECATED
0055     QT_DEPRECATED_VERSION_X_6_0("Use the constructor using a QMetaType instead")
0056     QSqlField(const QString& fieldName, QVariant::Type type, const QString &tableName = QString())
0057         : QSqlField(fieldName, QMetaType(type), tableName)
0058     {}
0059     QT_DEPRECATED_VERSION_X_6_0("Use metaType() instead")
0060     QVariant::Type type() const { return QVariant::Type(metaType().id()); };
0061     QT_DEPRECATED_VERSION_X_6_0("Use setMetaType() instead")
0062     void setType(QVariant::Type type) { setMetaType(QMetaType(int(type))); }
0063     QT_WARNING_POP
0064 #endif
0065 
0066     void setRequiredStatus(RequiredStatus status);
0067     inline void setRequired(bool required)
0068     { setRequiredStatus(required ? Required : Optional); }
0069     void setLength(int fieldLength);
0070     void setPrecision(int precision);
0071     void setDefaultValue(const QVariant &value);
0072     void setSqlType(int type);
0073     void setGenerated(bool gen);
0074     void setAutoValue(bool autoVal);
0075 
0076     RequiredStatus requiredStatus() const;
0077     int length() const;
0078     int precision() const;
0079     QVariant defaultValue() const;
0080     int typeID() const;
0081     bool isGenerated() const;
0082     bool isValid() const;
0083 
0084 private:
0085     void detach();
0086     // ### Qt7: move to private class
0087     QVariant val;
0088     QExplicitlySharedDataPointer<QSqlFieldPrivate> d;
0089 };
0090 
0091 Q_DECLARE_SHARED(QSqlField)
0092 
0093 #ifndef QT_NO_DEBUG_STREAM
0094 Q_SQL_EXPORT QDebug operator<<(QDebug, const QSqlField &);
0095 #endif
0096 
0097 QT_END_NAMESPACE
0098 
0099 #endif // QSQLFIELD_H