Nebula
Loading...
Searching...
No Matches
Db::Command Class Referenceabstract

#include <command.h>

Detailed Description

Wraps a general SQL command.

Commands may contain placeholders and can be precompiled for faster execution.

Inherits Core::RefCounted.

Inherited by Db::Sqlite3Command.

Public Member Functions

 Command ()
 constructor
 
virtual ~Command ()
 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 ()=0
 execute compiled command
 
bool CompileAndExecute (const Ptr< Database > &db, const Util::String &sqlCommand, ValueTable *resultTable=0)
 shortcut for simple SQL commands
 
virtual void Clear ()=0
 clear the current command
 
virtual bool IsValid () const =0
 return true if command is compiled and ready for execution
 
const Util::StringGetError () const
 get last error
 
const Ptr< Database > & GetDatabase () const
 get back pointer to database
 
const Util::StringGetSqlCommand () const
 get the last compiled SQL command
 
const Ptr< ValueTable > & GetValueTable () const
 get the last set value table (can be 0!)
 
virtual IndexT IndexOf (const Util::String &name) const =0
 convert a parameter name into an integer index
 
virtual IndexT IndexOf (const Attr::AttrId &attrId) const =0
 convert a parameter attribute id into an integer index
 
virtual void BindInt (IndexT index, int val)=0
 bind an integer by placeholder to 0-based index
 
virtual void BindFloat (IndexT index, float val)=0
 bind a float by placeholder index to 0-based index
 
virtual void BindBool (IndexT index, bool val)=0
 bind a bool by placeholder index 0-based index
 
virtual void BindVec4 (IndexT index, const Math::vec4 &val)=0
 bind a vec4 by placeholder index 0-based index
 
virtual void BindString (IndexT index, const Util::String &val)=0
 bind a string by placeholder index 0-based index
 
virtual void BindMat4 (IndexT index, const Math::mat4 &val)=0
 bind a mat4 by placeholder index 0-based index
 
virtual void BindBlob (IndexT index, const Util::Blob &val)=0
 bind a blob by placeholder index 0-based index
 
virtual void BindGuid (IndexT index, const Util::Guid &val)=0
 bind a guid by placeholder index 0-based index
 
virtual void BindInt (const Util::String &name, int val)=0
 bind an integer by placeholder name
 
virtual void BindFloat (const Util::String &name, float val)=0
 bind a float by placeholder name
 
virtual void BindBool (const Util::String &name, bool val)=0
 bind a bool by placeholder name
 
virtual void BindVec4 (const Util::String &name, const Math::vec4 &val)=0
 bind a vec4 by placeholder name
 
virtual void BindString (const Util::String &name, const Util::String &val)=0
 bind a string by placeholder name
 
virtual void BindMat4 (const Util::String &name, const Math::mat4 &val)=0
 bind a mat4 by placeholder name
 
virtual void BindBlob (const Util::String &name, const Util::Blob &val)=0
 bind a blob by placeholder name
 
virtual void BindGuid (const Util::String &name, const Util::Guid &val)=0
 bind a guid by placeholder name
 
virtual void BindInt (const Attr::AttrId &id, int val)=0
 bind an integer by placeholder attribute id
 
virtual void BindFloat (const Attr::AttrId &id, float val)=0
 bind a float by placeholder attribute id
 
virtual void BindBool (const Attr::AttrId &id, bool val)=0
 bind a bool by placeholder attribute id
 
virtual void BindVec4 (const Attr::AttrId &id, const Math::vec4 &val)=0
 bind a vec4 by placeholder attribute id
 
virtual void BindString (const Attr::AttrId &id, const Util::String &val)=0
 bind a string by placeholder attribute id
 
virtual void BindMat4 (const Attr::AttrId &id, const Math::mat4 &val)=0
 bind a mat4 by placeholder attribute id
 
virtual void BindBlob (const Attr::AttrId &id, const Util::Blob &val)=0
 bind a blob by placeholder attribute id
 
virtual void BindGuid (const Attr::AttrId &id, const Util::Guid &val)=0
 bind a guid by placeholder attribute id
 
- 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::StringGetClassName () const
 get the class name
 
Util::FourCC GetClassFourCC () const
 get the class FourCC code
 

Protected Member Functions

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

Util::String sqlCommand
 
Util::String error
 
Ptr< Databasedatabase
 
Ptr< ValueTablevalueTable
 

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!)
 

Constructor & Destructor Documentation

◆ Command()

Db::Command::Command ( )

constructor

◆ ~Command()

Db::Command::~Command ( )
virtual

destructor

Member Function Documentation

◆ BindBlob() [1/3]

virtual void Db::Command::BindBlob ( const Attr::AttrId & id,
const Util::Blob & val )
pure virtual

bind a blob by placeholder attribute id

Implemented in Db::Sqlite3Command.

◆ BindBlob() [2/3]

virtual void Db::Command::BindBlob ( const Util::String & name,
const Util::Blob & val )
pure virtual

bind a blob by placeholder name

Implemented in Db::Sqlite3Command.

◆ BindBlob() [3/3]

virtual void Db::Command::BindBlob ( IndexT index,
const Util::Blob & val )
pure virtual

bind a blob by placeholder index 0-based index

Implemented in Db::Sqlite3Command.

◆ BindBool() [1/3]

virtual void Db::Command::BindBool ( const Attr::AttrId & id,
bool val )
pure virtual

bind a bool by placeholder attribute id

Implemented in Db::Sqlite3Command.

◆ BindBool() [2/3]

virtual void Db::Command::BindBool ( const Util::String & name,
bool val )
pure virtual

bind a bool by placeholder name

Implemented in Db::Sqlite3Command.

◆ BindBool() [3/3]

virtual void Db::Command::BindBool ( IndexT index,
bool val )
pure virtual

bind a bool by placeholder index 0-based index

Implemented in Db::Sqlite3Command.

◆ BindFloat() [1/3]

virtual void Db::Command::BindFloat ( const Attr::AttrId & id,
float val )
pure virtual

bind a float by placeholder attribute id

Implemented in Db::Sqlite3Command.

◆ BindFloat() [2/3]

virtual void Db::Command::BindFloat ( const Util::String & name,
float val )
pure virtual

bind a float by placeholder name

Implemented in Db::Sqlite3Command.

◆ BindFloat() [3/3]

virtual void Db::Command::BindFloat ( IndexT index,
float val )
pure virtual

bind a float by placeholder index to 0-based index

Implemented in Db::Sqlite3Command.

◆ BindGuid() [1/3]

virtual void Db::Command::BindGuid ( const Attr::AttrId & id,
const Util::Guid & val )
pure virtual

bind a guid by placeholder attribute id

Implemented in Db::Sqlite3Command.

◆ BindGuid() [2/3]

virtual void Db::Command::BindGuid ( const Util::String & name,
const Util::Guid & val )
pure virtual

bind a guid by placeholder name

Implemented in Db::Sqlite3Command.

◆ BindGuid() [3/3]

virtual void Db::Command::BindGuid ( IndexT index,
const Util::Guid & val )
pure virtual

bind a guid by placeholder index 0-based index

Implemented in Db::Sqlite3Command.

◆ BindInt() [1/3]

virtual void Db::Command::BindInt ( const Attr::AttrId & id,
int val )
pure virtual

bind an integer by placeholder attribute id

Implemented in Db::Sqlite3Command.

◆ BindInt() [2/3]

virtual void Db::Command::BindInt ( const Util::String & name,
int val )
pure virtual

bind an integer by placeholder name

Implemented in Db::Sqlite3Command.

◆ BindInt() [3/3]

virtual void Db::Command::BindInt ( IndexT index,
int val )
pure virtual

bind an integer by placeholder to 0-based index

Implemented in Db::Sqlite3Command.

◆ BindMat4() [1/3]

virtual void Db::Command::BindMat4 ( const Attr::AttrId & id,
const Math::mat4 & val )
pure virtual

bind a mat4 by placeholder attribute id

Implemented in Db::Sqlite3Command.

◆ BindMat4() [2/3]

virtual void Db::Command::BindMat4 ( const Util::String & name,
const Math::mat4 & val )
pure virtual

bind a mat4 by placeholder name

Implemented in Db::Sqlite3Command.

◆ BindMat4() [3/3]

virtual void Db::Command::BindMat4 ( IndexT index,
const Math::mat4 & val )
pure virtual

bind a mat4 by placeholder index 0-based index

Implemented in Db::Sqlite3Command.

◆ BindString() [1/3]

virtual void Db::Command::BindString ( const Attr::AttrId & id,
const Util::String & val )
pure virtual

bind a string by placeholder attribute id

Implemented in Db::Sqlite3Command.

◆ BindString() [2/3]

virtual void Db::Command::BindString ( const Util::String & name,
const Util::String & val )
pure virtual

bind a string by placeholder name

Implemented in Db::Sqlite3Command.

◆ BindString() [3/3]

virtual void Db::Command::BindString ( IndexT index,
const Util::String & val )
pure virtual

bind a string by placeholder index 0-based index

Implemented in Db::Sqlite3Command.

◆ BindVec4() [1/3]

virtual void Db::Command::BindVec4 ( const Attr::AttrId & id,
const Math::vec4 & val )
pure virtual

bind a vec4 by placeholder attribute id

Implemented in Db::Sqlite3Command.

◆ BindVec4() [2/3]

virtual void Db::Command::BindVec4 ( const Util::String & name,
const Math::vec4 & val )
pure virtual

bind a vec4 by placeholder name

Implemented in Db::Sqlite3Command.

◆ BindVec4() [3/3]

virtual void Db::Command::BindVec4 ( IndexT index,
const Math::vec4 & val )
pure virtual

bind a vec4 by placeholder index 0-based index

Implemented in Db::Sqlite3Command.

◆ Clear()

virtual void Db::Command::Clear ( )
pure virtual

clear the current command

Implemented in Db::Sqlite3Command.

◆ Compile()

bool Db::Command::Compile ( const Ptr< Database > & db,
const Util::String & cmd,
ValueTable * resultTable = 0 )
virtual

compile an SQL statement with optional placeholders

This compiles an SQL statement against the provided database.

The SQL statement may contain placeholders which should be filled with values using the various BindXXX() methods. After values have been bound, the statement can be executed using the Execute() method.

Reimplemented in Db::Sqlite3Command.

◆ CompileAndExecute()

bool Db::Command::CompileAndExecute ( const Ptr< Database > & db,
const Util::String & cmd,
ValueTable * resultTable = 0 )

shortcut for simple SQL commands

This is a simple helper method which compiles and executes a simple SQL command in one step.

This is only recommended for simple commands which are not executed repaetedly and don't take any parameters.

◆ Execute()

virtual bool Db::Command::Execute ( )
pure virtual

execute compiled command

Implemented in Db::Sqlite3Command.

◆ GetDatabase()

const Ptr< Database > & Db::Command::GetDatabase ( ) const
inline

get back pointer to database

◆ GetError()

const Util::String & Db::Command::GetError ( ) const
inline

get last error

◆ GetSqlCommand()

const Util::String & Db::Command::GetSqlCommand ( ) const
inline

get the last compiled SQL command

◆ GetValueTable()

const Ptr< ValueTable > & Db::Command::GetValueTable ( ) const
inline

get the last set value table (can be 0!)

◆ IndexOf() [1/2]

virtual IndexT Db::Command::IndexOf ( const Attr::AttrId & attrId) const
pure virtual

convert a parameter attribute id into an integer index

Implemented in Db::Sqlite3Command.

◆ IndexOf() [2/2]

virtual IndexT Db::Command::IndexOf ( const Util::String & name) const
pure virtual

convert a parameter name into an integer index

Implemented in Db::Sqlite3Command.

◆ IsValid()

virtual bool Db::Command::IsValid ( ) const
pure virtual

return true if command is compiled and ready for execution

Implemented in Db::Sqlite3Command.

◆ SetError()

void Db::Command::SetError ( const Util::String & err)
inlineprotected

set error string

◆ SetSqlCommand()

void Db::Command::SetSqlCommand ( const Util::String & cmd)
inlineprotected

set the SQL statement to exeute

Member Data Documentation

◆ database

Ptr<Database> Db::Command::database
protected

◆ error

Util::String Db::Command::error
protected

◆ sqlCommand

Util::String Db::Command::sqlCommand
protected

◆ valueTable

Ptr<ValueTable> Db::Command::valueTable
protected

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