src/odbc/odbcDesc.cxx

Go to the documentation of this file.
00001 /*  Class CSqlOdbcDescList
00002     Description: Generic Descriptor manager. 
00003 
00004     Functions:
00005         CSqlOdbcDescList::delDesc();
00006         CSqlOdbcDescList::freeAllDesc();
00007         CSqlOdbcDescList::getDescWithColNum();
00008 
00009         CSqlOdbcDesc::CSqlOdbcDesc();
00010 */
00011 
00012 #include "odbcCommon.h"
00013 
00014 // Class CSqlOdbcDescList Member functions
00015 //----------------------------------
00016 // Delete descriptor from list
00017 SQLRETURN CSqlOdbcDescList::delDesc( CSqlOdbcDesc *node )
00018 {
00019     CSqlOdbcDescList::iterator iter;
00020     iter = this->begin();
00021     while( iter != this->end() )
00022     {
00023         if( *iter == node )
00024         {
00025             delete node;
00026             this->erase( iter );
00027             return( SQL_SUCCESS );
00028         }
00029         iter++;
00030     }
00031 
00032     return(SQL_ERROR);
00033 }
00034 
00035 void CSqlOdbcDescList::freeAllDesc( void )
00036 {
00037     int size=(int)this->size();
00038     if(size  > 0)
00039     {
00040             CSqlOdbcDescList::iterator iter;
00041             iter = this->begin();
00042             while( iter != this->end() )
00043             {
00044                     if(type_ == SQL_DESC_IMP)
00045                     {
00046                             if((*iter)->dataPtr_!= NULL)
00047                             {
00048                                     if((*iter)->cType_ == SQL_C_CHAR || (*iter)->cType_ == SQL_C_BINARY)
00049                                             delete []  (*iter)->dataPtr_;
00050                                     else
00051                                             delete (*iter)->dataPtr_;
00052                                     (*iter)->dataPtr_=NULL;
00053                             }
00054                     }
00055                     delete *iter;
00056                     *iter=NULL;
00057                     iter++;
00058             }
00059             this->clear();
00060     }
00061 }
00062 
00063 SQLRETURN CSqlOdbcDescList::getDescWithColNum( int colNum, CSqlOdbcDesc **out )
00064 {
00065     CSqlOdbcDescList::iterator iter;
00066     iter = this->begin();
00067     while( iter != this->end() )
00068     {
00069         if( colNum == (*iter)->col_ )
00070         {
00071             *out = *iter;
00072             return( SQL_SUCCESS );
00073         }
00074         iter++;
00075     }
00076 
00077     return( SQL_ERROR );
00078 }
00079 
00080 CSqlOdbcDescList::CSqlOdbcDescList( int descType )
00081 {
00082     type_=descType;
00083 }
00084 
00085 // Class CSqlOdbcDesc Functions
00086 //----------------------------------
00087 CSqlOdbcDesc::CSqlOdbcDesc( void ) :
00088     col_( 0 ),
00089     dataPtr_( 0 ),
00090     length_( 0 ),
00091     precision_( 0 ),
00092     scale_( 0 ),
00093     indPtr_( 0 ),
00094     cType_( -1 ),
00095     sqlType_( -1 ),
00096     csqlType_( -1 ),
00097     paramType_( SQL_PARAM_TYPE_UNKNOWN )
00098 {
00099     schemaName_[0] = '\0';
00100     tableName_[0] = '\0';
00101     colName_[0] = '\0';
00102 }
00103 

Generated on Mon Jun 9 22:37:14 2008 for csql by  doxygen 1.4.7