📄 context.cpp
字号:
break; CS_SMALLINT value = (CS_SMALLINT) par.Value(); ret_code = ct_param(cmd, ¶m_fmt, (CS_VOID*) &value, CS_UNUSED, indicator); break; } case eDB_TinyInt: { CDB_TinyInt& par = dynamic_cast<CDB_TinyInt&> (param); param_fmt.datatype = CS_TINYINT_TYPE; if ( declare_only ) break; CS_TINYINT value = (CS_TINYINT) par.Value(); ret_code = ct_param(cmd, ¶m_fmt, (CS_VOID*) &value, CS_UNUSED, indicator); break; } case eDB_Bit: { CDB_Bit& par = dynamic_cast<CDB_Bit&> (param); param_fmt.datatype = CS_BIT_TYPE; if ( declare_only ) break; CS_BIT value = (CS_BIT) par.Value(); ret_code = ct_param(cmd, ¶m_fmt, (CS_VOID*) &value, CS_UNUSED, indicator); break; } case eDB_BigInt: { CDB_BigInt& par = dynamic_cast<CDB_BigInt&> (param); param_fmt.datatype = CS_NUMERIC_TYPE; if ( declare_only ) break; CS_NUMERIC value; Int8 v8 = par.Value(); memset(&value, 0, sizeof(value)); value.precision= 18; if (longlong_to_numeric(v8, 18, value.array) == 0) return false; ret_code = ct_param(cmd, ¶m_fmt, (CS_VOID*) &value, CS_UNUSED, indicator); break; } case eDB_Char: { CDB_Char& par = dynamic_cast<CDB_Char&> (param); param_fmt.datatype = CS_CHAR_TYPE; if ( declare_only ) break; ret_code = ct_param(cmd, ¶m_fmt, (CS_VOID*) par.Value(), (CS_INT) par.Size(), indicator); break; } case eDB_LongChar: { CDB_LongChar& par = dynamic_cast<CDB_LongChar&> (param); param_fmt.datatype = CS_LONGCHAR_TYPE; if ( declare_only ) break; ret_code = ct_param(cmd, ¶m_fmt, (CS_VOID*) par.Value(), (CS_INT) par.Size(), indicator); break; } case eDB_VarChar: { CDB_VarChar& par = dynamic_cast<CDB_VarChar&> (param); param_fmt.datatype = CS_CHAR_TYPE; if ( declare_only ) break; ret_code = ct_param(cmd, ¶m_fmt, (CS_VOID*) par.Value(), (CS_INT) par.Size(), indicator); break; } case eDB_Binary: { CDB_Binary& par = dynamic_cast<CDB_Binary&> (param); param_fmt.datatype = CS_BINARY_TYPE; if ( declare_only ) break; ret_code = ct_param(cmd, ¶m_fmt, (CS_VOID*) par.Value(), (CS_INT) par.Size(), indicator); break; } case eDB_LongBinary: { CDB_LongBinary& par = dynamic_cast<CDB_LongBinary&> (param); param_fmt.datatype = CS_LONGBINARY_TYPE; if ( declare_only ) break; ret_code = ct_param(cmd, ¶m_fmt, (CS_VOID*) par.Value(), (CS_INT) par.Size(), indicator); break; } case eDB_VarBinary: { CDB_VarBinary& par = dynamic_cast<CDB_VarBinary&> (param); param_fmt.datatype = CS_BINARY_TYPE; if ( declare_only ) break; ret_code = ct_param(cmd, ¶m_fmt, (CS_VOID*) par.Value(), (CS_INT) par.Size(), indicator); break; } case eDB_Float: { CDB_Float& par = dynamic_cast<CDB_Float&> (param); param_fmt.datatype = CS_REAL_TYPE; if ( declare_only ) break; CS_REAL value = (CS_REAL) par.Value(); ret_code = ct_param(cmd, ¶m_fmt, (CS_VOID*) &value, CS_UNUSED, indicator); break; } case eDB_Double: { CDB_Double& par = dynamic_cast<CDB_Double&> (param); param_fmt.datatype = CS_FLOAT_TYPE; if ( declare_only ) break; CS_FLOAT value = (CS_FLOAT) par.Value(); ret_code = ct_param(cmd, ¶m_fmt, (CS_VOID*) &value, CS_UNUSED, indicator); break; } case eDB_SmallDateTime: { CDB_SmallDateTime& par = dynamic_cast<CDB_SmallDateTime&> (param); param_fmt.datatype = CS_DATETIME4_TYPE; if ( declare_only ) break; CS_DATETIME4 dt; dt.days = par.GetDays(); dt.minutes = par.GetMinutes(); ret_code = ct_param(cmd, ¶m_fmt, (CS_VOID*) &dt, CS_UNUSED, indicator); break; } case eDB_DateTime: { CDB_DateTime& par = dynamic_cast<CDB_DateTime&> (param); param_fmt.datatype = CS_DATETIME_TYPE; if ( declare_only ) break; CS_DATETIME dt; dt.dtdays = par.GetDays(); dt.dttime = par.Get300Secs(); ret_code = ct_param(cmd, ¶m_fmt, (CS_VOID*) &dt, CS_UNUSED, indicator); break; } default: { return false; } } if ( declare_only ) { ret_code = ct_param(cmd, ¶m_fmt, 0, CS_UNUSED, 0); } return (ret_code == CS_SUCCEED);}///////////////////////////////////////////////////////////////////////// Driver manager related functions//I_DriverContext* CTLIB_CreateContext(map<string,string>* attr = 0){ bool reuse_context= true; CS_INT version= CS_VERSION_110; if(attr) { reuse_context= (*attr)["reuse_context"] != "false"; string vers= (*attr)["version"]; if(vers.find("100") != string::npos) { version= CS_VERSION_100; } else { char* e; long v= strtol(vers.c_str(), &e, 10); if (v > 0 && (e == 0 || (!isalpha(*e)))) version= v; } } CTLibContext* cntx= new CTLibContext(reuse_context, version); if(cntx && attr) { string page_size= (*attr)["packet"]; if(!page_size.empty()) { CS_INT s= atoi(page_size.c_str()); cntx->CTLIB_SetPacketSize(s); } string prog_name= (*attr)["prog_name"]; if(!prog_name.empty()) { cntx->CTLIB_SetApplicationName(prog_name); } string host_name= (*attr)["host_name"]; if(!host_name.empty()) { cntx->CTLIB_SetHostName(host_name); } } return cntx;}void DBAPI_RegisterDriver_CTLIB(I_DriverMgr& mgr){ mgr.RegisterDriver("ctlib", CTLIB_CreateContext);}extern "C" { NCBI_DBAPIDRIVER_CTLIB_EXPORT void* DBAPI_E_ctlib() { return (void*)DBAPI_RegisterDriver_CTLIB; }} END_NCBI_SCOPE/* * =========================================================================== * $Log: context.cpp,v $ * Revision 1000.5 2004/06/01 19:19:38 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.32 * * Revision 1.32 2004/05/17 21:12:03 gorelenk * Added include of PCH ncbi_pch.hpp * * Revision 1.31 2004/04/07 13:41:47 gorelenk * Added export prefix to implementations of DBAPI_E_* functions. * * Revision 1.30 2003/11/19 22:47:20 soussov * adds code to setup client/server msg callbacks for each connection; adds 'prog_name' and 'host_name' attributes for create context * * Revision 1.29 2003/11/14 20:46:13 soussov * implements DoNotConnect mode * * Revision 1.28 2003/10/29 21:45:54 soussov * adds code which prevents repeated timeouts if server is hanging * * Revision 1.27 2003/10/27 17:00:20 soussov * adds code to prevent the return of broken connection from the pool * * Revision 1.26 2003/07/21 22:00:36 soussov * fixes bug whith pool name mismatch in Connect() * * Revision 1.25 2003/07/17 20:45:44 soussov * connections pool improvements * * Revision 1.24 2003/05/27 21:12:03 soussov * bit type param added * * Revision 1.23 2003/05/15 21:54:30 soussov * fixed bug in timeout handling * * Revision 1.22 2003/04/29 21:15:35 soussov * new datatypes CDB_LongChar and CDB_LongBinary added * * Revision 1.21 2003/04/01 21:49:55 soussov * new attribute 'packet=XXX' (where XXX is a packet size) added to CTLIB_CreateContext * * Revision 1.20 2003/03/18 14:34:20 ivanov * Fix for Rev 1.18-1.19 -- #include's for gethostname() on NCBI_OS_MSWIN platform * * Revision 1.19 2003/03/17 20:57:09 ivanov * #include <unistd.h> everywhere except NCBI_OS_MSWIN platform * * Revision 1.18 2003/03/17 19:37:31 ucko * #include <unistd.h> for gethostname() * * Revision 1.17 2003/03/17 15:29:02 soussov * sets the default host name using gethostname() * * Revision 1.16 2002/12/20 17:53:56 soussov * renames the members of ECapability enum * * Revision 1.15 2002/09/19 20:05:43 vasilche * Safe initialization of static mutexes * * Revision 1.14 2002/06/28 22:49:02 garrett * CTLIB now connects under Windows. * * Revision 1.13 2002/04/19 15:01:28 soussov * adds static mutex to Connect * * Revision 1.12 2002/04/12 18:50:25 soussov * static mutex in context constructor added * * Revision 1.11 2002/03/26 15:34:38 soussov * new image/text operations added * * Revision 1.10 2002/01/17 22:07:10 soussov * changes driver registration * * Revision 1.9 2002/01/11 20:24:33 soussov * driver manager support added * * Revision 1.8 2001/11/06 18:02:00 lavr * Added methods formely inline (moved from header files) * * Revision 1.7 2001/10/12 21:21:55 lavr * Bugfix: Changed '=' -> '==' in severity parsing * * Revision 1.6 2001/10/11 16:30:44 soussov * exclude ctlib dependencies from numeric conversion calls * * Revision 1.5 2001/10/01 20:09:30 vakatov * Introduced a generic default user error handler and the means to * alternate it. Added an auxiliary error handler class * "CDB_UserHandler_Stream". * Moved "{Push/Pop}{Cntx/Conn}MsgHandler()" to the generic code * (in I_DriverContext). * * Revision 1.4 2001/09/27 20:08:33 vakatov * Added "DB_" (or "I_") prefix where it was missing * * Revision 1.3 2001/09/27 16:46:34 vakatov * Non-const (was const) exception object to pass to the user handler * * Revision 1.2 2001/09/26 23:23:31 vakatov * Moved the err.message handlers' stack functionality (generic storage * and methods) to the "abstract interface" level. * * Revision 1.1 2001/09/21 23:40:02 vakatov * ----- Initial (draft) revision. ----- * This is a major revamp (by Denis Vakatov, with help from Vladimir Soussov) * of the DBAPI "driver" libs originally written by Vladimir Soussov. * The revamp involved massive code shuffling and grooming, numerous local * API redesigns, adding comments and incorporating DBAPI to the C++ Toolkit. * * =========================================================================== */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -