ndn::util::Sqlite3Statement Class Reference

Wrap an SQLite3 prepared statement. More...

#include <ndn-cxx/util/sqlite3-statement.hpp>

+ Inheritance diagram for ndn::util::Sqlite3Statement:
+ Collaboration diagram for ndn::util::Sqlite3Statement:

Public Member Functions

 Sqlite3Statement (sqlite3 *database, const std::string &statement)
 Initialize and prepare Sqlite3 statement. More...
 
 ~Sqlite3Statement ()
 Finalize the statement. More...
 
int bind (int index, const Block &block, void(*destructor)(void *))
 Bind a byte blob to the statement. More...
 
int bind (int index, const char *value, size_t size, void(*destructor)(void *))
 Bind a string to the statement. More...
 
int bind (int index, const std::string &value, void(*destructor)(void *))
 Bind a string to the statement. More...
 
int bind (int index, const void *value, size_t size, void(*destructor)(void *))
 Bind a byte blob to the statement. More...
 
int bind (int index, int number)
 Bind an integer to the statement. More...
 
const uint8_t * getBlob (int column)
 Get a pointer of byte blob from column. More...
 
Block getBlock (int column)
 Get a block from column. More...
 
int getInt (int column)
 Get an integer from column. More...
 
int getSize (int column)
 Get the size of column. More...
 
std::string getString (int column)
 Get a string from column. More...
 
 operator sqlite3_stmt * ()
 Implicitly converts to sqlite3_stmt* to be used in SQLite C API. More...
 
int step ()
 Wrapper of sqlite3_step. More...
 

Detailed Description

Wrap an SQLite3 prepared statement.

Warning
This class is implementation detail of ndn-cxx library.

Definition at line 36 of file sqlite3-statement.hpp.

Constructor & Destructor Documentation

◆ Sqlite3Statement()

ndn::util::Sqlite3Statement::Sqlite3Statement ( sqlite3 *  database,
const std::string &  statement 
)

Initialize and prepare Sqlite3 statement.

Parameters
databasehandler to open sqlite3 database
statementSQL statement
Exceptions
std::domain_errorSQL statement is bad

Definition at line 33 of file sqlite3-statement.cpp.

◆ ~Sqlite3Statement()

ndn::util::Sqlite3Statement::~Sqlite3Statement ( )

Finalize the statement.

Definition at line 28 of file sqlite3-statement.cpp.

Member Function Documentation

◆ bind() [1/5]

int ndn::util::Sqlite3Statement::bind ( int  index,
const Block block,
void(*)(void *)  destructor 
)

Bind a byte blob to the statement.

Parameters
indexThe binding position
blockThe binding block
destructorSQLite3 destructor, e.g., SQLITE_TRANSIENT
Returns
SQLite result value

Definition at line 59 of file sqlite3-statement.cpp.

◆ bind() [2/5]

int ndn::util::Sqlite3Statement::bind ( int  index,
const char *  value,
size_t  size,
void(*)(void *)  destructor 
)

Bind a string to the statement.

Parameters
indexThe binding position
valueThe pointer of the binding string
sizeThe size of the binding string
destructorSQLite3 destructor, e.g., SQLITE_TRANSIENT
Returns
SQLite result value.

Definition at line 41 of file sqlite3-statement.cpp.

◆ bind() [3/5]

int ndn::util::Sqlite3Statement::bind ( int  index,
const std::string &  value,
void(*)(void *)  destructor 
)

Bind a string to the statement.

Parameters
indexThe binding position
valueThe binding string
destructorSQLite3 destructor, e.g., SQLITE_TRANSIENT
Returns
SQLite result value.

Definition at line 47 of file sqlite3-statement.cpp.

◆ bind() [4/5]

int ndn::util::Sqlite3Statement::bind ( int  index,
const void *  value,
size_t  size,
void(*)(void *)  destructor 
)

Bind a byte blob to the statement.

Parameters
indexThe binding position
valueThe pointer of the blob
sizeThe size of the blob
destructorSQLite3 destructor, e.g., SQLITE_TRANSIENT
Returns
SQLite result value.

Definition at line 53 of file sqlite3-statement.cpp.

◆ bind() [5/5]

int ndn::util::Sqlite3Statement::bind ( int  index,
int  number 
)

Bind an integer to the statement.

Parameters
indexThe binding position
numberThe binding integer
Returns
SQLite result value

Definition at line 65 of file sqlite3-statement.cpp.

◆ getBlob()

const uint8_t * ndn::util::Sqlite3Statement::getBlob ( int  column)

Get a pointer of byte blob from column.

Definition at line 91 of file sqlite3-statement.cpp.

◆ getBlock()

Block ndn::util::Sqlite3Statement::getBlock ( int  column)

Get a block from column.

Definition at line 78 of file sqlite3-statement.cpp.

◆ getInt()

int ndn::util::Sqlite3Statement::getInt ( int  column)

Get an integer from column.

Definition at line 85 of file sqlite3-statement.cpp.

◆ getSize()

int ndn::util::Sqlite3Statement::getSize ( int  column)

Get the size of column.

Definition at line 97 of file sqlite3-statement.cpp.

◆ getString()

std::string ndn::util::Sqlite3Statement::getString ( int  column)

Get a string from column.

Definition at line 71 of file sqlite3-statement.cpp.

◆ operator sqlite3_stmt *()

ndn::util::Sqlite3Statement::operator sqlite3_stmt * ( )

Implicitly converts to sqlite3_stmt* to be used in SQLite C API.

Definition at line 108 of file sqlite3-statement.cpp.

◆ step()

int ndn::util::Sqlite3Statement::step ( )

Wrapper of sqlite3_step.

Definition at line 103 of file sqlite3-statement.cpp.