Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QSqlCachedResult Class Referenceabstract

#include <qsqlcachedresult_p.h>

+ Inheritance diagram for QSqlCachedResult:
+ Collaboration diagram for QSqlCachedResult:

Public Types

typedef QList< QVariantValueCache
 

Protected Member Functions

 QSqlCachedResult (QSqlCachedResultPrivate &d)
 
void init (int colCount)
 
void cleanup ()
 
void clearValues ()
 
virtual bool gotoNext (ValueCache &values, int index)=0
 
QVariant data (int i) override
 Returns the data for field index in the current row as a QVariant.
 
bool isNull (int i) override
 Returns true if the field at position index in the current row is null; otherwise returns false.
 
bool fetch (int i) override
 Positions the result to an arbitrary (zero-based) row index.
 
bool fetchNext () override
 Positions the result to the next available record (row) in the result.
 
bool fetchPrevious () override
 Positions the result to the previous record (row) in the result.
 
bool fetchFirst () override
 Positions the result to the first record (row 0) in the result.
 
bool fetchLast () override
 Positions the result to the last record (last row) in the result.
 
int colCount () const
 
ValueCachecache ()
 
void virtual_hook (int id, void *data) override
 
void detachFromResultSet () override
 
void setNumericalPrecisionPolicy (QSql::NumericalPrecisionPolicy policy) override
 
- Protected Member Functions inherited from QSqlResult
 QSqlResult (const QSqlDriver *db)
 Creates a QSqlResult using database driver db.
 
 QSqlResult (QSqlResultPrivate &dd)
 
int at () const
 Returns the current (zero-based) row position of the result.
 
QString lastQuery () const
 Returns the current SQL query text, or an empty string if there isn't one.
 
QSqlError lastError () const
 Returns the last error associated with the result.
 
bool isValid () const
 Returns true if the result is positioned on a valid record (that is, the result is not positioned before the first or after the last record); otherwise returns false.
 
bool isActive () const
 Returns true if the result has records to be retrieved; otherwise returns false.
 
bool isSelect () const
 Returns true if the current result is from a SELECT statement; otherwise returns false.
 
bool isForwardOnly () const
 Returns true if you can only scroll forward through the result set; otherwise returns false.
 
const QSqlDriverdriver () const
 Returns the driver associated with the result.
 
virtual void setAt (int at)
 This function is provided for derived classes to set the internal (zero-based) row position to index.
 
virtual void setActive (bool a)
 This function is provided for derived classes to set the internal active state to active.
 
virtual void setLastError (const QSqlError &e)
 This function is provided for derived classes to set the last error to error.
 
virtual void setQuery (const QString &query)
 Sets the current query for the result to query.
 
virtual void setSelect (bool s)
 This function is provided for derived classes to indicate whether or not the current statement is a SQL SELECT statement.
 
virtual void setForwardOnly (bool forward)
 Sets forward only mode to forward.
 
virtual bool exec ()
 Executes the query, returning true if successful; otherwise returns false.
 
virtual bool prepare (const QString &query)
 Prepares the given query for execution; the query will normally use placeholders so that it can be executed repeatedly.
 
virtual bool savePrepare (const QString &sqlquery)
 Prepares the given query, using the underlying database functionality where possible.
 
virtual void bindValue (int pos, const QVariant &val, QSql::ParamType type)
 Binds the value val of parameter type paramType to position index in the current record (row).
 
virtual void bindValue (const QString &placeholder, const QVariant &val, QSql::ParamType type)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Binds the value val of parameter type paramType to the placeholder name in the current record (row).
 
void addBindValue (const QVariant &val, QSql::ParamType type)
 Binds the value val of parameter type paramType to the next available position in the current record (row).
 
QVariant boundValue (const QString &placeholder) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the value bound by the given placeholder name in the current record (row).
 
QVariant boundValue (int pos) const
 Returns the value bound at position index in the current record (row).
 
QSql::ParamType bindValueType (const QString &placeholder) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the parameter type for the value bound with the given placeholder name.
 
QSql::ParamType bindValueType (int pos) const
 Returns the parameter type for the value bound at position index.
 
int boundValueCount () const
 Returns the number of bound values in the result.
 
QVariantListboundValues (QT6_DECL_NEW_OVERLOAD)
 
QVariantList boundValues (QT6_DECL_NEW_OVERLOAD) const
 
QString executedQuery () const
 Returns the query that was actually executed.
 
QStringList boundValueNames () const
 Returns the names of all bound values.
 
QString boundValueName (int pos) const
 Returns the name of the bound value at position index in the current record (row).
 
void clear ()
 Clears the entire result set and releases any associated resources.
 
bool hasOutValues () const
 Returns true if at least one of the query's bound values is a QSql::Out or a QSql::InOut; otherwise returns false.
 
BindingSyntax bindingSyntax () const
 Returns the binding syntax used by prepared queries.
 
virtual bool reset (const QString &sqlquery)=0
 Sets the result to use the SQL statement query for subsequent data retrieval.
 
virtual int size ()=0
 Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELECT statement.
 
virtual int numRowsAffected ()=0
 Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or if the query is a SELECT statement.
 
virtual QSqlRecord record () const
 Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
 
virtual QVariant lastInsertId () const
 Returns the object ID of the most recent inserted row if the database supports it.
 
virtual bool execBatch (bool arrayBind=false)
 
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy () const
 
void setPositionalBindingEnabled (bool enable)
 
bool isPositionalBindingEnabled () const
 
virtual bool nextResult ()
 
void resetBindCount ()
 Resets the number of bind parameters.
 

Additional Inherited Members

- Public Member Functions inherited from QSqlResult
virtual ~QSqlResult ()
 Destroys the object and frees any allocated resources.
 
virtual QVariant handle () const
 Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVariant if there is no handle.
 
- Protected Types inherited from QSqlResult
enum  BindingSyntax { PositionalBinding , NamedBinding }
 This enum type specifies the different syntaxes for specifying placeholders in prepared queries. More...
 
enum  VirtualHookOperation
 
- Protected Attributes inherited from QSqlResult
QSqlResultPrivated_ptr
 

Detailed Description

Definition at line 29 of file qsqlcachedresult_p.h.

Member Typedef Documentation

◆ ValueCache

Definition at line 34 of file qsqlcachedresult_p.h.

Constructor & Destructor Documentation

◆ QSqlCachedResult()

QSqlCachedResult::QSqlCachedResult ( QSqlCachedResultPrivate & d)
protected

Definition at line 82 of file qsqlcachedresult.cpp.

Member Function Documentation

◆ cache()

QSqlCachedResult::ValueCache & QSqlCachedResult::cache ( )
protected

Definition at line 242 of file qsqlcachedresult.cpp.

References d.

◆ cleanup()

void QSqlCachedResult::cleanup ( )
protected

Definition at line 201 of file qsqlcachedresult.cpp.

References QSql::BeforeFirstRow, d, QSqlResult::setActive(), and QSqlResult::setAt().

Referenced by detachFromResultSet(), QIBaseResult::exec(), QOCIResult::prepare(), and setNumericalPrecisionPolicy().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearValues()

void QSqlCachedResult::clearValues ( )
protected

Definition at line 209 of file qsqlcachedresult.cpp.

References QSql::BeforeFirstRow, d, and QSqlResult::setAt().

Referenced by QSQLiteResult::exec().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ colCount()

int QSqlCachedResult::colCount ( ) const
protected

Definition at line 236 of file qsqlcachedresult.cpp.

References d.

Referenced by QIBaseResult::exec(), and init().

+ Here is the caller graph for this function:

◆ data()

QVariant QSqlCachedResult::data ( int index)
overrideprotectedvirtual

Returns the data for field index in the current row as a QVariant.

This function is only called if the result is in an active state and is positioned on a valid record and index is non-negative. Derived classes must reimplement this function and return the value of field index, or QVariant() if it cannot be determined.

Implements QSqlResult.

Definition at line 181 of file qsqlcachedresult.cpp.

References QSqlResult::at(), d, and i.

+ Here is the call graph for this function:

◆ detachFromResultSet()

void QSqlCachedResult::detachFromResultSet ( )
overrideprotectedvirtual

Reimplemented from QSqlResult.

Reimplemented in QSQLiteResult.

Definition at line 253 of file qsqlcachedresult.cpp.

References cleanup().

+ Here is the call graph for this function:

◆ fetch()

bool QSqlCachedResult::fetch ( int index)
overrideprotectedvirtual

Positions the result to an arbitrary (zero-based) row index.

This function is only called if the result is in an active state. Derived classes must reimplement this function and position the result to the row index, and call setAt() with an appropriate value. Return true to indicate success, or false to signify failure.

See also
isActive(), fetchFirst(), fetchLast(), fetchNext(), fetchPrevious()

Implements QSqlResult.

Definition at line 93 of file qsqlcachedresult.cpp.

References QSql::AfterLastRow, QSqlResult::at(), d, gotoNext(), i, QSqlResult::isActive(), and QSqlResult::setAt().

Referenced by fetchLast(), and fetchPrevious().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchFirst()

bool QSqlCachedResult::fetchFirst ( )
overrideprotectedvirtual

Positions the result to the first record (row 0) in the result.

This function is only called if the result is in an active state. Derived classes must reimplement this function and position the result to the first record, and call setAt() with an appropriate value. Return true to indicate success, or false to signify failure.

See also
fetch(), fetchLast()

Implements QSqlResult.

Definition at line 147 of file qsqlcachedresult.cpp.

References QSqlResult::at(), QSql::BeforeFirstRow, d, and QSqlResult::setAt().

+ Here is the call graph for this function:

◆ fetchLast()

bool QSqlCachedResult::fetchLast ( )
overrideprotectedvirtual

Positions the result to the last record (last row) in the result.

This function is only called if the result is in an active state. Derived classes must reimplement this function and position the result to the last record, and call setAt() with an appropriate value. Return true to indicate success, or false to signify failure.

See also
fetch(), fetchFirst()

Implements QSqlResult.

Definition at line 160 of file qsqlcachedresult.cpp.

References QSql::AfterLastRow, QSqlResult::at(), d, fetch(), fetchNext(), i, and QSqlResult::setAt().

+ Here is the call graph for this function:

◆ fetchNext()

bool QSqlCachedResult::fetchNext ( )
overrideprotectedvirtual

Positions the result to the next available record (row) in the result.

This function is only called if the result is in an active state. The default implementation calls fetch() with the next index. Derived classes can reimplement this function and position the result to the next record in some other way, and call setAt() with an appropriate value. Return true to indicate success, or false to signify failure.

See also
fetch(), fetchPrevious()

Reimplemented from QSqlResult.

Definition at line 132 of file qsqlcachedresult.cpp.

References QSqlResult::at(), d, and QSqlResult::setAt().

Referenced by fetchLast(), and QOCIResult::fetchNext().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchPrevious()

bool QSqlCachedResult::fetchPrevious ( )
overrideprotectedvirtual

Positions the result to the previous record (row) in the result.

This function is only called if the result is in an active state. The default implementation calls fetch() with the previous index. Derived classes can reimplement this function and position the result to the next record in some other way, and call setAt() with an appropriate value. Return true to indicate success, or false to signify failure.

Reimplemented from QSqlResult.

Definition at line 142 of file qsqlcachedresult.cpp.

References QSqlResult::at(), and fetch().

+ Here is the call graph for this function:

◆ gotoNext()

virtual bool QSqlCachedResult::gotoNext ( ValueCache & values,
int index )
protectedpure virtual

Implemented in QSQLiteResult, QIBaseResult, and QOCIResult.

Referenced by fetch().

+ Here is the caller graph for this function:

◆ init()

void QSqlCachedResult::init ( int colCount)
protected

Definition at line 87 of file qsqlcachedresult.cpp.

References colCount(), d, and QSqlResult::isForwardOnly().

Referenced by QIBaseResult::exec(), and QOCIResult::exec().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isNull()

bool QSqlCachedResult::isNull ( int i)
overrideprotectedvirtual

Returns true if the field at position index in the current row is null; otherwise returns false.

Implements QSqlResult.

Definition at line 191 of file qsqlcachedresult.cpp.

References QSqlResult::at(), d, and i.

+ Here is the call graph for this function:

◆ setNumericalPrecisionPolicy()

void QSqlCachedResult::setNumericalPrecisionPolicy ( QSql::NumericalPrecisionPolicy policy)
overrideprotectedvirtual

Reimplemented from QSqlResult.

Definition at line 258 of file qsqlcachedresult.cpp.

References cleanup(), policy, and QSqlResult::setNumericalPrecisionPolicy().

+ Here is the call graph for this function:

◆ virtual_hook()

void QSqlCachedResult::virtual_hook ( int id,
void * data )
overrideprotectedvirtual

Reimplemented from QSqlResult.

Reimplemented in QSQLiteResult.

Definition at line 248 of file qsqlcachedresult.cpp.

References QSqlResult::virtual_hook().

Referenced by QOCIResult::virtual_hook(), and QSQLiteResult::virtual_hook().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: