3 v8::Persistent<v8::FunctionTemplate> nodejs_db_informix::Informix::constructorTemplate;
5 nodejs_db_informix::Informix::Informix(): nodejs_db::Binding() {
7 assert(this->connection);
12 nodejs_db_informix::Informix::~Informix() {
13 if (this->connection != NULL) {
14 delete this->connection;
20 void nodejs_db_informix::Informix::Init(v8::Handle<v8::Object> exports) {
21 v8::HandleScope scope;
23 v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
25 constructorTemplate = v8::Persistent<v8::FunctionTemplate>::New(t);
26 constructorTemplate->InstanceTemplate()->SetInternalFieldCount(1);
28 nodejs_db::Binding::Init(exports, constructorTemplate);
30 exports->Set(v8::String::NewSymbol(
"Informix")
31 , constructorTemplate->GetFunction());
37 nodejs_db_informix::Informix::New(
const v8::Arguments& args) {
38 v8::HandleScope scope;
41 if (binding == NULL) {
42 THROW_EXCEPTION(
"Can't create client object")
45 if (args.Length() > 0) {
46 ARG_CHECK_OBJECT(0, options);
48 v8::Handle<v8::Value>
set = binding->set(args[0]->ToObject());
50 return scope.Close(
set);
54 binding->Wrap(args.This());
56 return scope.Close(args.This());
62 nodejs_db_informix::Informix::set(
63 const v8::Local<v8::Object> options
65 ARG_CHECK_OBJECT_ATTR_OPTIONAL_STRING(options, hostname);
66 ARG_CHECK_OBJECT_ATTR_OPTIONAL_STRING(options, user);
67 ARG_CHECK_OBJECT_ATTR_OPTIONAL_STRING(options, password);
68 ARG_CHECK_OBJECT_ATTR_OPTIONAL_STRING(options, database);
69 ARG_CHECK_OBJECT_ATTR_OPTIONAL_UINT32(options, port);
70 ARG_CHECK_OBJECT_ATTR_OPTIONAL_STRING(options, charset);
71 ARG_CHECK_OBJECT_ATTR_OPTIONAL_BOOL(options, compress);
72 ARG_CHECK_OBJECT_ATTR_OPTIONAL_STRING(options, initCommand);
73 ARG_CHECK_OBJECT_ATTR_OPTIONAL_UINT32(options, readTimeout);
74 ARG_CHECK_OBJECT_ATTR_OPTIONAL_BOOL(options, reconnect);
75 ARG_CHECK_OBJECT_ATTR_OPTIONAL_STRING(options, socket);
76 ARG_CHECK_OBJECT_ATTR_OPTIONAL_BOOL(options, sslVerifyServer);
77 ARG_CHECK_OBJECT_ATTR_OPTIONAL_UINT32(options, timeout);
78 ARG_CHECK_OBJECT_ATTR_OPTIONAL_UINT32(options, writeTimeout);
84 v8::String::Utf8Value hostname(options->Get(hostname_key)->ToString());
85 v8::String::Utf8Value user(options->Get(user_key)->ToString());
86 v8::String::Utf8Value password(options->Get(password_key)->ToString());
87 v8::String::Utf8Value database(options->Get(database_key)->ToString());
89 if (options->Has(hostname_key)) {
90 c->setHostname(*hostname);
93 if (options->Has(user_key)) {
97 if (options->Has(password_key)) {
98 c->setPassword(*password);
101 if (options->Has(database_key)) {
102 c->setDatabase(*database);
105 if (options->Has(port_key)) {
106 c->setPort(options->Get(port_key)->ToUint32()->Value());
109 if (options->Has(charset_key)) {
110 v8::String::Utf8Value charset(options->Get(charset_key)->ToString());
111 c->setCharset(*charset);
114 if (options->Has(compress_key)) {
115 c->setCompress(options->Get(compress_key)->IsTrue());
118 if (options->Has(initCommand_key)) {
119 v8::String::Utf8Value initCommand(options->Get(initCommand_key)->ToString());
120 c->setInitCommand(*initCommand);
123 if (options->Has(readTimeout_key)) {
124 c->setReadTimeout(options->Get(readTimeout_key)->ToUint32()->Value());
127 if (options->Has(reconnect_key)) {
128 c->setReconnect(options->Get(reconnect_key)->IsTrue());
131 if (options->Has(socket_key)) {
132 v8::String::Utf8Value socket(options->Get(socket_key)->ToString());
133 c->setSocket(*socket);
136 if (options->Has(sslVerifyServer_key)) {
137 c->setSslVerifyServer(options->Get(sslVerifyServer_key)->IsTrue());
140 if (options->Has(timeout_key)) {
141 c->setTimeout(options->Get(timeout_key)->ToUint32()->Value());
144 if (options->Has(writeTimeout_key)) {
145 c->setWriteTimeout(options->Get(writeTimeout_key)->ToUint32()->Value());
148 return v8::Handle<v8::Value>();
153 v8::Persistent<v8::Object>
154 nodejs_db_informix::Informix::createQuery()
156 v8::Persistent<v8::Object> query(
157 nodejs_db_informix::Query::constructorTemplate->GetFunction()->NewInstance());