libnick 2024.9.2
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
Nickvision::Database::SqlStatement Class Reference

A sqlite statement. More...

#include <sqlstatement.h>

Public Member Functions

 SqlStatement (const std::shared_ptr< sqlite3 > &database, const std::string &command)
 Constructs a SqlStatement.
 
bool bind (int index, int value)
 Binds an int to a parameter.
 
bool bind (int index, sqlite3_int64 value)
 Binds an int64 to a parameter.
 
bool bind (int index, double value)
 Binds a double to a parameter.
 
bool bind (int index, bool value)
 Binds a bool to a parameter.
 
bool bind (int index, const std::string &value)
 Binds a string to a parameter.
 
bool bind (int index, void *value, int n)
 Binds a blob to a parameter.
 
bool step ()
 Steps through the statement.
 
int getColumnInt (int index) const
 Gets an int from a column.
 
sqlite3_int64 getColumnInt64 (int index) const
 Gets an int64 from a column.
 
double getColumnDouble (int index) const
 Gets a double from a column.
 
bool getColumnBool (int index) const
 Gets a bool from a column.
 
std::string getColumnString (int index) const
 Gets a string from a column.
 
std::pair< const void *, size_t > getColumnBlob (int index) const
 Gets a blob from a column.
 
 operator bool () const
 Gets whether or not the object is valid or not.
 

Detailed Description

A sqlite statement.

Constructor & Destructor Documentation

◆ SqlStatement()

Nickvision::Database::SqlStatement::SqlStatement ( const std::shared_ptr< sqlite3 > & database,
const std::string & command )

Constructs a SqlStatement.

Parameters
databaseThe sqlite3 database
commandThe sql command to bind to the statement
Exceptions
std::runtime_errorThrown if error in executing sql statement

Member Function Documentation

◆ bind() [1/6]

bool Nickvision::Database::SqlStatement::bind ( int index,
bool value )

Binds a bool to a parameter.

Parameters
indexThe index of the parameter
valueThe bool to bind
Returns
True if bind was successful, else false

◆ bind() [2/6]

bool Nickvision::Database::SqlStatement::bind ( int index,
const std::string & value )

Binds a string to a parameter.

Parameters
indexThe index of the parameter
valueThe string to bind
Returns
True if bind was successful, else false

◆ bind() [3/6]

bool Nickvision::Database::SqlStatement::bind ( int index,
double value )

Binds a double to a parameter.

Parameters
indexThe index of the parameter
valueThe double to bind
Returns
True if bind was successful, else false

◆ bind() [4/6]

bool Nickvision::Database::SqlStatement::bind ( int index,
int value )

Binds an int to a parameter.

Parameters
indexThe index of the parameter
valueThe int to bind
Returns
True if bind was successful, else false

◆ bind() [5/6]

bool Nickvision::Database::SqlStatement::bind ( int index,
sqlite3_int64 value )

Binds an int64 to a parameter.

Parameters
indexThe index of the parameter
valueThe int64 to bind
Returns
True if bind was successful, else false

◆ bind() [6/6]

bool Nickvision::Database::SqlStatement::bind ( int index,
void * value,
int n )

Binds a blob to a parameter.

Parameters
indexThe index of the parameter
valueThe blob to bind
nThe size of the blob
Returns
True if bind was successful, else false

◆ getColumnBlob()

std::pair< const void *, size_t > Nickvision::Database::SqlStatement::getColumnBlob ( int index) const

Gets a blob from a column.

Parameters
indexThe index of the column
Returns
A pair of the blob from the column and the blob's size

◆ getColumnBool()

bool Nickvision::Database::SqlStatement::getColumnBool ( int index) const

Gets a bool from a column.

Parameters
indexThe index of the column
Returns
The bool from the column

◆ getColumnDouble()

double Nickvision::Database::SqlStatement::getColumnDouble ( int index) const

Gets a double from a column.

Parameters
indexThe index of the column
Returns
The double from the column

◆ getColumnInt()

int Nickvision::Database::SqlStatement::getColumnInt ( int index) const

Gets an int from a column.

Parameters
indexThe index of the column
Returns
The int from the column

◆ getColumnInt64()

sqlite3_int64 Nickvision::Database::SqlStatement::getColumnInt64 ( int index) const

Gets an int64 from a column.

Parameters
indexThe index of the column
Returns
The int64 from the column

◆ getColumnString()

std::string Nickvision::Database::SqlStatement::getColumnString ( int index) const

Gets a string from a column.

Parameters
indexThe index of the column
Returns
The string from the column

◆ operator bool()

Nickvision::Database::SqlStatement::operator bool ( ) const

Gets whether or not the object is valid or not.

Returns
True if valid, else false

◆ step()

bool Nickvision::Database::SqlStatement::step ( )

Steps through the statement.

Returns
True if SQLITE_ROW, else false
Exceptions
std::runtime_errorThrown if error in executing sql statement

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