30 sqlite3_finalize(m_stmt);
35 int res = sqlite3_prepare_v2(database, statement.data(), -1, &m_stmt,
nullptr);
37 NDN_THROW(std::domain_error(
"bad SQL statement: " + statement));
43 return sqlite3_bind_text(m_stmt, index, value, size, destructor);
49 return sqlite3_bind_text(m_stmt, index, value.data(), value.size(), destructor);
55 return sqlite3_bind_blob(m_stmt, index, buf, size, destructor);
61 return sqlite3_bind_blob(m_stmt, index, block.
data(), block.
size(), destructor);
67 return sqlite3_bind_int(m_stmt, index, number);
73 return std::string(
reinterpret_cast<const char*
>(sqlite3_column_text(m_stmt, column)),
74 sqlite3_column_bytes(m_stmt, column));
80 return Block(make_span(
reinterpret_cast<const uint8_t*
>(sqlite3_column_blob(m_stmt, column)),
81 sqlite3_column_bytes(m_stmt, column)));
87 return sqlite3_column_int(m_stmt, column);
93 return static_cast<const uint8_t*
>(sqlite3_column_blob(m_stmt, column));
99 return sqlite3_column_bytes(m_stmt, column);
105 return sqlite3_step(m_stmt);
108 Sqlite3Statement::operator sqlite3_stmt*()
Represents a TLV element of the NDN packet format.
const uint8_t * data() const
Returns a raw pointer to the beginning of the encoded wire, i.e., the whole TLV.
size_t size() const
Returns the size of the encoded wire, i.e., of the whole TLV.
Sqlite3Statement(sqlite3 *database, const std::string &statement)
Initialize and prepare Sqlite3 statement.
int bind(int index, const char *value, size_t size, void(*destructor)(void *))
Bind a string to the statement.
int getInt(int column)
Get an integer from column.
const uint8_t * getBlob(int column)
Get a pointer of byte blob from column.
Block getBlock(int column)
Get a block from column.
~Sqlite3Statement()
Finalize the statement.
int getSize(int column)
Get the size of column.
int step()
Wrapper of sqlite3_step.
std::string getString(int column)
Get a string from column.