Storage Engine API
mongo::SqliteStatement Class Referencefinal

SqliteStatement is a wrapper around the sqlite3_stmt object. More...

#include <mobile_sqlite_statement.h>

Detailed Description

SqliteStatement is a wrapper around the sqlite3_stmt object.

All calls to the SQLite API that involve a sqlite_stmt object are made in this class.

Public Member Functions

 SqliteStatement (const MobileSession &session, const std::string &sqlQuery)
 Creates and prepares a SQLite statement. More...
 
 ~SqliteStatement ()
 Finalizes the prepared statement. More...
 
void bindInt (int paramIndex, int64_t intValue)
 The various bind methods bind a value to the query parameter specified by paramIndex. More...
 
void bindBlob (int paramIndex, const void *data, int len)
 
void bindText (int paramIndex, const char *data, int len)
 
void clearBindings ()
 
int step (int desiredStatus=-1)
 Wraps sqlite3_step and returns the resulting status. More...
 
int64_t getColInt (int colIndex)
 The getCol methods wrap sqlite3_column methods and return the correctly typed values stored in a retrieved query row[colIndex]. More...
 
const voidgetColBlob (int colIndex)
 
int64_t getColBytes (int colIndex)
 Returns the number of bytes in a corresponding blob or string. More...
 
const voidgetColText (int colIndex)
 Wraps sqlite3_column_text method and returns the text from the retrieved query row[colIndex]. More...
 
void reset ()
 Resets the statement to the first of the query result rows. More...
 
void setExceptionStatus (int status)
 Sets the last status on the prepared statement. More...
 

Static Public Member Functions

static void execQuery (MobileSession *session, const std::string &query)
 A one step query execution that wraps sqlite3_prepare_v2(), sqlite3_step(), and sqlite3_finalize(). More...
 

Private Attributes

sqlite3_stmt * _stmt
 
int _exceptionStatus = SQLITE_OK
 

Constructor & Destructor Documentation

◆ SqliteStatement()

mongo::SqliteStatement::SqliteStatement ( const MobileSession session,
const std::string &  sqlQuery 
)

Creates and prepares a SQLite statement.

◆ ~SqliteStatement()

mongo::SqliteStatement::~SqliteStatement ( )

Finalizes the prepared statement.

Member Function Documentation

◆ bindBlob()

void mongo::SqliteStatement::bindBlob ( int  paramIndex,
const void data,
int  len 
)

◆ bindInt()

void mongo::SqliteStatement::bindInt ( int  paramIndex,
int64_t  intValue 
)

The various bind methods bind a value to the query parameter specified by paramIndex.

Parameters
paramIndex- zero-based index of a query parameter.

◆ bindText()

void mongo::SqliteStatement::bindText ( int  paramIndex,
const char *  data,
int  len 
)

◆ clearBindings()

void mongo::SqliteStatement::clearBindings ( )

◆ execQuery()

void mongo::SqliteStatement::execQuery ( MobileSession session,
const std::string &  query 
)
static

A one step query execution that wraps sqlite3_prepare_v2(), sqlite3_step(), and sqlite3_finalize().

None of the rows retrieved, if any, are saved before the query is finalized. Thus, this method should not be used for read operations.

◆ getColBlob()

const void * mongo::SqliteStatement::getColBlob ( int  colIndex)

◆ getColBytes()

int64_t mongo::SqliteStatement::getColBytes ( int  colIndex)

Returns the number of bytes in a corresponding blob or string.

◆ getColInt()

int64_t mongo::SqliteStatement::getColInt ( int  colIndex)

The getCol methods wrap sqlite3_column methods and return the correctly typed values stored in a retrieved query row[colIndex].

Parameters
colIndex- zero-based index of a column retrieved from a query row.

◆ getColText()

const void * mongo::SqliteStatement::getColText ( int  colIndex)

Wraps sqlite3_column_text method and returns the text from the retrieved query row[colIndex].

Parameters
colIndex- zero-based index of a column retrieved from a query row.

◆ reset()

void mongo::SqliteStatement::reset ( )

Resets the statement to the first of the query result rows.

◆ setExceptionStatus()

void mongo::SqliteStatement::setExceptionStatus ( int  status)
inline

Sets the last status on the prepared statement.

◆ step()

int mongo::SqliteStatement::step ( int  desiredStatus = -1)

Wraps sqlite3_step and returns the resulting status.

Parameters
desiredStatus- the desired return status of sqlite3_step. When desiredStatus is non-negative, checkStatus compares desiredStatus with the returned status from sqlite3_step. By default, checkStatus is ignored.

Member Data Documentation

◆ _exceptionStatus

int mongo::SqliteStatement::_exceptionStatus = SQLITE_OK
private

◆ _stmt

sqlite3_stmt* mongo::SqliteStatement::_stmt
private

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