libsqlite3x 2007.10.18
sqlite3x::sqlite3_cursor Class Reference

A type for reading results from an sqlite3_command. More...

#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 &copy)
 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_cursoroperator= (const sqlite3_cursor &copy)
 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
 

Detailed Description

A type for reading results from an sqlite3_command.

Definition at line 458 of file sqlite3x.hpp.

Constructor & Destructor Documentation

◆ sqlite3_cursor() [1/3]

sqlite3x::sqlite3_cursor::sqlite3_cursor ( sqlite3_command & cmd)

Creates a cursor by calling cmd->executecursor().

Definition at line 33 of file sqlite3x_cursor.cpp.

◆ sqlite3_cursor() [2/3]

sqlite3x::sqlite3_cursor::sqlite3_cursor ( )

Creates an empty cursor object, suitable only for use as the target of a copy/assignment.

Definition at line 27 of file sqlite3x_cursor.cpp.

◆ sqlite3_cursor() [3/3]

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.

◆ ~sqlite3_cursor()

sqlite3x::sqlite3_cursor::~sqlite3_cursor ( )

Closes this cursor, freeing up db resources if this is the last cursor of a copied set.

Definition at line 37 of file sqlite3x_cursor.cpp.

References close().

Member Function Documentation

◆ close()

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.

Referenced by operator=(), and ~sqlite3_cursor().

◆ colcount()

int sqlite3x::sqlite3_cursor::colcount ( )

Returns the column count of the result set or throws on error.

Definition at line 50 of file sqlite3x_cursor.cpp.

References sqlite3x::sqlite3_command::colcount().

◆ getblob() [1/2]

std::string sqlite3x::sqlite3_cursor::getblob ( int index)

Gets the blob value at the given field number.

Definition at line 130 of file sqlite3x_cursor.cpp.

Referenced by sqlite3x::sqlite3_command::executeblob(), and sqlite3x::sqlite3_command::executeblob().

◆ getblob() [2/2]

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.

◆ getcolname()

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.

◆ getdouble()

double sqlite3x::sqlite3_cursor::getdouble ( int index)

Gets the double value at the given field number.

Definition at line 107 of file sqlite3x_cursor.cpp.

References getdouble().

Referenced by sqlite3x::sqlite3_command::executedouble(), and getdouble().

◆ getint()

int sqlite3x::sqlite3_cursor::getint ( int index)

Gets the integer value at the given field number.

Definition at line 97 of file sqlite3x_cursor.cpp.

References getint().

Referenced by sqlite3x::sqlite3_command::executeint(), and getint().

◆ getint64()

int64_t sqlite3x::sqlite3_cursor::getint64 ( int index)

Gets the (int64_t) value at the given field number.

Definition at line 102 of file sqlite3x_cursor.cpp.

References getint64().

Referenced by sqlite3x::sqlite3_command::executeint64(), and getint64().

◆ getstring() [1/2]

std::string sqlite3x::sqlite3_cursor::getstring ( int index)

Gets the string value at the given field number.

Definition at line 112 of file sqlite3x_cursor.cpp.

Referenced by sqlite3x::sqlite3_command::executestring(), and sqlite3x::sqlite3_command::executestring().

◆ getstring() [2/2]

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.

◆ isnull()

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 isnull().

Referenced by isnull().

◆ operator=()

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().

◆ reset()

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_connection::errormsg(), and sqlite3x::sqlite3_command::reset().

◆ step()

bool sqlite3x::sqlite3_cursor::step ( )

Friends And Related Symbol Documentation

◆ sqlite3_command

friend class sqlite3_command
friend

Definition at line 460 of file sqlite3x.hpp.


The documentation for this class was generated from the following files: