Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

odbc Namespace Reference


Classes

class  odbc::CallableStatement
class  odbc::Connection
class  odbc::DatabaseMetaData
class  odbc::Driver
class  odbc::DataSource
class  odbc::DriverManager
class  odbc::ErrorHandler
class  odbc::PreparedStatement
class  odbc::ResultSet
class  odbc::ResultSetMetaData
class  odbc::Statement
struct  odbc::Types
class  odbc::Bytes
struct  odbc::Bytes::Rep
class  odbc::Date
class  odbc::Time
class  odbc::Timestamp
class  odbc::CleanVector< T >
class  odbc::DriverMessage
class  odbc::SQLException
class  odbc::SQLWarning
class  odbc::Deleter< T >
class  odbc::DataHandler
class  odbc::Rowset
class  odbc::DataStreamBuf
class  odbc::DataStreamBase
class  odbc::DataStream
class  odbc::DriverInfo
class  odbc::ValueSaver< T >

Typedefs

typedef CleanVector< Driver * > DriverList
typedef CleanVector< DataSource * > DataSourceList
typedef CleanVector< SQLWarning * > WarningList

Enumerations

enum  { INSERTS, UPDATES, DELETES }

Functions

int getODBCCursorTypeFor (int rsType, const DriverInfo *di)
const char * nameOfSQLType (int sqlType)
const char * nameOfCType (int cType)
void localtime (time_t t, tm *stm)
ODBCXX_STRING intToString (int i)
int stringToInt (const ODBCXX_STRING &s)
ODBCXX_STRING longToString (Long l)
odbc::Long stringToLong (const ODBCXX_STRING &_s)
ODBCXX_STRING doubleToString (double d)
double stringToDouble (const ODBCXX_STRING &s)
int readStream (ODBCXX_STREAM *s, char *buf, unsigned int maxlen)
ODBCXX_STREAM * stringToStream (const ODBCXX_STRING &str)
ODBCXX_STRING streamToString (ODBCXX_STREAM *s)
ODBCXX_BYTES streamToBytes (ODBCXX_STREAM *s)
ODBCXX_STREAM * bytesToStream (const ODBCXX_BYTES &b)

Variables

const int GETDATA_CHUNK_SIZE = 4*1024
const int PUTDATA_CHUNK_SIZE = GETDATA_CHUNK_SIZE
const int STRING_TO_STREAM_CHUNK_SIZE = 1024
const int STREAM_TO_STRING_CHUNK_SIZE = STRING_TO_STREAM_CHUNK_SIZE
const int INT_STR_LEN = 12
const int LONG_STR_LEN = 22
const int DOUBLE_STR_LEN = 80


Detailed Description

The namespace where all libodbc++ classes reside


Typedef Documentation

typedef CleanVector<DataSource*> odbc::DataSourceList
 

A list of datasources. Behaves like an std::vector

Definition at line 94 of file drivermanager.h.

Referenced by odbc::DriverManager::getDataSources(), main(), and ODBCConnection::RefreshDataSources().

typedef CleanVector<Driver*> odbc::DriverList
 

A list of Drivers. Actually an STL vector

Definition at line 65 of file drivermanager.h.

Referenced by odbc::DriverManager::getDrivers(), main(), and ODBCConnection::RefreshDrivers().

typedef CleanVector<SQLWarning*> odbc::WarningList
 

Definition at line 742 of file types.h.

Referenced by dumpWarnings().


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
INSERTS 
UPDATES 
DELETES 

Definition at line 113 of file databasemetadata.cpp.

00113      {
00114   INSERTS,UPDATES,DELETES
00115 };


Function Documentation

ODBCXX_STREAM* bytesToStream const ODBCXX_BYTES &  b  )  [inline]
 

Definition at line 227 of file dtconv.h.

References ODBCXX_STREAM, and s().

Referenced by odbc::DataHandler::setBytes(), and odbc::ResultSet::updateBytes().

00227                                                              {
00228 #if !defined(ODBCXX_QT)
00229     stringstream* s=new stringstream();
00230     if(b.getSize()>0) {
00231       s->write((char*)b.getData(),b.getSize());
00232     }
00233     return s;
00234 #else // ODBCXX_QT
00235     QBuffer* buf=new QBuffer(b.copy());
00236     buf->open(IO_ReadOnly);
00237     return buf;
00238 #endif
00239   }

ODBCXX_STRING doubleToString double  d  )  [inline]
 

Definition at line 117 of file dtconv.h.

References DOUBLE_STR_LEN, ODBCXX_STRING, and ODBCXX_STRING_C.

Referenced by odbc::DataHandler::getString(), odbc::DataHandler::setDouble(), and odbc::DataHandler::setFloat().

00117                                                 {
00118     char buf[DOUBLE_STR_LEN];
00119 #if defined(ODBCXX_HAVE_SNPRINTF)
00120     snprintf(buf,DOUBLE_STR_LEN,"%f",d);
00121 #elif defined(ODBCXX_HAVE__SNPRINTF)
00122     _snprintf(buf,DOUBLE_STR_LEN,"%f",d);
00123 #else
00124     sprintf(buf,"%f",d);
00125 #endif
00126     return ODBCXX_STRING_C(buf);
00127   }

int getODBCCursorTypeFor int  rsType,
const DriverInfo di
[inline]
 

Definition at line 43 of file databasemetadata.cpp.

References odbc::DriverInfo::getCursorMask(), and intToString().

Referenced by odbc::DatabaseMetaData::_ownXXXAreVisible(), odbc::DatabaseMetaData::othersDeletesAreVisible(), odbc::DatabaseMetaData::othersInsertsAreVisible(), and odbc::DatabaseMetaData::othersUpdatesAreVisible().

00044 {
00045   int r;
00046   switch(rsType) {
00047   case ResultSet::TYPE_FORWARD_ONLY:
00048     r=SQL_CURSOR_FORWARD_ONLY; 
00049     break;
00050   case ResultSet::TYPE_SCROLL_INSENSITIVE:
00051     r=SQL_CURSOR_STATIC; 
00052     break;
00053   case ResultSet::TYPE_SCROLL_SENSITIVE:
00054     if(di->getCursorMask()&SQL_SO_DYNAMIC) {
00055       r=SQL_CURSOR_DYNAMIC;
00056     } else {
00057       r=SQL_CURSOR_KEYSET_DRIVEN;
00058     }
00059     break;
00060   default:
00061     throw SQLException("[libodbc++]: Invalid ResultSet type "+intToString(rsType));
00062   }
00063   
00064   return r;
00065 }

ODBCXX_STRING intToString int  i  )  [inline]
 

Definition at line 50 of file dtconv.h.

References INT_STR_LEN, and ODBCXX_STRING.

Referenced by odbc::PreparedStatement::_checkParam(), odbc::Timestamp::_invalid(), odbc::Date::_invalid(), odbc::Time::_invalid(), odbc::DataHandler::DataHandler(), getODBCCursorTypeFor(), odbc::DataHandler::getString(), odbc::ResultSet::setFetchSize(), odbc::DataHandler::setInt(), odbc::DatabaseMetaData::supportsConvert(), odbc::DatabaseMetaData::supportsResultSetConcurrency(), odbc::DatabaseMetaData::supportsResultSetType(), and odbc::Timestamp::toString().

00050                                           {
00051 
00052 #if defined(ODBCXX_QT)
00053 
00054     return QString::number(i);
00055 
00056 #else
00057 
00058     char buf[INT_STR_LEN];
00059 
00060 # if defined(WIN32) && defined(ODBCXX_HAVE__ITOA)
00061     _itoa(i,buf,10);
00062 # elif defined(WIN32) && defined(ODBCXX_HAVE_ITOA)
00063     itoa(i,buf,10);
00064 # else
00065     snprintf(buf,INT_STR_LEN,"%d",i);
00066 # endif
00067     return std::string(buf);
00068 #endif
00069   }

void localtime time_t  t,
tm *  stm
[inline]
 

Definition at line 66 of file datetime.cpp.

References ODBCXX_LOCKER.

Referenced by VldTimeStamp::AsString(), VldTimeStamp::GetDate(), VldTimeStamp::GetTime(), VldTimeStamp::GetZoneOffset(), UberRecHeader::Print(), UberHeader::Print(), UberHeader::ReadTemperature(), MsgStream::SetCurrentDateString(), odbc::Timestamp::setTime(), odbc::Time::setTime(), and odbc::Date::setTime().

00066                                            {
00067 
00068 #if defined(ODBCXX_ENABLE_THREADS)
00069     
00070 # if defined(ODBCXX_HAVE_LOCALTIME_R)
00071     
00072     ::localtime_r(&t,stm);
00073 
00074 # else
00075 
00076     // workaround
00077     static odbc::Mutex lock;
00078     {
00079       ODBCXX_LOCKER(lock);
00080       memcpy(stm,::localtime(&t),sizeof(tm));
00081     }
00082     
00083 
00084 # endif // HAVE_LOCALTIME_R
00085 
00086 #else
00087     // no reentrancy needed
00088     memcpy(stm,::localtime(&t),sizeof(tm));
00089 #endif
00090   }

ODBCXX_STRING longToString Long  l  )  [inline]
 

Definition at line 79 of file dtconv.h.

References LONG_STR_LEN, ODBCXX_SIZEOF_LONG, ODBCXX_STRING, and ODBCXX_STRING_C.

Referenced by odbc::DataHandler::getString(), and odbc::DataHandler::setLong().

00079                                             {
00080     char buf[LONG_STR_LEN];
00081 #if defined(WIN32) && defined(ODBCXX_HAVE__I64TOA)
00082     _i64toa(l,buf,10);
00083 #else
00084     snprintf(buf,LONG_STR_LEN,
00085 # if defined(PRId64)
00086              "%" PRId64
00087 # elif ODBCXX_SIZEOF_LONG==8
00088              "%ld"
00089 # else
00090              "%lld"
00091 # endif
00092              ,l);
00093 #endif // _i64toa
00094     return ODBCXX_STRING_C(buf);
00095   }

const char* nameOfCType int  cType  ) 
 

Definition at line 78 of file datahandler.cpp.

00078                                      {
00079     static struct {
00080       int id;
00081       const char* name;
00082     } cTypes[] = {
00083       { SQL_C_CHAR,             "SQL_C_CHAR" },
00084       { SQL_C_BINARY,           "SQL_C_BINARY" },
00085       { SQL_C_BIT,              "SQL_C_BIT" },
00086       { SQL_C_TINYINT,          "SQL_C_TINYINT" },
00087       { SQL_C_SHORT,            "SQL_C_SHORT" },
00088       { SQL_C_LONG,             "SQL_C_LONG" },
00089       { SQL_C_DOUBLE,           "SQL_C_DOUBLE" },
00090       { SQL_C_FLOAT,            "SQL_C_FLOAT" },
00091       { SQL_C_DATE,             "SQL_C_DATE" },
00092       { SQL_C_TIME,             "SQL_C_TIME" },
00093       { SQL_C_TIMESTAMP,        "SQL_C_TIMESTAMP" },
00094 #if ODBCVER >= 0x0300
00095       { SQL_C_SBIGINT,          "SQL_C_SBIGINT" },
00096       { SQL_C_TYPE_TIME,        "SQL_C_TYPE_TIME" },
00097       { SQL_C_TYPE_DATE,        "SQL_C_TYPE_DATE" },
00098       { SQL_C_TYPE_TIMESTAMP,   "SQL_C_TYPE_TIMESTAMP" },
00099 #endif
00100       { 0,                      NULL }
00101     };
00102 
00103     for(unsigned int i=0; cTypes[i].name!=NULL; i++) {
00104       if(cTypes[i].id==cType) {
00105         return cTypes[i].name;
00106       }
00107     }
00108     return "UNKNOWN";
00109   }

const char* nameOfSQLType int  sqlType  ) 
 

Definition at line 42 of file datahandler.cpp.

00042                                          {
00043     static struct {
00044       int id;
00045       const char* name;
00046     } sqlTypes[] = {
00047       { Types::BIGINT,          "BIGINT" },
00048       { Types::BINARY,          "BINARY" },
00049       { Types::BIT,             "BIT" },
00050       { Types::CHAR,            "CHAR" },
00051       { Types::DATE,            "DATE" },
00052       { Types::DECIMAL,         "DECIMAL" },
00053       { Types::DOUBLE,          "DOUBLE" },
00054       { Types::FLOAT,           "FLOAT" },
00055       { Types::INTEGER,         "INTEGER" },
00056       { Types::LONGVARBINARY,   "LONGVARBINARY" },
00057       { Types::LONGVARCHAR,     "LONGVARCHAR" },
00058       { Types::NUMERIC,         "NUMERIC" },
00059       { Types::REAL,            "REAL" },
00060       { Types::SMALLINT,        "SMALLINT" },
00061       { Types::TIME,            "TIME" },
00062       { Types::TIMESTAMP,       "TIMESTAMP" },
00063       { Types::TINYINT,         "TINYINT" },
00064       { Types::VARBINARY,       "VARBINARY" },
00065       { Types::VARCHAR,         "VARCHAR" },
00066       {0,                       NULL }
00067     };
00068 
00069     for(unsigned int i=0; sqlTypes[i].name!=NULL; i++) {
00070       if(sqlTypes[i].id==sqlType) {
00071         return sqlTypes[i].name;
00072       }
00073     }
00074 
00075     return "UNKNOWN";
00076   }

int readStream ODBCXX_STREAM *  s,
char *  buf,
unsigned int  maxlen
[inline]
 

Definition at line 140 of file dtconv.h.

References s().

Referenced by odbc::ResultSet::_handleStreams(), and odbc::PreparedStatement::execute().

00142                                              {
00143 #if defined(ODBCXX_QT)
00144     return s->readBlock(buf,maxlen);
00145 #else
00146     if(*s) {
00147       s->read(buf,maxlen);
00148       return (int)s->gcount();
00149     } else {
00150       return 0;
00151     }
00152 #endif
00153   }

ODBCXX_BYTES streamToBytes ODBCXX_STREAM *  s  )  [inline]
 

Definition at line 189 of file dtconv.h.

References GETDATA_CHUNK_SIZE, ODBCXX_BYTES, and s().

Referenced by odbc::ResultSet::getBytes().

00189                                                       {
00190     char buf[GETDATA_CHUNK_SIZE];
00191     char* bigbuf=NULL;
00192     unsigned int size=0;
00193     //int r;
00194 #if defined(ODBCXX_QT)
00195     while((r=s->readBlock(buf,GETDATA_CHUNK_SIZE))!=-1) {
00196       char* tmp=new char[size+(unsigned int)r];
00197       if(size>0) {
00198         memcpy((void*)tmp,(void*)bigbuf,size);
00199       }
00200       memcpy((void*)&tmp[size],buf,r);
00201       delete[] bigbuf;
00202       bigbuf=tmp;
00203       size+=(unsigned int)r;
00204     }
00205 
00206     // this should take care of deleting bigbuf
00207     return QByteArray().assign(bigbuf,size);
00208 #else
00209     while(s->read(buf,GETDATA_CHUNK_SIZE) || s->gcount()) {
00210       char* tmp=new char[size+s->gcount()];
00211       if(size>0) {
00212         memcpy((void*)tmp,(void*)bigbuf,size);
00213       }
00214       memcpy((void*)&tmp[size],buf,s->gcount());
00215       delete[] bigbuf;
00216       bigbuf=tmp;
00217       size+=s->gcount();
00218     }
00219 
00220     // this copies the buffer's contents
00221     Bytes b((signed char*)bigbuf,size);
00222     delete[] bigbuf;
00223     return b;
00224 #endif
00225   }

ODBCXX_STRING streamToString ODBCXX_STREAM *  s  )  [inline]
 

Definition at line 172 of file dtconv.h.

References GETDATA_CHUNK_SIZE, ODBCXX_STRING, ODBCXX_STRING_CL, and s().

Referenced by odbc::ResultSet::getString().

00172                                                         {
00173     char buf[GETDATA_CHUNK_SIZE];
00174 #if defined(ODBCXX_QT)
00175     int r;
00176     QString ret;
00177     while((r=s->readBlock(buf,GETDATA_CHUNK_SIZE))>0) {
00178       ret+=ODBCXX_STRING_CL(buf,r);
00179     }
00180 #else
00181     std::string ret;
00182     while(s->read(buf,GETDATA_CHUNK_SIZE) || s->gcount()) {
00183       ret+=ODBCXX_STRING_CL(buf,s->gcount());
00184     }
00185 #endif
00186     return ret;
00187   }

double stringToDouble const ODBCXX_STRING &  s  )  [inline]
 

Definition at line 129 of file dtconv.h.

References s().

Referenced by odbc::DataHandler::getDouble(), odbc::DataHandler::getFloat(), and odbc::DataHandler::setString().

00129                                                        {
00130 #if defined(ODBCXX_QT)
00131     return s.toDouble();
00132 #else
00133     return strtod(s.c_str(),NULL);
00134 #endif
00135   }

int stringToInt const ODBCXX_STRING &  s  )  [inline]
 

Definition at line 71 of file dtconv.h.

References s().

Referenced by odbc::DatabaseMetaData::getDriverMajorVersion(), odbc::DatabaseMetaData::getDriverMinorVersion(), odbc::DataHandler::getInt(), and odbc::DataHandler::setString().

00071                                                  {
00072 #if defined(ODBCXX_QT)
00073     return s.toInt();
00074 #else
00075     return (int)strtol(s.c_str(),NULL,10);
00076 #endif
00077   }

odbc::Long stringToLong const ODBCXX_STRING &  _s  )  [inline]
 

Definition at line 97 of file dtconv.h.

References ODBCXX_STRING_CSTR, and s().

Referenced by odbc::DataHandler::getLong().

00097                                                         {
00098 #if !defined(ODBCXX_QT)
00099     const char* s=ODBCXX_STRING_CSTR(_s);
00100 #else
00101     QCString cs(_s.local8Bit());
00102     const char* s=cs.data();
00103 #endif
00104 
00105 #if defined(WIN32) && defined(ODBCXX_HAVE__ATOI64)
00106     return (Long)_atoi64(s);
00107 #elif ODBCXX_SIZEOF_LONG==4 && defined(ODBCXX_HAVE_STRTOLL)
00108     return (Long)strtoll(s,NULL,10);
00109 #elif ODBCXX_SIZEOF_LONG==4 && defined(ODBCXX_HAVE_STRTOQ)
00110     return (Long)strtoq(s,NULL,10);
00111 #else
00112     // either 64bit platform, or I'm stupid.
00113     return (Long)strtol(s,NULL,10);
00114 #endif
00115   }

ODBCXX_STREAM* stringToStream const ODBCXX_STRING &  str  )  [inline]
 

Definition at line 156 of file dtconv.h.

References ODBCXX_STREAM, ODBCXX_STRING_CSTR, ODBCXX_STRING_LEN, and s().

Referenced by odbc::DataHandler::setString(), and odbc::ResultSet::updateString().

00156                                                                  {
00157 #if !defined(ODBCXX_QT)
00158     stringstream* s=new stringstream();
00159     *s << str;
00160     return s;
00161 #else // defined(ODBCXX_QT)
00162     QBuffer* b=new QBuffer();
00163     b->open(IO_WriteOnly);
00164     b->writeBlock(ODBCXX_STRING_CSTR(str),ODBCXX_STRING_LEN(str));
00165     b->close();
00166     b->open(IO_ReadOnly);
00167     return b;
00168 #endif
00169   }


Variable Documentation

const int odbc::DOUBLE_STR_LEN = 80
 

Definition at line 47 of file dtconv.h.

Referenced by doubleToString().

const int odbc::GETDATA_CHUNK_SIZE = 4*1024
 

Definition at line 138 of file types.h.

Referenced by odbc::DataStreamBuf::DataStreamBuf(), streamToBytes(), and streamToString().

const int odbc::INT_STR_LEN = 12
 

Definition at line 45 of file dtconv.h.

Referenced by intToString().

const int odbc::LONG_STR_LEN = 22
 

Definition at line 46 of file dtconv.h.

Referenced by longToString().

const int odbc::PUTDATA_CHUNK_SIZE = GETDATA_CHUNK_SIZE
 

Definition at line 140 of file types.h.

Referenced by odbc::ResultSet::_handleStreams(), and odbc::PreparedStatement::execute().

const int odbc::STREAM_TO_STRING_CHUNK_SIZE = STRING_TO_STREAM_CHUNK_SIZE
 

Definition at line 145 of file types.h.

const int odbc::STRING_TO_STREAM_CHUNK_SIZE = 1024
 

Definition at line 144 of file types.h.


Generated on Thu Nov 1 15:58:51 2007 for loon by  doxygen 1.3.9.1