SQLite for C++
Public Member Functions | Protected Attributes | List of all members
SQLite::Conn::PreparedStatement Class Reference
Inheritance diagram for SQLite::Conn::PreparedStatement:
SQLite::Conn::ResultSet

Public Member Functions

 PreparedStatement (Conn &conn, const std::string &stmt)
 
sqlite3_stmt * get_ptr ()
 
void commit ()
 
void next ()
 
void close () noexcept
 
Binding Values
void bind (Args... args)
 
template<typename T >
void bind (const size_t i, const T value)
 
template<>
void bind (const size_t i, const char *value)
 
template<>
void bind (const size_t i, const std::string value)
 
template<>
void bind (const size_t i, const int value)
 
template<>
void bind (const size_t i, const long int value)
 
template<>
void bind (const size_t i, double value)
 

Protected Attributes

int params
 
Connconn
 
std::shared_ptr< stmt_basebase = std::make_shared<stmt_base>()
 
const char * unused
 

Private Member Functions

Variadic bind() Helpers
template<typename T >
void _bind_many (size_t i, T value)
 
template<typename T , typename... Args>
void _bind_many (size_t i, T value, Args... args)
 

Detailed Description

An interface for executing and iterating through SQL statements

Constructor & Destructor Documentation

◆ PreparedStatement()

SQLite::Conn::PreparedStatement::PreparedStatement ( Conn conn,
const std::string &  stmt 
)

Prepare a SQL statement

Parameters
[in]connAn active SQLite connection
[out]stmtA SQL query that should be prepared

Member Function Documentation

◆ bind() [1/5]

void SQLite::Conn::PreparedStatement::bind ( Args...  args)
inline

Bind any number of arguments to the statement and automatically call next()

Safety

If too many arguments are bound, an error will be thrown at runtime.

◆ bind() [2/5]

template<>
void SQLite::Conn::PreparedStatement::bind ( const size_t  i,
const std::string  value 
)
inline

Bind text values to the statement

Note: This function is zero-indexed while sqlite3_bind_* is 1-indexed

◆ bind() [3/5]

template<>
void SQLite::Conn::PreparedStatement::bind ( const size_t  i,
const int  value 
)
inline

Bind integer values to the statement

◆ bind() [4/5]

template<>
void SQLite::Conn::PreparedStatement::bind ( const size_t  i,
const long int  value 
)
inline

Bind integer values to the statement

◆ bind() [5/5]

template<>
void SQLite::Conn::PreparedStatement::bind ( const size_t  i,
double  value 
)
inline

Bind floating point values to the statement

◆ close()

void SQLite::Conn::PreparedStatement::close ( )
noexcept

Close the prepared statement

◆ commit()

void SQLite::Conn::PreparedStatement::commit ( )

End a transaction

◆ get_ptr()

sqlite3_stmt * SQLite::Conn::PreparedStatement::get_ptr ( )

Get a raw pointer to the underlying sqlite3_stmt

◆ next()

void SQLite::Conn::PreparedStatement::next ( )

Call after bind()-ing values to execute statement


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