SQLiteC++
0.5.0
SQLiteC++ is a smart and easy to use C++ SQLite3 wrapper.
|
RAII encapsulation of a prepared SQLite Statement. More...
#include <Statement.h>
Classes | |
class | Ptr |
Shared pointer to the sqlite3_stmt SQLite Statement Object. More... | |
Public Member Functions | |
Statement (Database &aDatabase, const char *apQuery) | |
Compile and register the SQL query for the provided SQLite Database Connection. More... | |
virtual | ~Statement (void) throw () |
Finalize and unregister the SQL query from the SQLite Database Connection. More... | |
void | reset (void) |
Reset the statement to make it ready for a new execution. More... | |
void | bind (const int aIndex, const int &aValue) |
Bind an int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) More... | |
void | bind (const int aIndex, const sqlite3_int64 &aValue) |
Bind a 64bits int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) More... | |
void | bind (const int aIndex, const double &aValue) |
Bind a double (64bits float) value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) More... | |
void | bind (const int aIndex, const std::string &aValue) |
Bind a string value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) More... | |
void | bind (const int aIndex, const char *apValue) |
Bind a text value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) More... | |
void | bind (const int aIndex, const void *apValue, const int aSize) |
Bind a binary blob value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) More... | |
void | bind (const int aIndex) |
Bind a NULL value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) More... | |
void | bind (const char *apName, const int &aValue) |
Bind an int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) More... | |
void | bind (const char *apName, const sqlite3_int64 &aValue) |
Bind a 64bits int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) More... | |
void | bind (const char *apName, const double &aValue) |
Bind a double (64bits float) value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) More... | |
void | bind (const char *apName, const std::string &aValue) |
Bind a string value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) More... | |
void | bind (const char *apName, const char *apValue) |
Bind a text value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) More... | |
void | bind (const char *apName, const void *apValue, const int aSize) |
Bind a binary blob value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) More... | |
void | bind (const char *apName) |
Bind a NULL value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) More... | |
bool | executeStep (void) |
Execute a step of the prepared query to fetch one row of results. More... | |
int | exec (void) |
Execute a one-step query with no expected result. More... | |
Column | getColumn (const int aIndex) |
Return a copie of the column data specified by its index. More... | |
bool | isColumnNull (const int aIndex) const |
Test if the column value is NULL. More... | |
const std::string & | getQuery (void) const |
Return the UTF-8 SQL Query. More... | |
int | getColumnCount (void) const |
Return the number of columns in the result set returned by the prepared statement. More... | |
bool | isOk (void) const |
true when a row has been fetched with executeStep() More... | |
bool | isDone (void) const |
true when the last executeStep() had no more row to fetch More... | |
const char * | errmsg (void) const |
Return UTF-8 encoded English language explanation of the most recent error. More... | |
RAII encapsulation of a prepared SQLite Statement.
A Statement is a compiled SQL query ready to be executed step by step to provide results one row at a time.
Resource Acquisition Is Initialization (RAII) means that the Statement is compiled in the constructor and finalized in the destructor, so that there is no need to worry about memory management or the validity of the underlying SQLite Statement.
Definition at line 32 of file Statement.h.
SQLite::Statement::Statement | ( | Database & | aDatabase, |
const char * | apQuery | ||
) |
|
virtual |
Finalize and unregister the SQL query from the SQLite Database Connection.
Definition at line 30 of file Statement.cpp.
void SQLite::Statement::bind | ( | const int | aIndex, |
const int & | aValue | ||
) |
Bind an int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
Definition at line 45 of file Statement.cpp.
void SQLite::Statement::bind | ( | const int | aIndex, |
const sqlite3_int64 & | aValue | ||
) |
Bind a 64bits int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
Definition at line 52 of file Statement.cpp.
void SQLite::Statement::bind | ( | const int | aIndex, |
const double & | aValue | ||
) |
Bind a double (64bits float) value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
Definition at line 59 of file Statement.cpp.
void SQLite::Statement::bind | ( | const int | aIndex, |
const std::string & | aValue | ||
) |
Bind a string value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
Definition at line 66 of file Statement.cpp.
void SQLite::Statement::bind | ( | const int | aIndex, |
const char * | apValue | ||
) |
Bind a text value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
Definition at line 73 of file Statement.cpp.
void SQLite::Statement::bind | ( | const int | aIndex, |
const void * | apValue, | ||
const int | aSize | ||
) |
Bind a binary blob value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
Definition at line 80 of file Statement.cpp.
void SQLite::Statement::bind | ( | const int | aIndex | ) |
Bind a NULL value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
Definition at line 87 of file Statement.cpp.
void SQLite::Statement::bind | ( | const char * | apName, |
const int & | aValue | ||
) |
Bind an int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
Definition at line 95 of file Statement.cpp.
void SQLite::Statement::bind | ( | const char * | apName, |
const sqlite3_int64 & | aValue | ||
) |
Bind a 64bits int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
Definition at line 103 of file Statement.cpp.
void SQLite::Statement::bind | ( | const char * | apName, |
const double & | aValue | ||
) |
Bind a double (64bits float) value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
Definition at line 111 of file Statement.cpp.
void SQLite::Statement::bind | ( | const char * | apName, |
const std::string & | aValue | ||
) |
Bind a string value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
Definition at line 119 of file Statement.cpp.
void SQLite::Statement::bind | ( | const char * | apName, |
const char * | apValue | ||
) |
Bind a text value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
Definition at line 127 of file Statement.cpp.
void SQLite::Statement::bind | ( | const char * | apName, |
const void * | apValue, | ||
const int | aSize | ||
) |
Bind a binary blob value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
Definition at line 135 of file Statement.cpp.
void SQLite::Statement::bind | ( | const char * | apName | ) |
Bind a NULL value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
Definition at line 143 of file Statement.cpp.
|
inline |
Return UTF-8 encoded English language explanation of the most recent error.
Definition at line 245 of file Statement.h.
int SQLite::Statement::exec | ( | void | ) |
Execute a one-step query with no expected result.
This method is useful for any kind of statements other than the Data Query Language (DQL) "SELECT" :
It is similar to Database::exec(), but using a precompiled statement, it adds :
SQLite::Exception | in case of error, or if row of results are returned ! |
Definition at line 182 of file Statement.cpp.
bool SQLite::Statement::executeStep | ( | void | ) |
Execute a step of the prepared query to fetch one row of results.
While true is returned, a row of results is available, and can be accessed thru the getColumn() method
SQLite::Exception | in case of error |
Definition at line 152 of file Statement.cpp.
Column SQLite::Statement::getColumn | ( | const int | aIndex | ) |
Return a copie of the column data specified by its index.
Can be used to access the data of the current row of result when applicable, while the executeStep() method returns true.
Throw an exception if there is no row to return a Column from :
after a reset() call
Throw an exception if the specified index is out of the [0, getColumnCount()) range.
[in] | aIndex | Index of the column, starting at 0 |
Definition at line 216 of file Statement.cpp.
|
inline |
Return the number of columns in the result set returned by the prepared statement.
Definition at line 230 of file Statement.h.
|
inline |
Return the UTF-8 SQL Query.
Definition at line 225 of file Statement.h.
bool SQLite::Statement::isColumnNull | ( | const int | aIndex | ) | const |
Test if the column value is NULL.
[in] | aIndex | Index of the column, starting at 0 |
Definition at line 232 of file Statement.cpp.
|
inline |
true when the last executeStep() had no more row to fetch
Definition at line 240 of file Statement.h.
|
inline |
true when a row has been fetched with executeStep()
Definition at line 235 of file Statement.h.
void SQLite::Statement::reset | ( | void | ) |
Reset the statement to make it ready for a new execution.
Definition at line 36 of file Statement.cpp.