#include <sqlite3x.hpp>
Public Member Functions | |
sqlite3_cursor (sqlite3_command &cmd) | |
Creates a cursor by calling cmd->executecursor(). | |
sqlite3_cursor () | |
Creates an empty cursor object, suitable only for use as the target of a copy/assignment. | |
sqlite3_cursor (const sqlite3_cursor ©) | |
Copies the given cursor object. | |
~sqlite3_cursor () | |
Closes this cursor, freeing up db resources if this is the last cursor of a copied set. | |
sqlite3_cursor & | operator= (const sqlite3_cursor ©) |
Copies the given cursor object. | |
bool | step () |
Steps one step through the sql result set and returns true on SQLITE_ROW, false on SQLITE3_DONE, and throws on any other result. | |
void | reset () |
Resets the underlying prepared statement of this cursor. | |
void | close () |
Closes this cursor. | |
int | colcount () |
Returns the column count of the result set or throws on error. | |
bool | isnull (int index) |
Check if the given field number is NULL. | |
int | getint (int index) |
Gets the integer value at the given field number. | |
int64_t | getint64 (int index) |
Gets the (int64_t) value at the given field number. | |
double | getdouble (int index) |
Gets the double value at the given field number. | |
std::string | getstring (int index) |
Gets the string value at the given field number. | |
char const * | getstring (int index, int &size) |
Like getstring(index), but returns a C-style string. | |
std::string | getblob (int index) |
Gets the blob value at the given field number. | |
void const * | getblob (int index, int &size) |
Overloaded to avoid an internal copy of the blob data. | |
std::string | getcolname (int index) |
Gets the column name for the given column index. | |
Friends | |
class | sqlite3_command |
Definition at line 458 of file sqlite3x.hpp.
sqlite3x::sqlite3_cursor::sqlite3_cursor | ( | const sqlite3_cursor & | copy | ) |
Copies the given cursor object.
This is a fairly efficient operation, using reference counting.
Definition at line 29 of file sqlite3x_cursor.cpp.
References sqlite3x::sqlite3_command::refs.
void sqlite3x::sqlite3_cursor::close | ( | ) |
Closes this cursor.
Calling it multiple times is a no-op on the second and subsequent calls.
Definition at line 81 of file sqlite3x_cursor.cpp.
References sqlite3x::sqlite3_command::refs, and sqlite3x::sqlite3_command::stmt.
Referenced by operator=(), and ~sqlite3_cursor().
void const * sqlite3x::sqlite3_cursor::getblob | ( | int | index, | |
int & | size | |||
) |
Overloaded to avoid an internal copy of the blob data.
size is set to the number of bytes in the blob and the returned pointer is the blob.
Definition at line 135 of file sqlite3x_cursor.cpp.
References sqlite3x::sqlite3_command::stmt.
std::string sqlite3x::sqlite3_cursor::getcolname | ( | int | index | ) |
Gets the column name for the given column index.
Throws on error.
Definition at line 141 of file sqlite3x_cursor.cpp.
References sqlite3x::sqlite3_command::stmt.
char const * sqlite3x::sqlite3_cursor::getstring | ( | int | index, | |
int & | size | |||
) |
Like getstring(index), but returns a C-style string.
We hope it is null-terminated, but the sqlite3 docs are ambiguous on this point. size is set to the length of the returned string.
The advantage of this over getstring(index) is that this version avoids a potential extra internal copy of the string. Note that there is no guaranty how long this pointer will remain valid - be sure to copy the string if you need it.
Definition at line 117 of file sqlite3x_cursor.cpp.
References sqlite3x::sqlite3_command::stmt.
bool sqlite3x::sqlite3_cursor::isnull | ( | int | index | ) |
Check if the given field number is NULL.
This function returns true if is NULL, else false.
Definition at line 92 of file sqlite3x_cursor.cpp.
References sqlite3x::sqlite3_command::stmt.
sqlite3_cursor & sqlite3x::sqlite3_cursor::operator= | ( | const sqlite3_cursor & | copy | ) |
Copies the given cursor object.
This is a fairly efficient operation, using reference counting. This object points to the same underlying result set as the original, so both objects should not be used.
Definition at line 41 of file sqlite3x_cursor.cpp.
References close(), cmd, and sqlite3x::sqlite3_command::refs.
void sqlite3x::sqlite3_cursor::reset | ( | ) |
Resets the underlying prepared statement of this cursor.
Throws on error.
Definition at line 72 of file sqlite3x_cursor.cpp.
References sqlite3x::sqlite3_command::con, sqlite3x::sqlite3_connection::errormsg(), and sqlite3x::sqlite3_command::reset().