Commit f89fa7e3 by Orlando Vazquez

Rename the Sqlite3Db class to Database, and move it to its own file

parent f7cb2ad2
......@@ -131,8 +131,8 @@ Ryan Dahl [ry@tinyclouds.org]
THANKS
------
Many thanks to Eric Fredricksen for his synchronous driver on which this was
based.
Many thanks to Eric Fredricksen for his synchronous driver on which this
driver was originally based.
* http://github.com/grumdrig/node-sqlite/
* http://grumdrig.com/node-sqlite/
......@@ -142,6 +142,4 @@ LICENSE
node-sqlite is BSD licensed.
(c) 2010 Eric Fredricksen
(c) 2010 Orlando Vazquez
......@@ -58,12 +58,4 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
return ThrowException(Exception::TypeError( \
String::New("Argument " #I " must be an integer"))); \
}
enum ExecMode
{
EXEC_EMPTY = 0,
EXEC_LAST_INSERT_ID = 1,
EXEC_AFFECTED_ROWS = 2
};
#endif
......@@ -25,62 +25,61 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
using namespace v8;
using namespace node;
class Statement : public EventEmitter {
public:
static Persistent<FunctionTemplate> constructor_template;
static void Init(v8::Handle<Object> target);
static Handle<Value> New(const Arguments& args);
static Persistent<FunctionTemplate> constructor_template;
static void Init(v8::Handle<Object> target);
static Handle<Value> New(const Arguments& args);
protected:
Statement(sqlite3_stmt* stmt, int first_rc = -1)
: EventEmitter(), first_rc_(first_rc), stmt_(stmt) {
column_count_ = -1;
column_types_ = NULL;
column_names_ = NULL;
column_data_ = NULL;
}
~Statement() {
if (stmt_) sqlite3_finalize(stmt_);
if (column_types_) free(column_types_);
if (column_names_) free(column_names_);
if (column_data_) FreeColumnData();
}
static int EIO_AfterBind(eio_req *req);
static int EIO_Bind(eio_req *req);
static Handle<Value> Bind(const Arguments& args);
static int EIO_AfterFinalize(eio_req *req);
static int EIO_Finalize(eio_req *req);
static Handle<Value> Finalize(const Arguments& args);
static Handle<Value> Reset(const Arguments& args);
static int EIO_AfterStep(eio_req *req);
static int EIO_Step(eio_req *req);
static Handle<Value> Step(const Arguments& args);
void FreeColumnData(void);
bool HasCallback();
void SetCallback(Local<Function> cb);
Local<Function> GetCallback();
Statement(sqlite3_stmt* stmt, int first_rc = -1)
: EventEmitter(), first_rc_(first_rc), stmt_(stmt) {
column_count_ = -1;
column_types_ = NULL;
column_names_ = NULL;
column_data_ = NULL;
}
~Statement() {
if (stmt_) sqlite3_finalize(stmt_);
if (column_types_) free(column_types_);
if (column_names_) free(column_names_);
if (column_data_) FreeColumnData();
}
static int EIO_AfterBind(eio_req *req);
static int EIO_Bind(eio_req *req);
static Handle<Value> Bind(const Arguments& args);
static int EIO_AfterFinalize(eio_req *req);
static int EIO_Finalize(eio_req *req);
static Handle<Value> Finalize(const Arguments& args);
static Handle<Value> Reset(const Arguments& args);
static int EIO_AfterStep(eio_req *req);
static int EIO_Step(eio_req *req);
static Handle<Value> Step(const Arguments& args);
void FreeColumnData(void);
bool HasCallback();
void SetCallback(Local<Function> cb);
Local<Function> GetCallback();
private:
int column_count_;
int *column_types_;
char **column_names_;
void **column_data_;
bool error_;
int first_rc_;
sqlite3_stmt* stmt_;
int column_count_;
int *column_types_;
char **column_names_;
void **column_data_;
bool error_;
int first_rc_;
sqlite3_stmt* stmt_;
};
// indicates the key type (integer index or name string)
......
......@@ -24,7 +24,7 @@ def build(bld):
obj = bld.new_task_gen("cxx", "shlib", "node_addon")
obj.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE", "-Wall"]
obj.target = "sqlite3_bindings"
obj.source = "src/sqlite3_bindings.cc src/statement.cc"
obj.source = "src/sqlite3_bindings.cc src/database.cc src/statement.cc"
obj.uselib = "SQLITE3 PROFILER"
t = 'sqlite3_bindings.node'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment