1 /* 2 This file is part of libodbc++. 3 4 Copyright (C) 1999-2000 Manush Dodunekov <manush@stendahls.net> 5 6 This library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Library General Public 8 License as published by the Free Software Foundation; either 9 version 2 of the License, or (at your option) any later version. 10 11 This library is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Library General Public License for more details. 15 16 You should have received a copy of the GNU Library General Public License 17 along with this library; see the file COPYING. If not, write to 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 Boston, MA 02111-1307, USA. 20 */ 21 22 #ifndef __DRIVERINFO_H 23 #define __DRIVERINFO_H 24 25 #include <odbc++/types.h> 26 27 namespace odbc { 28 29 class Connection; 30 31 class ODBCXX_EXPORT DriverInfo { 32 friend class Connection; 33 public: getMajorVersion()34 int getMajorVersion() const { 35 return majorVersion_; 36 } 37 getMinorVersion()38 int getMinorVersion() const { 39 return minorVersion_; 40 } 41 getCursorMask()42 int getCursorMask() const { 43 return cursorMask_; 44 } 45 supportsForwardOnly()46 bool supportsForwardOnly() const { 47 return (cursorMask_&SQL_SO_FORWARD_ONLY)!=0; 48 } 49 supportsStatic()50 bool supportsStatic() const { 51 return (cursorMask_&SQL_SO_STATIC)!=0; 52 } 53 supportsKeyset()54 bool supportsKeyset() const { 55 return (cursorMask_&SQL_SO_KEYSET_DRIVEN)!=0; 56 } 57 supportsDynamic()58 bool supportsDynamic() const { 59 return (cursorMask_&SQL_SO_DYNAMIC)!=0; 60 } 61 supportsScrollSensitive()62 bool supportsScrollSensitive() const { 63 return 64 this->supportsDynamic() || 65 this->supportsKeyset(); 66 } 67 68 // assumes that this->supportsScrollSensitive()==true getScrollSensitive()69 int getScrollSensitive() const { 70 if(this->supportsDynamic()) { 71 return SQL_CURSOR_DYNAMIC; 72 } else { 73 return SQL_CURSOR_KEYSET_DRIVEN; 74 } 75 } 76 77 // concurrency, ct is an SQL_CURSOR constant 78 bool supportsReadOnly(int ct) const; 79 bool supportsLock(int ct) const; 80 bool supportsRowver(int ct) const; 81 bool supportsValues(int ct) const; 82 supportsUpdatable(int ct)83 bool supportsUpdatable(int ct) const { 84 return 85 this->supportsLock(ct) || 86 this->supportsRowver(ct) || 87 this->supportsValues(ct); 88 } 89 getUpdatable(int ct)90 int getUpdatable(int ct) const { 91 // assumes supportsUpdatable(ct) returns true 92 if(this->supportsRowver(ct)) { 93 return SQL_CONCUR_ROWVER; 94 } else if(this->supportsValues(ct)) { 95 return SQL_CONCUR_VALUES; 96 } else if(this->supportsLock(ct)) { 97 return SQL_CONCUR_LOCK; 98 } 99 return SQL_CONCUR_READ_ONLY; 100 } 101 // GetDataSupport supportsGetDataAnyOrder(void)102 bool supportsGetDataAnyOrder(void) const 103 { return (getdataExt_ & SQL_GD_ANY_ORDER)!=0; }; supportsGetDataAnyColumn(void)104 bool supportsGetDataAnyColumn(void) const 105 { return (getdataExt_ & SQL_GD_ANY_COLUMN)!=0; }; supportsGetDataBlock(void)106 bool supportsGetDataBlock(void) const 107 { return (getdataExt_ & SQL_GD_BLOCK)!=0; }; supportsGetDataBound(void)108 bool supportsGetDataBound(void) const 109 { return (getdataExt_ & SQL_GD_BOUND)!=0; }; 110 // supportsFunction(int funcId)111 bool supportsFunction(int funcId) const { 112 return ODBC3_C 113 (SQL_FUNC_EXISTS(supportedFunctions_,funcId), 114 supportedFunctions_[funcId])==SQL_TRUE; 115 } 116 117 private: 118 // odbc version 119 int majorVersion_; 120 int minorVersion_; 121 122 int getdataExt_; 123 int cursorMask_; 124 #if ODBCVER >= 0x0300 125 int forwardOnlyA2_; 126 int staticA2_; 127 int keysetA2_; 128 int dynamicA2_; 129 #endif 130 int concurMask_; 131 132 133 SQLUSMALLINT* supportedFunctions_; 134 135 explicit DriverInfo(Connection* con); ~DriverInfo()136 ~DriverInfo() { 137 delete[] supportedFunctions_; 138 } 139 }; 140 141 } // namespace odbc 142 143 144 #endif // __DRIVERINFO_H 145 146