#ifndef QSQLERROR_H<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

#define QSQLERROR_H

 

#include <QtCore/qstring.h>

 

QT_BEGIN_HEADER                  //声明开始头文件

 

QT_BEGIN_NAMESPACE          //声明开始命名空间

 

QT_MODULE(Sql)

 

class Q_SQL_EXPORT QSqlError

{

public:

    enum ErrorType {                                 //错误类型,都喜欢使用enum

        NoError,

        ConnectionError,

        StatementError,

        TransactionError,

        UnknownError

#ifdef QT3_SUPPORT                      //宏的运用!

        , None = NoError,

        Connection = ConnectionError,

        Statement = StatementError,

        Transaction = TransactionError,

        Unknown = UnknownError

#endif

    };

    QSqlError( const QString& driverText = QString(),

                const QString& databaseText = QString(),

                ErrorType type = NoError,

                int number = -1);

    QSqlError(const QSqlError& other);

    QSqlError& operator=(const QSqlError& other);

    ~QSqlError();

 

QString driverText() const;

//类似的函数全用const

void setDriverText(const QString& driverText);

//一个set**对应一个**,成对出现

    QString databaseText() const;

    void setDatabaseText(const QString& databaseText);

    ErrorType type() const;

    void setType(ErrorType type);

int number() const;

//什么数?--errorNumber(错误数)

    void setNumber(int number);

QString text() const;

//什么text---driverText or databaseText

    bool isValid() const;

 

private:

    QString driverError;

    QString databaseError;

    ErrorType errorType;

int errorNumber;

//变量基本都是私有的,函数基本都是共有的

};

 

#ifndef QT_NO_DEBUG_STREAM

Q_SQL_EXPORT QDebug operator<<(QDebug, const QSqlError &);

#endif

//自动输出错误信息

 

QT_END_NAMESPACE

 

QT_END_HEADER

 

#endif // QSQLERROR_H