Nebula
|
#include <sqlite3command.h>
SQLite3 implementation of Db::Command.
Inherits Db::Command.
Public Member Functions | |
Sqlite3Command () | |
constructor | |
virtual | ~Sqlite3Command () |
destructor | |
virtual bool | Compile (const Ptr< Database > &db, const Util::String &sqlCommand, ValueTable *resultTable=0) |
compile an SQL statement with optional placeholders | |
virtual bool | Execute () |
execute compiled command | |
virtual void | Clear () |
clear the current command | |
virtual bool | IsValid () const |
return true if command is compiled and ready for execution | |
virtual IndexT | IndexOf (const Util::String &name) const |
convert a parameter name into an integer index | |
virtual IndexT | IndexOf (const Attr::AttrId &attrId) const |
convert a parameter attribute id into an integer index | |
virtual void | BindInt (IndexT index, int val) |
bind an integer by placeholder index | |
virtual void | BindFloat (IndexT index, float val) |
bind a float by placeholder index | |
virtual void | BindBool (IndexT index, bool val) |
bind a bool by placeholder index | |
virtual void | BindVec4 (IndexT index, const Math::vec4 &val) |
bind a vec4 by placeholder index | |
virtual void | BindString (IndexT index, const Util::String &val) |
bind a string by placeholder index | |
virtual void | BindMat4 (IndexT index, const Math::mat4 &val) |
bind a Math::mat4 by placeholder index | |
virtual void | BindBlob (IndexT index, const Util::Blob &val) |
bind a blob by placeholder index | |
virtual void | BindGuid (IndexT index, const Util::Guid &val) |
bind a guid by placeholder index | |
virtual void | BindInt (const Util::String &name, int val) |
bind an integer by placeholder name | |
virtual void | BindFloat (const Util::String &name, float val) |
bind a float by placeholder name | |
virtual void | BindBool (const Util::String &name, bool val) |
bind a bool by placeholder name | |
virtual void | BindVec4 (const Util::String &name, const Math::vec4 &val) |
bind a vec4 by placeholder name | |
virtual void | BindString (const Util::String &name, const Util::String &val) |
bind a string by placeholder name | |
virtual void | BindMat4 (const Util::String &name, const Math::mat4 &val) |
bind a Math::mat4 by placeholder name | |
virtual void | BindBlob (const Util::String &name, const Util::Blob &val) |
bind a blob by placeholder name | |
virtual void | BindGuid (const Util::String &name, const Util::Guid &val) |
bind a guid by placeholder name | |
virtual void | BindInt (const Attr::AttrId &id, int val) |
bind an integer by placeholder attribute id | |
virtual void | BindFloat (const Attr::AttrId &id, float val) |
bind a float by placeholder attribute id | |
virtual void | BindBool (const Attr::AttrId &id, bool val) |
bind a bool by placeholder attribute id | |
virtual void | BindVec4 (const Attr::AttrId &id, const Math::vec4 &val) |
bind a float4 by placeholder attribute id | |
virtual void | BindString (const Attr::AttrId &id, const Util::String &val) |
bind a string by placeholder attribute id | |
virtual void | BindMat4 (const Attr::AttrId &id, const Math::mat4 &val) |
bind a Math::mat4 by placeholder attribute id | |
virtual void | BindBlob (const Attr::AttrId &id, const Util::Blob &val) |
bind a blob by placeholder attribute id | |
virtual void | BindGuid (const Attr::AttrId &id, const Util::Guid &val) |
bind a guid by placeholder attribute id | |
Public Member Functions inherited from Db::Command | |
Command () | |
constructor | |
virtual | ~Command () |
destructor | |
bool | CompileAndExecute (const Ptr< Database > &db, const Util::String &sqlCommand, ValueTable *resultTable=0) |
shortcut for simple SQL commands | |
const Util::String & | GetError () const |
get last error | |
const Ptr< Database > & | GetDatabase () const |
get back pointer to database | |
const Util::String & | GetSqlCommand () const |
get the last compiled SQL command | |
const Ptr< ValueTable > & | GetValueTable () const |
get the last set value table (can be 0!) | |
Public Member Functions inherited from Core::RefCounted | |
RefCounted () | |
constructor | |
int | GetRefCount () const |
get the current refcount | |
void | AddRef () |
increment refcount by one | |
void | Release () |
decrement refcount and destroy object if refcount is zero | |
bool | IsInstanceOf (const Rtti &rtti) const |
return true if this object is instance of given class | |
bool | IsInstanceOf (const Util::String &className) const |
return true if this object is instance of given class by string | |
bool | IsInstanceOf (const Util::FourCC &classFourCC) const |
return true if this object is instance of given class by fourcc | |
bool | IsA (const Rtti &rtti) const |
return true if this object is instance of given class, or a derived class | |
bool | IsA (const Util::String &rttiName) const |
return true if this object is instance of given class, or a derived class, by string | |
bool | IsA (const Util::FourCC &rttiFourCC) const |
return true if this object is instance of given class, or a derived class, by fourcc | |
const Util::String & | GetClassName () const |
get the class name | |
Util::FourCC | GetClassFourCC () const |
get the class FourCC code | |
Private Member Functions | |
__DeclareClass (Sqlite3Command) | |
void | SetSqliteError () |
set current error string to SQLite's error message | |
void | ReadRow () |
add a new row of results | |
Private Attributes | |
sqlite3_stmt * | sqliteStatement |
Util::Array< IndexT > | resultIndexMap |
Additional Inherited Members | |
Static Public Member Functions inherited from Core::RefCounted | |
static void | DumpRefCountingLeaks () |
dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!) | |
Protected Member Functions inherited from Db::Command | |
void | SetError (const Util::String &err) |
set error string | |
void | SetSqlCommand (const Util::String &cmd) |
set the SQL statement to exeute | |
Protected Member Functions inherited from Core::RefCounted | |
virtual | ~RefCounted () |
destructor (called when refcount reaches zero) | |
Protected Attributes inherited from Db::Command | |
Util::String | sqlCommand |
Util::String | error |
Ptr< Database > | database |
Ptr< ValueTable > | valueTable |
Db::Sqlite3Command::Sqlite3Command | ( | ) |
constructor
|
virtual |
destructor
|
private |
|
virtual |
bind a blob by placeholder attribute id
Implements Db::Command.
|
virtual |
bind a blob by placeholder name
Implements Db::Command.
|
virtual |
bind a blob by placeholder index
Bind a string value by placeholder index.
Either get the index from one of the IndexOf methods or use a 0-based index. index.
Implements Db::Command.
|
virtual |
bind a bool by placeholder attribute id
Implements Db::Command.
|
virtual |
bind a bool by placeholder name
Implements Db::Command.
|
virtual |
bind a bool by placeholder index
Bind a bool value by placeholder index.
Either get the index from one of the IndexOf methods or use a 0-based index.
Implements Db::Command.
|
virtual |
bind a float by placeholder attribute id
Implements Db::Command.
|
virtual |
bind a float by placeholder name
Implements Db::Command.
|
virtual |
bind a float by placeholder index
Bind a float value by placeholder index.
Either get the index from one of the IndexOf methods or use a 0-based index.
Implements Db::Command.
|
virtual |
bind a guid by placeholder attribute id
Implements Db::Command.
|
virtual |
bind a guid by placeholder name
Implements Db::Command.
|
virtual |
bind a guid by placeholder index
Bind a guid value by placeholder index.
Either get the index from one of the IndexOf methods or use a 0-based index. index.
Implements Db::Command.
|
virtual |
bind an integer by placeholder attribute id
Implements Db::Command.
|
virtual |
bind an integer by placeholder name
Implements Db::Command.
|
virtual |
bind an integer by placeholder index
Bind an integer value by placeholder index.
Either get the index from one of the IndexOf methods or use a 0-based index.
Implements Db::Command.
|
virtual |
bind a Math::mat4 by placeholder attribute id
Implements Db::Command.
|
virtual |
bind a Math::mat4 by placeholder name
Implements Db::Command.
|
virtual |
bind a Math::mat4 by placeholder index
Bind a Math::mat4 value by placeholder index.
Either get the index from one of the IndexOf methods or use a 0-based index.
Implements Db::Command.
|
virtual |
bind a string by placeholder attribute id
Implements Db::Command.
|
virtual |
bind a string by placeholder name
Implements Db::Command.
|
virtual |
bind a string by placeholder index
Bind a string value by placeholder index.
Either get the index from one of the IndexOf methods or use a 0-based index.. NOTE: the string should be in UTF-8 format.
Implements Db::Command.
|
virtual |
bind a float4 by placeholder attribute id
Implements Db::Command.
|
virtual |
bind a vec4 by placeholder name
Implements Db::Command.
|
virtual |
bind a vec4 by placeholder index
Bind a float4 value by placeholder index.
Either get the index from one of the IndexOf methods or use a 0-based index.
Implements Db::Command.
|
virtual |
|
virtual |
compile an SQL statement with optional placeholders
Compiles a command with optional placeholders.
Placeholders are identified by a leading $. After the command has been compiled, actual values can be bound to the placeholders using the Bind*() methods. When everything is in place, use Execute() to execute the command. If compilation fails, the method will return false. Get an error description with the method GetError().
Remember that the SQL statement string must be UTF-8 encoded!
Reimplemented from Db::Command.
|
virtual |
|
virtual |
convert a parameter attribute id into an integer index
Returns the index of a placeholder value by attribute id.
NOTE: this method is slow because a temporary string must be created! It's much faster to work with unnamed wildcards ("?") and set them directly by index!
Implements Db::Command.
|
virtual |
convert a parameter name into an integer index
Returns the index of a placeholder value by name.
The placeholder name must be UTF-8 encoded! NOTE: this method is slow because a temporary string must be created! It's much faster to work with unnamed wildcards ("?") and set them directly by index!
Implements Db::Command.
|
virtual |
return true if command is compiled and ready for execution
Returns true if the command has been compiled and is ready for execution, false if the command needs to be recompiled.
Implements Db::Command.
|
private |
add a new row of results
Gather row of result values from SQLite and add them to the result ValueTable.
Note that modification tracking is turned off in the value table, because reading from the database doesn't count as modification.
ptr = ByteOrder::ConvertFloat4(ByteOrder::LittleEndian, ByteOrder::Host, *ptr);
|
private |
set current error string to SQLite's error message
|
private |
|
private |