/*
This file is part of libodbc++.
Copyright (C) 1999-2000 Manush Dodunekov <manush@stendahls.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __ODBCXX_RESULTSETMETADATA_H
#define __ODBCXX_RESULTSETMETADATA_H
#include <odbc++/setup.h>
#include <odbc++/types.h>
#include <odbc++/resultset.h>
namespace odbc {
class ResultSet;
class DriverInfo;
class ODBCXX_EXPORT ResultSetMetaData {
friend class ResultSet;
friend class Statement;
private:
ResultSet* resultSet_;
int numCols_;
std::vector<ODBCXX_STRING> colNames_;
std::vector<int> colTypes_;
std::vector<int> colPrecisions_;
std::vector<int> colScales_;
#if ODBCVER >= 0x0300
std::vector<int> colLengths_;
#endif
//internal stuff
bool needsGetData_;
//yes, both constructor and destructor are meant to be private
ResultSetMetaData(ResultSet* rs);
~ResultSetMetaData() {}
//driver info
const DriverInfo* _getDriverInfo() const {
return resultSet_->_getDriverInfo();
}
//these fetch info about a column
int _getNumericAttribute(unsigned int col, SQLUSMALLINT attr);
ODBCXX_STRING _getStringAttribute(unsigned int col, SQLUSMALLINT attr, unsigned int maxlen =255);
//this loads the above values
void _fetchColumnInfo();
public:
enum {
columnNoNulls = SQL_NO_NULLS,
columnNullable = SQL_NULLABLE,
columnNullableUnknown = SQL_NULLABLE_UNKNOWN
};
int getColumnCount() const;
const ODBCXX_STRING& getColumnName(int column) const;
int getColumnType(int column) const;
int getPrecision(int column) const;
int getScale(int column) const;
int getColumnDisplaySize(int column);
ODBCXX_STRING getCatalogName(int column);
ODBCXX_STRING getColumnLabel(int column);
ODBCXX_STRING getColumnTypeName(int column);
ODBCXX_STRING getSchemaName(int column);
ODBCXX_STRING getTableName(int column);
bool isAutoIncrement(int column);
bool isCaseSensitive(int column);
bool isCurrency(int column);
bool isDefinitelyWritable(int column);
int isNullable(int column);
bool isReadOnly(int column);
bool isSearchable(int column);
bool isSigned(int column);
bool isWritable(int column);
};
}; // namespace odbc
#endif // __ODBCXX_RESULTSETMETADATA_H