Actually it is not possible to access to sqlite3 sqlite3_column_table_name function directly from SQLite::Statement.
It is because we have not access to sqlite3_stmt: because Statement::getPreparedStatement is private.
So it is possible to:
- Let Statement::getPreparedStatement is to be protected (or public)?
- Or add a function into statement to call sqlite3_column_table_name
Actually I must prepare 2 statements!
This code is like this, not really optimized!
class Statement::Impl : public std::enable_shared_from_this<Statement::Impl>
{
public:
explicit Impl(SQLite::Database &_rDatabase, SQLite::Statement && _rrStatment);
/// @brief Destructor
virtual ~Impl();
protected:
SQLite::Database & m_rDatabase; ///< Reference to database
SQLite::Statement m_Statement; ///< Internal statement
sqlite3_stmt * m_pRawStmt; ///< Pointer on statement, this used ONLY FOR sqlite3_column_table_name
};
Statement::Impl::Impl(SQLite::Database &_rDatabase, SQLite::Statement && _rrStatment)
: m_rDatabase(_rDatabase)
, m_Statement(std::move(_rrStatment))
, m_pRawStmt(nullptr)
{
// Prepare C raw handle to access to metadata table name
sqlite3_prepare_v2(m_rDatabase.getDatabase()->getHandle(), m_Statement.getExpandedSQL().c_str(), -1, &m_pRawStmt, nullptr);
}
Statement::Impl::~Impl()
{
if (m_pRawStmt != nullptr)
{
sqlite3_finalize(m_pRawStmt);
m_pRawStmt = nullptr;
}
}
std::string Statement::Impl::getTableName(int _iIndexColumn) const
{
return sqlite3_column_table_name(m_pRawStmt, _iIndexColumn);
}
Actually it is not possible to access to sqlite3 sqlite3_column_table_name function directly from SQLite::Statement.
It is because we have not access to sqlite3_stmt: because Statement::getPreparedStatement is private.
So it is possible to:
Actually I must prepare 2 statements!
This code is like this, not really optimized!