Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

odbc++/resultsetmetadata.h

00001 /* 
00002    This file is part of libodbc++.
00003    
00004    Copyright (C) 1999-2000 Manush Dodunekov <manush@stendahls.net>
00005    
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010    
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015    
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.  If not, write to
00018    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019    Boston, MA 02111-1307, USA.
00020 */
00021 
00022 #ifndef __ODBCXX_RESULTSETMETADATA_H
00023 #define __ODBCXX_RESULTSETMETADATA_H
00024 
00025 #include <odbc++/setup.h>
00026 #include <odbc++/types.h>
00027 #include <odbc++/resultset.h>
00028 
00029 namespace odbc {
00030 
00031   class ResultSet;
00032   class DriverInfo;
00033 
00035   class ODBCXX_EXPORT ResultSetMetaData {
00036     friend class ResultSet;
00037     friend class Statement;
00038   private:
00039     ResultSet* resultSet_;
00040 
00041     int numCols_;
00042     std::vector<ODBCXX_STRING> colNames_;
00043     std::vector<int> colTypes_;
00044     std::vector<int> colPrecisions_;
00045     std::vector<int> colScales_;
00046 #if ODBCVER >= 0x0300
00047     std::vector<int> colLengths_;
00048 #endif
00049 
00050     //internal stuff
00051     bool needsGetData_;
00052 
00053     //yes, both constructor and destructor are meant to be private
00054     ResultSetMetaData(ResultSet* rs);
00055     ~ResultSetMetaData() {}
00056 
00057     //driver info
00058     const DriverInfo* _getDriverInfo() const {
00059       return resultSet_->_getDriverInfo();
00060     }
00061 
00062     //these fetch info about a column
00063     int _getNumericAttribute(unsigned int col, SQLUSMALLINT attr);
00064     ODBCXX_STRING _getStringAttribute(unsigned int col, SQLUSMALLINT attr, unsigned int maxlen =255);
00065 
00066     //this loads the above values
00067     void _fetchColumnInfo();
00068 
00069   public:
00071     enum {
00072       columnNoNulls             = SQL_NO_NULLS,
00073       columnNullable            = SQL_NULLABLE,
00074       columnNullableUnknown     = SQL_NULLABLE_UNKNOWN
00075     };
00076 
00078     int getColumnCount() const;
00079 
00083     const ODBCXX_STRING& getColumnName(int column) const;
00084 
00089     int getColumnType(int column) const;
00090 
00094     int getPrecision(int column) const;
00095 
00099     int getScale(int column) const;
00100 
00104     int getColumnDisplaySize(int column);
00105 
00109     ODBCXX_STRING getCatalogName(int column);
00110 
00114     ODBCXX_STRING getColumnLabel(int column);
00115 
00119     ODBCXX_STRING getColumnTypeName(int column);
00120 
00124     ODBCXX_STRING getSchemaName(int column);
00125 
00129     ODBCXX_STRING getTableName(int column);
00130 
00134     bool isAutoIncrement(int column);
00135 
00139     bool isCaseSensitive(int column);
00140     
00144     bool isCurrency(int column);
00145 
00149     bool isDefinitelyWritable(int column);
00150 
00154     int isNullable(int column);
00155 
00159     bool isReadOnly(int column);
00160 
00164     bool isSearchable(int column);
00165 
00169     bool isSigned(int column);
00170 
00174     bool isWritable(int column);
00175   };
00176 
00177   
00178 
00179 }; // namespace odbc
00180 
00181 
00182 #endif // __ODBCXX_RESULTSETMETADATA_H

Go back to the freeodbc++ homepage