#ifndef QSQLRECORD_H
#define QSQLRECORD_H
 
#include <QtCore/qstring.h>
 
QT_BEGIN_HEADER                  //声明开始头文件
 
QT_BEGIN_NAMESPACE          //声明开始命名空间
 
QT_MODULE(Sql)
 
class QSqlField;
class QStringList;
class QVariant;
class QSqlRecordPrivate;
 
class Q_SQL_EXPORT QSqlRecord
{
public:
    QSqlRecord();                              //无初始参数的构造函数,record包括fieldvalue
    QSqlRecord(const QSqlRecord& other);
    QSqlRecord& operator=(const QSqlRecord& other);
    ~QSqlRecord();
 
    bool operator==(const QSqlRecord &other) const;
    inline bool operator!=(const QSqlRecord &other) const { return !operator==(other); }
 
    QVariant value(int i) const;               //i来定位设定值
    QVariant value(const QString& name) const;          //name定位
    void setValue(int i, const QVariant& val);
    void setValue(const QString& name, const QVariant& val);
 
    void setNull(int i);                                //i来定位把值置空
    void setNull(const QString& name);
    bool isNull(int i) const;
    bool isNull(const QString& name) const;
 
    int indexOf(const QString &name) const;        //返回名字对应的index
    QString fieldName(int i) const;
 
    QSqlField field(int i) const;                 //返回index   i对应的字段
    QSqlField field(const QString &name) const;
 
    bool isGenerated(int i) const;   //是否产生?这个表示什么
    bool isGenerated(const QString& name) const;
    void setGenerated(const QString& name, bool generated);
    void setGenerated(int i, bool generated);
 
#ifdef QT3_SUPPORT
    QT3_SUPPORT const QSqlField* fieldPtr(int i) const;
    QT3_SUPPORT const QSqlField* fieldPtr(const QString& name) const;
    inline QT3_SUPPORT int position(const QString& name) const { return indexOf(name); }
    QT3_SUPPORT QString toString(const QString& prefix = QString(),
                               const QString& sep = QLatin1String(",")) const;
    QT3_SUPPORT QStringList toStringList(const QString& prefix = QString()) const;
#endif
 
    void append(const QSqlField& field);       //添加
    void replace(int pos, const QSqlField& field);           //取代
    void insert(int pos, const QSqlField& field);              //插入
    void remove(int pos);       //移除
 
bool isEmpty() const;
 
    bool contains(const QString& name) const;
    void clear();
    void clearValues();
    int count() const;
 
private:
    void detach();  //分离?
    QSqlRecordPrivate* d;
};
 
#ifndef QT_NO_DEBUG_STREAM
Q_SQL_EXPORT QDebug operator<<(QDebug, const QSqlRecord &);
#endif
 
QT_END_NAMESPACE
 
QT_END_HEADER
 
#endif // QSQLRECORD_H