ThinSQLite++
A thin, safe and convenient modern C++ wrapper for SQLite API.
Loading...
Searching...
No Matches
index_info< T > Class Template Reference

Virtual Table Indexing Information. More...

Inheritance diagram for index_info< T >:
handle< sqlite3_index_info, index_info< void > >

Public Types

using constraint = sqlite3_index_info::sqlite3_index_constraint
 Alias for unwieldy C struct name.
 
using constraint_usage = sqlite3_index_info::sqlite3_index_constraint_usage
 Alias for unwieldy C struct name.
 
using orderby = sqlite3_index_info::sqlite3_index_orderby
 Alias for unwieldy C struct name.
 

Public Member Functions

span< const constraintconstraints () const noexcept
 Returns the table of WHERE clause constraints.
 
span< const orderbyorderbys () const noexcept
 Returns the table of ORDER BY clause constraints.
 
uint64_t columns_used () const noexcept
 Returns mask of columns used by statement.
 
const char * collation (int constraint_idx) const noexcept
 Determine the collation for a constraint.
 
int distinct () const noexcept
 Determine if the query is DISTINCT.
 
bool is_in (int constraint_idx) const noexcept
 Determine if a constraint is an IN that can be processed all at once.
 
void handle_in (int constraint_idx, bool handle) const noexcept
 Set all-at-once processing of an IN operator.
 
span< const constraint_usageconstraints_usage () const noexcept
 Returns the desired usage of the constraints.
 
span< constraint_usageconstraints_usage () noexcept
 Returns the desired usage of the constraints.
 
int index_number () const noexcept
 Returns number used to identify the index.
 
void set_index_number (int val) noexcept
 Sets number used to identify the index.
 
index_data () const noexcept
 Returns data associated with the index.
 
template<class X >
void set_index_data (X *data, bool allocated=false) noexcept
 Set the index data.
 
template<class X >
void set_index_data (std::unique_ptr< X, sqlite_deleter< X > > data) noexcept
 Set the index data.
 
template<class X >
void set_index_data (std::unique_ptr< X > data) noexcept
 Set the index data.
 
bool order_by_consumed () const noexcept
 Returns whether the cursor output is already ordered.
 
void set_order_by_consumed (bool val) noexcept
 Sets whether the cursor output is already ordered.
 
double estimated_cost () const noexcept
 Returns estimated cost of using this index.
 
void set_estimated_cost (double val) noexcept
 Sets estimated cost of using this index.
 
int64_t estimated_rows () const noexcept
 Returns estimated number of rows returned.
 
void set_estimated_rows (int64_t val) noexcept
 Sets estimated number of rows returned.
 
int index_flags () const noexcept
 Returns mask of SQLITE_INDEX_SCAN_ flags.
 
void set_index_flags (int val) noexcept
 Sets mask of SQLITE_INDEX_SCAN_ flags.
 
void operator delete (void *) noexcept
 Operator delete for a fake pointer is no-op.
 
sqlite3_index_info * c_ptr () const noexcept
 Access the real underlying SQLite type.
 

Static Public Member Functions

static index_info< void > * from (sqlite3_index_info *obj) noexcept
 Create fake pointer from the underlying SQLite one.
 

Detailed Description

template<class T = void>
class thinsqlitepp::index_info< T >

Virtual Table Indexing Information.

This is a fake wrapper class for sqlite3_index_info.

It is used by your functions overriding vtab::best_index but can also be used standalone if manually implementing xBestIndex.

Unlike other SQLite data types sqlite3_index_info is a real struct, not an opaque data type. If desired you can directly access the struct members via c_ptr() but this wrapper provides convenient and safe inline accessor methods for all members.

Template Parameters
TThe type of the index data in sqlite3_index_info::idxStr. Must be a pointer or void. If void storing data is disabled.

#include <thinsqlitepp/vtab.hpp>

Member Function Documentation

◆ columns_used()

template<class T = void>
uint64_t columns_used ( ) const
inlinenoexcept

Returns mask of columns used by statement.

Since
SQLite 3.10.0

◆ collation()

template<class T = void>
const char * collation ( int constraint_idx) const
inlinenoexcept

Determine the collation for a constraint.

Equivalent to sqlite3_vtab_collation

◆ distinct()

template<class T = void>
int distinct ( ) const
inlinenoexcept

Determine if the query is DISTINCT.

Equivalent to sqlite3_vtab_distinct

◆ is_in()

template<class T = void>
bool is_in ( int constraint_idx) const
inlinenoexcept

Determine if a constraint is an IN that can be processed all at once.

Equivalent to sqlite3_vtab_in with last argument -1

◆ handle_in()

template<class T = void>
void handle_in ( int constraint_idx,
bool handle ) const
inlinenoexcept

Set all-at-once processing of an IN operator.

Equivalent to sqlite3_vtab_in

◆ constraints_usage() [1/2]

template<class T = void>
span< const constraint_usage > constraints_usage ( ) const
inlinenoexcept

Returns the desired usage of the constraints.

The size of this span is the same as returned by constraints.

◆ constraints_usage() [2/2]

template<class T = void>
span< constraint_usage > constraints_usage ( )
inlinenoexcept

Returns the desired usage of the constraints.

The size of this span is the same as returned by constraints.

◆ index_data()

template<class T = void>
T index_data ( ) const
inlinenoexcept

Returns data associated with the index.

Only meaningful if template parameter T is non-void. Otherwise does nothing and returns nothing.

◆ set_index_data() [1/3]

template<class T = void>
template<class X >
void set_index_data ( X * data,
bool allocated = false )
inlinenoexcept

Set the index data.

Enabled only if template parameter T is non-void and data pointer can be converted to it.

Parameters
datadata to set
allocatedif true SQLite will automatically free the data using sqlite3_free. Otherwise you are responsible for the pointed data lifecycle

◆ set_index_data() [2/3]

template<class T = void>
template<class X >
void set_index_data ( std::unique_ptr< X, sqlite_deleter< X > > data)
inlinenoexcept

Set the index data.

This is a convenience overload of set_index_data(T, bool) that takes a std::unique_pointer with an sqlite_deleter.

Enabled only if template parameter T is non-void, trivially destructible and data pointer type can be converted to it.

◆ set_index_data() [3/3]

template<class T = void>
template<class X >
void set_index_data ( std::unique_ptr< X > data)
inlinenoexcept

Set the index data.

This is a convenience overload of set_index_data(T *, bool) that takes a std::unique_pointer to T.

Enabled only if template parameter T is a pointer to a trivially destructible class derived from sqlite_allocated

◆ estimated_rows()

template<class T = void>
int64_t estimated_rows ( ) const
inlinenoexcept

Returns estimated number of rows returned.

Since
SQLite 3.8.2

◆ set_estimated_rows()

template<class T = void>
void set_estimated_rows ( int64_t val)
inlinenoexcept

Sets estimated number of rows returned.

Since
SQLite 3.8.2

◆ index_flags()

template<class T = void>
int index_flags ( ) const
inlinenoexcept

Returns mask of SQLITE_INDEX_SCAN_ flags.

Since
SQLite 3.9.0

◆ set_index_flags()

template<class T = void>
void set_index_flags ( int val)
inlinenoexcept

Sets mask of SQLITE_INDEX_SCAN_ flags.

Since
SQLite 3.9.0