?? qsqldriver.cpp
字號:
/******************************************************************************** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.**** This file is part of the QtSql module of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file. Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://www.trolltech.com/products/qt/opensource.html**** If you are unsure which license is appropriate for your use, please** review the following information:** http://www.trolltech.com/products/qt/licensing.html or contact the** sales department at sales@trolltech.com.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "qsqldriver.h"#include "qdatetime.h"#include "qsqlerror.h"#include "qsqlfield.h"#include "qsqlindex.h"#include "qstringlist.h"#include "private/qobject_p.h"class QSqlDriverPrivate : public QObjectPrivate{public: QSqlDriverPrivate(); virtual ~QSqlDriverPrivate();public: // @CHECK: this member is never used. It was named q, which expanded to q_func(). QSqlDriver *q_func(); uint isOpen : 1; uint isOpenError : 1; QSqlError error;};inline QSqlDriverPrivate::QSqlDriverPrivate() : QObjectPrivate(), isOpen(false), isOpenError(false){}QSqlDriverPrivate::~QSqlDriverPrivate(){}/*! \class QSqlDriver \brief The QSqlDriver class is an abstract base class for accessing specific SQL databases. \ingroup database \module sql This class should not be used directly. Use QSqlDatabase instead. If you want to create your own SQL drivers, you can subclass this class and reimplement its pure virtual functions and those virtual functions that you need. See \l{How to Write Your Own Database Driver} for more information. \sa QSqlDatabase, QSqlResult*//*! Constructs a new driver with the given \a parent.*/QSqlDriver::QSqlDriver(QObject *parent) : QObject(*new QSqlDriverPrivate, parent){}/*! Destroys the object and frees any allocated resources.*/QSqlDriver::~QSqlDriver(){}/*! \fn bool QSqlDriver::open(const QString &db, const QString &user, const QString& password, const QString &host, int port, const QString &options) Derived classes must reimplement this pure virtual function to open a database connection on database \a db, using user name \a user, password \a password, host \a host, port \a port and connection options \a options. The function must return true on success and false on failure. \sa setOpen()*//*! \fn bool QSqlDriver::close() Derived classes must reimplement this pure virtual function in order to close the database connection. Return true on success, false on failure. \sa open(), setOpen()*//*! \fn QSqlResult *QSqlDriver::createResult() const Creates an empty SQL result on the database. Derived classes must reimplement this function and return a QSqlResult object appropriate for their database to the caller.*//*! Returns true if the database connection is open; otherwise returns false.*/bool QSqlDriver::isOpen() const{ return d_func()->isOpen;}/*! Returns true if the there was an error opening the database connection; otherwise returns false.*/bool QSqlDriver::isOpenError() const{ return d_func()->isOpenError;}/*! \enum QSqlDriver::DriverFeature This enum contains a list of features a driver might support. Use hasFeature() to query whether a feature is supported or not. \value Transactions Whether the driver supports SQL transactions. \value QuerySize Whether the database is capable of reporting the size of a query. Note that some databases do not support returning the size (i.e. number of rows returned) of a query, in which case QSqlQuery::size() will return -1. \value BLOB Whether the driver supports Binary Large Object fields. \value Unicode Whether the driver supports Unicode strings if the database server does. \value PreparedQueries Whether the driver supports prepared query execution. \value NamedPlaceholders Whether the driver supports the use of named placeholders. \value PositionalPlaceholders Whether the driver supports the use of positional placeholders. \value LastInsertId Whether the driver supports returning the Id of the last touched row. \value BatchOperations Whether the driver supports batched operations, see QSqlResult::execBatch() More information about supported features can be found in the \l{sql-driver.html}{Qt SQL driver} documentation. \sa hasFeature()*//*! \enum QSqlDriver::StatementType This enum contains a list of SQL statement (or clause) types the driver can create. \value WhereStatement An SQL \c WHERE statement (e.g., \c{WHERE f = 5}). \value SelectStatement An SQL \c SELECT statement (e.g., \c{SELECT f FROM t}). \value UpdateStatement An SQL \c UPDATE statement (e.g., \c{UPDATE TABLE t set f = 1}). \value InsertStatement An SQL \c INSERT statement (e.g., \c{INSERT INTO t (f) values (1)}). \value DeleteStatement An SQL \c DELETE statement (e.g., \c{DELETE FROM t}). \sa sqlStatement()*//*! \enum QSqlDriver::IdentifierType This enum contains a list of SQL identifier types. \value FieldName A SQL field name \value TableName A SQL table name*//*! \fn bool QSqlDriver::hasFeature(DriverFeature feature) const Returns true if the driver supports feature \a feature; otherwise returns false. Note that some databases need to be open() before this can be determined. \sa DriverFeature*//*! This function sets the open state of the database to \a open. Derived classes can use this function to report the status of open(). \sa open(), setOpenError()*/void QSqlDriver::setOpen(bool open){ d_func()->isOpen = open;}/*! This function sets the open error state of the database to \a error. Derived classes can use this function to report the status of open(). Note that if \a error is true the open state of the database is set to closed (i.e., isOpen() returns false). \sa open(), setOpen()*/void QSqlDriver::setOpenError(bool error){ d_func()->isOpenError = error; if (error) d_func()->isOpen = false;}/*! This function is called to begin a transaction. If successful, return true, otherwise return false. The default implementation does nothing and returns false. \sa commitTransaction(), rollbackTransaction()*/bool QSqlDriver::beginTransaction(){ return false;}/*! This function is called to commit a transaction. If successful, return true, otherwise return false. The default implementation does nothing and returns false. \sa beginTransaction(), rollbackTransaction()*/bool QSqlDriver::commitTransaction(){ return false;}/*! This function is called to rollback a transaction. If successful, return true, otherwise return false. The default implementation does nothing and returns false. \sa beginTransaction(), commitTransaction()*/bool QSqlDriver::rollbackTransaction(){ return false;}/*! This function is used to set the value of the last error, \a error, that occurred on the database. \sa lastError()*/void QSqlDriver::setLastError(const QSqlError &error){ d_func()->error = error;}/*! Returns a QSqlError object which contains information about the last error that occurred on the database.*/QSqlError QSqlDriver::lastError() const{ return d_func()->error;}/*! Returns a list of the names of the tables in the database. The default implementation returns an empty list. The \a tableType argument describes what types of tables should be returned. Due to binary compatibility, the string contains the value of the enum QSql::TableTypes as text. An empty string should be treated as QSql::Tables for backward compatibility.*/QStringList QSqlDriver::tables(QSql::TableType) const{ return QStringList();}/*! Returns the primary index for table \a tableName. Returns an empty QSqlIndex if the table doesn't have a primary index. The default implementation returns an empty index.*/QSqlIndex QSqlDriver::primaryIndex(const QString&) const{
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -