|
|
| <prev next> |
Choosing A Webhost: |
CVS update of odbsequoia/src (env.cpp env.hpp explicit_type.cpp): msg#00184db.carob.cvs
Date: Thursday, March 30, 2006 @ 23:03:19 Author: marc Path: /cvsroot/carob/odbsequoia/src Modified: env.cpp (1.11 -> 1.12) env.hpp (1.6 -> 1.7) explicit_type.cpp (1.8 -> 1.9) Extracted ODBCEnv::init() from ODBCEnv ctor, so to implement a skeletal handle and being able to report construction errors to it. -------------------+ env.cpp | 17 +++++++++++++---- env.hpp | 12 ++++++++++-- explicit_type.cpp | 17 ++++++++++------- 3 files changed, 33 insertions(+), 13 deletions(-) Index: odbsequoia/src/env.cpp diff -u odbsequoia/src/env.cpp:1.11 odbsequoia/src/env.cpp:1.12 --- odbsequoia/src/env.cpp:1.11 Thu Mar 30 21:23:52 2006 +++ odbsequoia/src/env.cpp Thu Mar 30 23:03:19 2006 @@ -35,17 +35,21 @@ using namespace ODBSeqNS; -ODBCEnv::ODBCEnv() : ODBCItem(*this) // I have no father +SQLRETURN +ODBCEnv::init() { + SQLRETURN ret = SQL_SUCCESS; + #define MAX_VALUE_LEN 30 char temp[MAX_VALUE_LEN]; + // Behaviour of SQLGetPrivateProfileString is complex and weird, + // check comments in inst.hpp + /* Fake ODBC version 2 */ if (0 > SQLGetPrivateProfileString(MYDRIVER_NAME_INST_INI, FAKEODBC2_INST_INI, "true", temp, MAX_VALUE_LEN, ODBCINST_INI)) - // FIXME: catch above & return diags - // Problem: how to return diags without any object? - // But how could this fail anyway? + // How could this fail anyway? throw ODBSeqException(L"TODO", L"Invalid " WIDENMACRO(FAKEODBC2_INST_INI) L" value"); @@ -53,6 +57,11 @@ fake_version2 = false; else fake_version2 = true; + + + isInitialized = true; + + return ret; } namespace { Index: odbsequoia/src/env.hpp diff -u odbsequoia/src/env.hpp:1.6 odbsequoia/src/env.hpp:1.7 --- odbsequoia/src/env.hpp:1.6 Thu Mar 30 21:23:52 2006 +++ odbsequoia/src/env.hpp Thu Mar 30 23:03:19 2006 @@ -35,14 +35,22 @@ class ODBCEnv : public ODBCItem { public: - ODBCEnv(); + ODBCEnv::ODBCEnv() + : ODBCItem(*this), // I have no father + isInitialized(false) + { } + // we need a two-phase ctor, so we have an skeletal handle to + // report errors to. + SQLRETURN + init(); + SQLRETURN ODBCEnv::AllocConnect(SQLHANDLE * OutputHandle); SQLRETURN ODBCEnv::set_env_attr(SQLINTEGER attribute, SQLPOINTER value, SQLINTEGER str_len); - bool fake_version2; + bool isInitialized, fake_version2; }; } Index: odbsequoia/src/explicit_type.cpp diff -u odbsequoia/src/explicit_type.cpp:1.8 odbsequoia/src/explicit_type.cpp:1.9 --- odbsequoia/src/explicit_type.cpp:1.8 Mon Mar 27 13:06:35 2006 +++ odbsequoia/src/explicit_type.cpp Thu Mar 30 23:03:19 2006 @@ -63,17 +63,20 @@ switch (HandleType) { - case SQL_HANDLE_ENV: - *OutputHandle = new ODBCEnv; - return SQL_SUCCESS; + case SQL_HANDLE_ENV: { + ODBCEnv & newEnv = * new ODBCEnv; + *OutputHandle = & newEnv; + // TODO: catch & convert exceptions + return newEnv.init(); + } case SQL_HANDLE_DBC: { - ODBCEnv * env = static_cast<ODBCEnv *>(InputHandle); - return env->AllocConnect(OutputHandle); + ODBCEnv & env = * static_cast<ODBCEnv *>(InputHandle); + return env.AllocConnect(OutputHandle); } case SQL_HANDLE_STMT: { - ODBCConnection * conn = static_cast<ODBCConnection *>(InputHandle); - return conn->AllocStmt(OutputHandle); + ODBCConnection & conn = * static_cast<ODBCConnection *>(InputHandle); + return conn.AllocStmt(OutputHandle); } case SQL_HANDLE_DESC: return SQL_ERROR;
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS update of odbsequoia (5 files), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of odbsequoia/src (connect.cpp), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of odbsequoia (5 files), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home
| advertise | OSDir is
an inevitable website.
|