ThinSQLite++
A thin, safe and convenient modern C++ wrapper for SQLite API.
Loading...
Searching...
No Matches
vtab< Derived >::cursor Class Reference

Base class for cursors. More...

Inheritance diagram for vtab< Derived >::cursor:
sqlite3_vtab_cursor

Public Member Functions

 cursor (cursor &)=delete
 
cursoroperator= (cursor &)=delete
 
sqlite3_vtab_cursorc_ptr () const noexcept
 Access the underlying sqlite3_vtab_cursor struct.
 
template<class D = Derived>
void filter (int idx, typename D::index_data_type idx_data, int argc, value **argv)
 Begins a search of a virtual table.
 
template<class D = Derived>
void filter (int idx, int argc, value **argv)
 Begins a search of a virtual table.
 
bool eof () const noexcept
 Whether the cursor reached the end.
 
void next ()
 Advances the cursor.
 
void column (context &ctxt, int idx) const
 Retrieves the value of the virtual table column in a row cursor is currently pointing at.
 
sqlite_int64 rowid () const
 Retrieves the rowid of the row cursor is currently pointing at.
 

Protected Member Functions

 cursor (Derived *owner)
 Constructs an instance with a given owner.
 
Derived * owner () const noexcept
 Returns the owning vtab - derived class.
 

Detailed Description

template<class Derived>
class thinsqlitepp::vtab< Derived >::cursor

Base class for cursors.

It wraps sqlite3_vtab_cursor and provides default implementation of the required methods. The default implementation returns no rows. Re-define various methods in your derived classes.

Member Function Documentation

◆ filter() [1/2]

template<class Derived >
template<class D = Derived>
void filter ( int idx,
typename D::index_data_type idx_data,
int argc,
value ** argv )
inline

Begins a search of a virtual table.

Equivalent to xFilter

This method is called if index_data_type is defined as a pointer.

Re-define this method as a non-templated function in your derived class. Your implementation can throw exceptions to indicate errors.

This method can be called multiple times and should initialize cursor internals to start cursor iteration anew (do not rely on constructor to do that).

The default implementation does nothing.

Template Parameters
DDefers resolution of nested data types declared in derived class. This is an internal implementation detail - your re-defined implementations do not need to be templated.
Parameters
idxvalue passed to index_info::set_index_number in best_index. Its significance is entirely up to you
idx_datapointer passed to index_info::set_index_data. Its significance is entirely up to you
argccount of items in argv array
argvrequested values of certain expressions from index_info::constraint_usage

◆ filter() [2/2]

template<class Derived >
template<class D = Derived>
void filter ( int idx,
int argc,
value ** argv )
inline

Begins a search of a virtual table.

Equivalent to xFilter

This method is called if index_data_type is void.

Re-define this method as a non-templated function in your derived class. Your implementation can throw exceptions to indicate errors.

This method can be called multiple times and should initialize cursor internals to start cursor iteration anew (do not rely on constructor to do that).

The default implementation does nothing.

Template Parameters
DDefers resolution of nested data types declared in derived class. This is an internal implementation detail - your re-defined implementations do not need to be templated.
Parameters
idxvalue passed to index_info::set_index_number in best_index. Its significance is entirely up to you
argccount of items in argv array
argvrequested values of certain expressions from index_info::constraint_usage

◆ eof()

template<class Derived >
bool eof ( ) const
inlinenoexcept

Whether the cursor reached the end.

Equivalent to xEof

Re-define this method together with next() in your derived class. Your implementation must also be noexcept.

This default implementation always returns true

◆ next()

template<class Derived >
void next ( )
inline

Advances the cursor.

Equivalent to xNext

Re-define this method together with eof() in your derived class. Your implementation can throw exceptions to indicate errors.

This default implementation should never be called since default eof() always returns true. If called it will report an error.

◆ column()

template<class Derived >
void column ( context & ctxt,
int idx ) const
inline

Retrieves the value of the virtual table column in a row cursor is currently pointing at.

Equivalent to xColumn

Re-define this method in your derived class. Your implementation can throw exceptions to indicate errors.

This default implementation always return null

Parameters
ctxtthe context to set the column value on
idxcolumn index

◆ rowid()

template<class Derived >
sqlite_int64 rowid ( ) const
inline

Retrieves the rowid of the row cursor is currently pointing at.

Equivalent to xRowid

Re-define this method in your derived class. Your implementation can throw exceptions to indicate errors.

This default implementation always reports an error

◆ owner()

template<class Derived >
Derived * owner ( ) const
inlineprotectednoexcept

Returns the owning vtab - derived class.

Equivalent to accessing the pVtab field of sqlite3_vtab_cursor

Note
this is safe to call from your derived class constructor