Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::db::impl::SqlitePreparedStatementImpl Class Referencefinal

SQLite prepared statement implementation. More...

#include <SqlitePreparedStatementImpl.h>

Inheritance diagram for sese::db::impl::SqlitePreparedStatementImpl:
sese::db::PreparedStatement

Public Member Functions

 SqlitePreparedStatementImpl (sqlite3_stmt *stmt, size_t count) noexcept
 
 ~SqlitePreparedStatementImpl () noexcept override
 
ResultSet::Ptr executeQuery () noexcept override
 Execute query.
 
int64_t executeUpdate () noexcept override
 Execute update.
 
bool setDouble (uint32_t index, const double &value) noexcept override
 Set double-precision floating-point value.
 
bool setFloat (uint32_t index, const float &value) noexcept override
 Set single-precision floating-point value.
 
bool setLong (uint32_t index, const int64_t &value) noexcept override
 Set long integer value.
 
bool setInteger (uint32_t index, const int32_t &value) noexcept override
 Set integer value.
 
bool setText (uint32_t index, const char *value) noexcept override
 Set text value.
 
bool setNull (uint32_t index) noexcept override
 Set to NULL.
 
bool setDateTime (uint32_t index, const sese::DateTime &value) noexcept override
 Set to dateTime.
 
bool getColumnType (uint32_t index, MetadataType &type) noexcept override
 Get result set column type.
 
int64_t getColumnSize (uint32_t index) noexcept override
 Get result set column size. This interface is usually only effective when the type is binary or string, and the unit is bytes.
 
int getLastError () const noexcept override
 Get the error code for the corresponding driver of the instance.
 
const char * getLastErrorMessage () const noexcept override
 Get the error message for the corresponding driver of the instance. Need to check for null.
 
- Public Member Functions inherited from sese::db::PreparedStatement
virtual ~PreparedStatement () noexcept=default
 
ErrorCode getErrorCode () const
 

Static Protected Member Functions

static std::string splitBefore (const std::string &str)
 

Protected Attributes

sqlite3_stmt * stmt
 
bool stmtStatus = false
 
bool * isManual
 
size_t count = 0
 
void ** buffer
 

Static Protected Attributes

static const char * INTEGER_AFFINITY_SET []
 
static const char * TEXT_AFFINITY_SET []
 
static const char * REAL_AFFINITY_SET []
 

Additional Inherited Members

- Public Types inherited from sese::db::PreparedStatement
using Ptr = std::unique_ptr<PreparedStatement>
 

Detailed Description

SQLite prepared statement implementation.

Constructor & Destructor Documentation

◆ SqlitePreparedStatementImpl()

impl::SqlitePreparedStatementImpl::SqlitePreparedStatementImpl ( sqlite3_stmt * stmt,
size_t count )
explicitnoexcept

References count().

◆ ~SqlitePreparedStatementImpl()

impl::SqlitePreparedStatementImpl::~SqlitePreparedStatementImpl ( )
overridenoexcept

References count(), and free().

Member Function Documentation

◆ executeQuery()

ResultSet::Ptr impl::SqlitePreparedStatementImpl::executeQuery ( )
overridevirtualnoexcept

Execute query.

Returns
Query result set
Return values
nullptrQuery failed

Implements sese::db::PreparedStatement.

◆ executeUpdate()

int64_t impl::SqlitePreparedStatementImpl::executeUpdate ( )
overridevirtualnoexcept

Execute update.

Returns
Number of rows affected
Return values
-1Update failed

Implements sese::db::PreparedStatement.

◆ getColumnSize()

int64_t impl::SqlitePreparedStatementImpl::getColumnSize ( uint32_t index)
overridevirtualnoexcept

Get result set column size. This interface is usually only effective when the type is binary or string, and the unit is bytes.

Parameters
indexIndex value
Returns
Returns -1 if failed

Implements sese::db::PreparedStatement.

◆ getColumnType()

bool impl::SqlitePreparedStatementImpl::getColumnType ( uint32_t index,
MetadataType & type )
overridevirtualnoexcept

Get result set column type.

Parameters
indexIndex value
typeColumn type
Returns
Whether the retrieval was successful

Implements sese::db::PreparedStatement.

References sese::db::BOOLEAN, sese::db::DATE, sese::db::DATE_TIME, sese::db::FLOAT, in(), sese::db::INTEGER, sese::strcmpDoNotCase(), sese::db::TEXT, and sese::db::UNKNOWN.

◆ getLastError()

int impl::SqlitePreparedStatementImpl::getLastError ( ) const
nodiscardoverridevirtualnoexcept

Get the error code for the corresponding driver of the instance.

Returns
Error code

Implements sese::db::PreparedStatement.

◆ getLastErrorMessage()

const char * impl::SqlitePreparedStatementImpl::getLastErrorMessage ( ) const
nodiscardoverridevirtualnoexcept

Get the error message for the corresponding driver of the instance. Need to check for null.

Return values
nullptrFailed to get error message
Returns
Error message

Implements sese::db::PreparedStatement.

◆ setDateTime()

bool impl::SqlitePreparedStatementImpl::setDateTime ( uint32_t index,
const sese::DateTime & value )
overridevirtualnoexcept

Set to dateTime.

Parameters
indexIndex
valueDate
Returns
Whether the setting was successful

Implements sese::db::PreparedStatement.

References count(), sese::text::DateTimeFormatter::format(), and free().

◆ setDouble()

bool impl::SqlitePreparedStatementImpl::setDouble ( uint32_t index,
const double & value )
overridevirtualnoexcept

Set double-precision floating-point value.

Parameters
indexIndex
valueValue
Returns
Whether the setting was successful

Implements sese::db::PreparedStatement.

References count(), and free().

◆ setFloat()

bool impl::SqlitePreparedStatementImpl::setFloat ( uint32_t index,
const float & value )
overridevirtualnoexcept

Set single-precision floating-point value.

Parameters
indexIndex
valueValue
Returns
Whether the setting was successful

Implements sese::db::PreparedStatement.

References count(), and free().

◆ setInteger()

bool impl::SqlitePreparedStatementImpl::setInteger ( uint32_t index,
const int32_t & value )
overridevirtualnoexcept

Set integer value.

Parameters
indexIndex
valueValue
Returns
Whether the setting was successful

Implements sese::db::PreparedStatement.

References count(), and free().

◆ setLong()

bool impl::SqlitePreparedStatementImpl::setLong ( uint32_t index,
const int64_t & value )
overridevirtualnoexcept

Set long integer value.

Parameters
indexIndex
valueValue
Returns
Whether the setting was successful

Implements sese::db::PreparedStatement.

References count(), and free().

◆ setNull()

bool impl::SqlitePreparedStatementImpl::setNull ( uint32_t index)
overridevirtualnoexcept

Set to NULL.

Parameters
indexIndex
Returns
Whether the setting was successful

Implements sese::db::PreparedStatement.

References count(), and free().

◆ setText()

bool impl::SqlitePreparedStatementImpl::setText ( uint32_t index,
const char * value )
overridevirtualnoexcept

Set text value.

Parameters
indexIndex
valueValue
Returns
Whether the setting was successful

Implements sese::db::PreparedStatement.

References count(), and free().

◆ splitBefore()

std::string impl::SqlitePreparedStatementImpl::splitBefore ( const std::string & str)
staticprotected

Member Data Documentation

◆ buffer

void** sese::db::impl::SqlitePreparedStatementImpl::buffer
protected

◆ count

size_t sese::db::impl::SqlitePreparedStatementImpl::count = 0
protected

◆ INTEGER_AFFINITY_SET

const char * impl::SqlitePreparedStatementImpl::INTEGER_AFFINITY_SET
staticprotected
Initial value:
{
"INT",
"INTEGER",
"TINYINT",
"SMALLINT",
"MEDIUMINT",
"BIGINT",
"UNSIGNED BIG INT",
"INT2",
"INT8"
}

◆ isManual

bool* sese::db::impl::SqlitePreparedStatementImpl::isManual
protected

◆ REAL_AFFINITY_SET

const char * impl::SqlitePreparedStatementImpl::REAL_AFFINITY_SET
staticprotected
Initial value:
{
"REAL",
"DOUBLE",
"DOUBLE PRECISION",
"FLOAT",
"NUMERIC",
"DECIMAL"
}

◆ stmt

sqlite3_stmt* sese::db::impl::SqlitePreparedStatementImpl::stmt
protected

◆ stmtStatus

bool sese::db::impl::SqlitePreparedStatementImpl::stmtStatus = false
protected

◆ TEXT_AFFINITY_SET

const char * impl::SqlitePreparedStatementImpl::TEXT_AFFINITY_SET
staticprotected
Initial value:
{
"CHARACTER",
"VARCHAR",
"VARYING CHARACTER",
"NCHAR",
"NATIVE CHARACTER",
"NVARCHAR",
"TEXT",
"CLOB"
}

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