Nebula
Loading...
Searching...
No Matches
sqlite3command.h
Go to the documentation of this file.
1#pragma once
2#ifndef DB_SQLITE3COMMAND_H
3#define DB_SQLITE3COMMAND_H
4//------------------------------------------------------------------------------
14#include "db/command.h"
15#include "sqlite3.h"
16
17//------------------------------------------------------------------------------
18namespace Db
19{
20class Sqlite3Command : public Command
21{
23public:
27 virtual ~Sqlite3Command();
28
30 virtual bool Compile(const Ptr<Database>& db, const Util::String& sqlCommand, ValueTable* resultTable=0);
32 virtual bool Execute();
34 virtual void Clear();
36 virtual bool IsValid() const;
37
39 virtual IndexT IndexOf(const Util::String& name) const;
41 virtual IndexT IndexOf(const Attr::AttrId& attrId) const;
42
44 virtual void BindInt(IndexT index, int val);
46 virtual void BindFloat(IndexT index, float val);
48 virtual void BindBool(IndexT index, bool val);
50 virtual void BindVec4(IndexT index, const Math::vec4& val);
52 virtual void BindString(IndexT index, const Util::String& val);
54 virtual void BindMat4(IndexT index, const Math::mat4& val);
56 virtual void BindBlob(IndexT index, const Util::Blob& val);
58 virtual void BindGuid(IndexT index, const Util::Guid& val);
59
61 virtual void BindInt(const Util::String& name, int val);
63 virtual void BindFloat(const Util::String& name, float val);
65 virtual void BindBool(const Util::String& name, bool val);
67 virtual void BindVec4(const Util::String& name, const Math::vec4& val);
69 virtual void BindString(const Util::String& name, const Util::String& val);
71 virtual void BindMat4(const Util::String& name, const Math::mat4& val);
73 virtual void BindBlob(const Util::String& name, const Util::Blob& val);
75 virtual void BindGuid(const Util::String& name, const Util::Guid& val);
76
78 virtual void BindInt(const Attr::AttrId& id, int val);
80 virtual void BindFloat(const Attr::AttrId& id, float val);
82 virtual void BindBool(const Attr::AttrId& id, bool val);
84 virtual void BindVec4(const Attr::AttrId& id, const Math::vec4& val);
86 virtual void BindString(const Attr::AttrId& id, const Util::String& val);
88 virtual void BindMat4(const Attr::AttrId& id, const Math::mat4& val);
90 virtual void BindBlob(const Attr::AttrId& id, const Util::Blob& val);
92 virtual void BindGuid(const Attr::AttrId& id, const Util::Guid& val);
93
94private:
96 void SetSqliteError();
98 void ReadRow();
99
100 sqlite3_stmt* sqliteStatement;
102};
103
104} // namespace Db
105//------------------------------------------------------------------------------
106#endif
107
An attribute ID is used to carry attribute types (no values) around.
Definition attrid.h:20
Wraps a general SQL command.
Definition command.h:26
Util::String sqlCommand
Definition command.h:115
SQLite3 implementation of Db::Command.
Definition sqlite3command.h:21
virtual void BindInt(IndexT index, int val)
bind an integer by placeholder index
Definition sqlite3command.cc:426
__DeclareClass(Sqlite3Command)
Sqlite3Command()
constructor
Definition sqlite3command.cc:22
Util::Array< IndexT > resultIndexMap
Definition sqlite3command.h:101
virtual void BindFloat(IndexT index, float val)
bind a float by placeholder index
Definition sqlite3command.cc:439
virtual void BindVec4(IndexT index, const Math::vec4 &val)
bind a vec4 by placeholder index
Definition sqlite3command.cc:468
virtual bool IsValid() const
return true if command is compiled and ready for execution
Definition sqlite3command.cc:153
virtual void BindString(IndexT index, const Util::String &val)
bind a string by placeholder index
Definition sqlite3command.cc:505
virtual void BindGuid(IndexT index, const Util::Guid &val)
bind a guid by placeholder index
Definition sqlite3command.cc:535
virtual void BindBlob(IndexT index, const Util::Blob &val)
bind a blob by placeholder index
Definition sqlite3command.cc:518
virtual void Clear()
clear the current command
Definition sqlite3command.cc:41
virtual void BindBool(IndexT index, bool val)
bind a bool by placeholder index
Definition sqlite3command.cc:452
virtual bool Compile(const Ptr< Database > &db, const Util::String &sqlCommand, ValueTable *resultTable=0)
compile an SQL statement with optional placeholders
Definition sqlite3command.cc:77
virtual void BindMat4(IndexT index, const Math::mat4 &val)
bind a Math::mat4 by placeholder index
Definition sqlite3command.cc:486
void ReadRow()
add a new row of results
Definition sqlite3command.cc:243
void SetSqliteError()
set current error string to SQLite's error message
Definition sqlite3command.cc:56
virtual ~Sqlite3Command()
destructor
Definition sqlite3command.cc:31
sqlite3_stmt * sqliteStatement
Definition sqlite3command.h:100
virtual IndexT IndexOf(const Util::String &name) const
convert a parameter name into an integer index
Definition sqlite3command.cc:384
virtual bool Execute()
execute compiled command
Definition sqlite3command.cc:173
A table of database values.
Definition valuetable.h:23
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition ptr.h:38
Nebula's dynamic array class.
Definition array.h:60
The Util::Blob class encapsulates a chunk of raw memory into a C++ object which can be copied,...
Definition blob.h:22
Implements a GUID.
Definition column.cc:10
A 4x4 single point precision float matrix.
Definition mat4.h:49
A 4D vector.
Definition vec4.h:24
Nebula's universal string class.
Definition string.h:50
int IndexT
Definition types.h:48