mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 09:46:02 -04:00
Added Statement::getColumnCount() and commented out the throw specifications (they are not usefull)
This commit is contained in:
parent
abc1f7bfa3
commit
0a1520ced0
@ -16,7 +16,7 @@ namespace SQLite
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Open the provided database UTF-8 filename.
|
// Open the provided database UTF-8 filename.
|
||||||
Database::Database(const char* apFilename, const int aFlags /*= SQLITE_OPEN_READONLY*/) throw(SQLite::Exception) :
|
Database::Database(const char* apFilename, const int aFlags /*= SQLITE_OPEN_READONLY*/) : // throw(SQLite::Exception)
|
||||||
mpSQLite(NULL),
|
mpSQLite(NULL),
|
||||||
mFilename(apFilename)
|
mFilename(apFilename)
|
||||||
{
|
{
|
||||||
@ -50,13 +50,13 @@ Database::~Database(void) throw() // nothrow
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Register a Statement object (a SQLite query)
|
// Register a Statement object (a SQLite query)
|
||||||
void Database::registerStatement(Statement& aStatement) throw(SQLite::Exception)
|
void Database::registerStatement(Statement& aStatement) // throw(SQLite::Exception)
|
||||||
{
|
{
|
||||||
mStatementList.push_back(&aStatement);
|
mStatementList.push_back(&aStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unregister a Statement object
|
// Unregister a Statement object
|
||||||
void Database::unregisterStatement(Statement& aStatement) throw(SQLite::Exception)
|
void Database::unregisterStatement(Statement& aStatement) // throw(SQLite::Exception)
|
||||||
{
|
{
|
||||||
std::vector<Statement*>::iterator iStatement;
|
std::vector<Statement*>::iterator iStatement;
|
||||||
iStatement = std::find(mStatementList.begin(), mStatementList.end(), &aStatement);
|
iStatement = std::find(mStatementList.begin(), mStatementList.end(), &aStatement);
|
||||||
|
@ -45,7 +45,7 @@ public:
|
|||||||
* @param[in] apFilename UTF-8 path/uri to the database file ("filename" sqlite3 parameter)
|
* @param[in] apFilename UTF-8 path/uri to the database file ("filename" sqlite3 parameter)
|
||||||
* @param[in] aFlags SQLITE_OPEN_READONLY/SQLITE_OPEN_READWRITE/SQLITE_OPEN_CREATE...
|
* @param[in] aFlags SQLITE_OPEN_READONLY/SQLITE_OPEN_READWRITE/SQLITE_OPEN_CREATE...
|
||||||
*/
|
*/
|
||||||
explicit Database(const char* apFilename, const int aFlags = SQLITE_OPEN_READONLY) throw(SQLite::Exception);
|
explicit Database(const char* apFilename, const int aFlags = SQLITE_OPEN_READONLY); // throw(SQLite::Exception);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Close the SQLite database connection.
|
* @brief Close the SQLite database connection.
|
||||||
@ -58,12 +58,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Register a Statement object (a SQLite query)
|
* @brief Register a Statement object (a SQLite query)
|
||||||
*/
|
*/
|
||||||
void registerStatement(Statement& aStatement) throw(SQLite::Exception);
|
void registerStatement(Statement& aStatement); // throw(SQLite::Exception);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Unregister a Statement object
|
* @brief Unregister a Statement object
|
||||||
*/
|
*/
|
||||||
void unregisterStatement(Statement& aStatement) throw(SQLite::Exception);
|
void unregisterStatement(Statement& aStatement); // throw(SQLite::Exception);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Filename used to open the database
|
* @brief Filename used to open the database
|
||||||
|
@ -16,7 +16,7 @@ namespace SQLite
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Compile and register the SQL query for the provided SQLite Database Connection
|
// Compile and register the SQL query for the provided SQLite Database Connection
|
||||||
Statement::Statement(Database &aDatabase, const char* apQuery) throw(SQLite::Exception) :
|
Statement::Statement(Database &aDatabase, const char* apQuery) : // throw(SQLite::Exception)
|
||||||
mpStmt(NULL),
|
mpStmt(NULL),
|
||||||
mDatabase(aDatabase),
|
mDatabase(aDatabase),
|
||||||
mQuery(apQuery),
|
mQuery(apQuery),
|
||||||
@ -43,7 +43,7 @@ Statement::~Statement(void) throw() // nothrow
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reset the statement to make it ready for a new execution
|
// Reset the statement to make it ready for a new execution
|
||||||
void Statement::reset(void) throw(SQLite::Exception)
|
void Statement::reset(void) // throw(SQLite::Exception)
|
||||||
{
|
{
|
||||||
mbDone = false;
|
mbDone = false;
|
||||||
int ret = sqlite3_reset(mpStmt);
|
int ret = sqlite3_reset(mpStmt);
|
||||||
@ -54,7 +54,7 @@ void Statement::reset(void) throw(SQLite::Exception)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bind an int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
// Bind an int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
||||||
void Statement::bind(const int aIndex, const int& aValue) throw(SQLite::Exception)
|
void Statement::bind(const int aIndex, const int& aValue) // throw(SQLite::Exception)
|
||||||
{
|
{
|
||||||
int ret = sqlite3_bind_int(mpStmt, aIndex, aValue);
|
int ret = sqlite3_bind_int(mpStmt, aIndex, aValue);
|
||||||
if (SQLITE_OK != ret)
|
if (SQLITE_OK != ret)
|
||||||
@ -64,7 +64,7 @@ void Statement::bind(const int aIndex, const int& aValue) throw(SQLite::Exceptio
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bind a 64bits int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
// Bind a 64bits int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
||||||
void Statement::bind(const int aIndex, const sqlite3_int64& aValue) throw(SQLite::Exception)
|
void Statement::bind(const int aIndex, const sqlite3_int64& aValue) // throw(SQLite::Exception)
|
||||||
|
|
||||||
{
|
{
|
||||||
int ret = sqlite3_bind_int64(mpStmt, aIndex, aValue);
|
int ret = sqlite3_bind_int64(mpStmt, aIndex, aValue);
|
||||||
@ -75,7 +75,7 @@ void Statement::bind(const int aIndex, const sqlite3_int64& aValue) throw(SQLite
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bind a double (64bits float) value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
// Bind a double (64bits float) value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
||||||
void Statement::bind(const int aIndex, const double& aValue) throw(SQLite::Exception)
|
void Statement::bind(const int aIndex, const double& aValue) // throw(SQLite::Exception)
|
||||||
{
|
{
|
||||||
int ret = sqlite3_bind_double(mpStmt, aIndex, aValue);
|
int ret = sqlite3_bind_double(mpStmt, aIndex, aValue);
|
||||||
if (SQLITE_OK != ret)
|
if (SQLITE_OK != ret)
|
||||||
@ -85,7 +85,7 @@ void Statement::bind(const int aIndex, const double& aValue) throw(SQLite::Excep
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bind a string value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
// Bind a string value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
||||||
void Statement::bind(const int aIndex, const std::string& aValue) throw(SQLite::Exception)
|
void Statement::bind(const int aIndex, const std::string& aValue) // throw(SQLite::Exception)
|
||||||
{
|
{
|
||||||
int ret = sqlite3_bind_text(mpStmt, aIndex, aValue.c_str(), aValue.size(), SQLITE_TRANSIENT);
|
int ret = sqlite3_bind_text(mpStmt, aIndex, aValue.c_str(), aValue.size(), SQLITE_TRANSIENT);
|
||||||
if (SQLITE_OK != ret)
|
if (SQLITE_OK != ret)
|
||||||
@ -95,7 +95,7 @@ void Statement::bind(const int aIndex, const std::string& aValue) throw(SQLite::
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bind a text value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
// Bind a text value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
||||||
void Statement::bind(const int aIndex, const char* apValue) throw(SQLite::Exception)
|
void Statement::bind(const int aIndex, const char* apValue) // throw(SQLite::Exception)
|
||||||
{
|
{
|
||||||
int ret = sqlite3_bind_text(mpStmt, aIndex, apValue, -1, SQLITE_TRANSIENT);
|
int ret = sqlite3_bind_text(mpStmt, aIndex, apValue, -1, SQLITE_TRANSIENT);
|
||||||
if (SQLITE_OK != ret)
|
if (SQLITE_OK != ret)
|
||||||
@ -105,7 +105,7 @@ void Statement::bind(const int aIndex, const char* apValue) throw(SQLite::Except
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bind a NULL value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
// Bind a NULL value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
||||||
void Statement::bind(const int aIndex) throw(SQLite::Exception)
|
void Statement::bind(const int aIndex) // throw(SQLite::Exception)
|
||||||
{
|
{
|
||||||
int ret = sqlite3_bind_null(mpStmt, aIndex);
|
int ret = sqlite3_bind_null(mpStmt, aIndex);
|
||||||
if (SQLITE_OK != ret)
|
if (SQLITE_OK != ret)
|
||||||
@ -115,7 +115,7 @@ void Statement::bind(const int aIndex) throw(SQLite::Exception)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Execute a step of the query to fetch one row of results
|
// Execute a step of the query to fetch one row of results
|
||||||
bool Statement::executeStep(void) throw(SQLite::Exception)
|
bool Statement::executeStep(void) // throw(SQLite::Exception)
|
||||||
{
|
{
|
||||||
bool bOk = false;
|
bool bOk = false;
|
||||||
|
|
||||||
@ -140,5 +140,10 @@ bool Statement::executeStep(void) throw(SQLite::Exception)
|
|||||||
return bOk;
|
return bOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the number of columns in the result set returned by the prepared statement
|
||||||
|
int Statement::getColumnCount(void) const throw() // nothrow
|
||||||
|
{
|
||||||
|
return sqlite3_column_count(mpStmt);
|
||||||
|
}
|
||||||
|
|
||||||
}; // namespace SQLite
|
}; // namespace SQLite
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
*
|
*
|
||||||
* Exception is thrown in case of error, then the Statement object is NOT constructed.
|
* Exception is thrown in case of error, then the Statement object is NOT constructed.
|
||||||
*/
|
*/
|
||||||
explicit Statement(Database &aDatabase, const char* apQuery) throw(SQLite::Exception);
|
explicit Statement(Database &aDatabase, const char* apQuery); // throw(SQLite::Exception);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Finalize and unregister the SQL query from the SQLite Database Connection.
|
* @brief Finalize and unregister the SQL query from the SQLite Database Connection.
|
||||||
@ -42,37 +42,42 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Reset the statement to make it ready for a new execution.
|
* @brief Reset the statement to make it ready for a new execution.
|
||||||
*/
|
*/
|
||||||
void reset(void) throw(SQLite::Exception);
|
void reset(void); // throw(SQLite::Exception);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Bind an int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
* @brief Bind an int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
||||||
*/
|
*/
|
||||||
void bind(const int aIndex, const int& aValue) throw(SQLite::Exception);
|
void bind(const int aIndex, const int& aValue) ; // throw(SQLite::Exception);
|
||||||
/**
|
/**
|
||||||
* @brief Bind a 64bits int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
* @brief Bind a 64bits int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
||||||
*/
|
*/
|
||||||
void bind(const int aIndex, const sqlite3_int64& aValue) throw(SQLite::Exception);
|
void bind(const int aIndex, const sqlite3_int64& aValue) ; // throw(SQLite::Exception);
|
||||||
/**
|
/**
|
||||||
* @brief Bind a double (64bits float) value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
* @brief Bind a double (64bits float) value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
||||||
*/
|
*/
|
||||||
void bind(const int aIndex, const double& aValue) throw(SQLite::Exception);
|
void bind(const int aIndex, const double& aValue) ; // throw(SQLite::Exception);
|
||||||
/**
|
/**
|
||||||
* @brief Bind a string value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
* @brief Bind a string value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
||||||
*/
|
*/
|
||||||
void bind(const int aIndex, const std::string& aValue) throw(SQLite::Exception);
|
void bind(const int aIndex, const std::string& aValue) ; // throw(SQLite::Exception);
|
||||||
/**
|
/**
|
||||||
* @brief Bind a text value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
* @brief Bind a text value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
||||||
*/
|
*/
|
||||||
void bind(const int aIndex, const char* apValue) throw(SQLite::Exception);
|
void bind(const int aIndex, const char* apValue) ; // throw(SQLite::Exception);
|
||||||
/**
|
/**
|
||||||
* @brief Bind a NULL value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
* @brief Bind a NULL value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
|
||||||
*/
|
*/
|
||||||
void bind(const int aIndex) throw(SQLite::Exception); // bind NULL value
|
void bind(const int aIndex); // throw(SQLite::Exception); // bind NULL value
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Execute a step of the query to fetch one row of results.
|
* @brief Execute a step of the query to fetch one row of results.
|
||||||
*/
|
*/
|
||||||
bool executeStep(void) throw(SQLite::Exception);
|
bool executeStep(void); // throw(SQLite::Exception);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return the number of columns in the result set returned by the prepared statement
|
||||||
|
*/
|
||||||
|
int getColumnCount(void) const throw(); // nothrow
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief UTF-8 SQL Query.
|
* @brief UTF-8 SQL Query.
|
||||||
|
@ -11,6 +11,7 @@ int main (void)
|
|||||||
|
|
||||||
// Compile a SQL query, containing one parameter (index 1)
|
// Compile a SQL query, containing one parameter (index 1)
|
||||||
SQLite::Statement query(db, "SELECT * FROM test WHERE size>?");
|
SQLite::Statement query(db, "SELECT * FROM test WHERE size>?");
|
||||||
|
std::cout << "SQLite statement compiled (" << query.getColumnCount () << " collumns in the result)\n";
|
||||||
// Bind an integer value "6" to the first parameter of the SQL query
|
// Bind an integer value "6" to the first parameter of the SQL query
|
||||||
query.bind(1, 6);
|
query.bind(1, 6);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user