libodbc++  0.2.5
resultsetmetadata.h
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 __ODBCXX_RESULTSETMETADATA_H
23 #define __ODBCXX_RESULTSETMETADATA_H
24 
25 #include <odbc++/setup.h>
26 #include <odbc++/types.h>
27 #include <odbc++/resultset.h>
28 #define ODBCXX_USE_INDEXED_METADATA_COLNAMES
29 namespace odbc {
30 
31  class ResultSet;
32  class DriverInfo;
33 #ifdef ODBCXX_USE_INDEXED_METADATA_COLNAMES
34 typedef struct caseinsesnless
35 : public std::less<ODBCXX_STRING>
36 {
37  bool operator()(const ODBCXX_STRING _Left, const ODBCXX_STRING _Right) const;
38 }CaseInsesitiveLess;
39 #endif // ODBCXX_USE_INDEXED_METADATA_COLNAMES
40 
41  class ODBCXX_EXPORT ResultSetMetaData {
42  friend class ResultSet;
43  friend class Statement;
44  private:
45 
46  ResultSet* resultSet_;
47 
48  int numCols_;
49  std::vector<ODBCXX_STRING> colNames_;
50 #ifdef ODBCXX_USE_INDEXED_METADATA_COLNAMES
51  std::map<const ODBCXX_STRING, int, CaseInsesitiveLess> colNameIndex_;
52  int findColumn(const ODBCXX_STRING& colName);
53 #endif // ODBCXX_USE_INDEXED_METADATA_COLNAMES
54  std::vector<int> colTypes_;
55  std::vector<int> colPrecisions_;
56  std::vector<int> colScales_;
57 #if ODBCVER >= 0x0300
58  std::vector<int> colLengths_;
59 #endif
60 
61  //internal stuff
62  bool needsGetData_;
63 
64  //yes, both constructor and destructor are meant to be private
66  ~ResultSetMetaData() {}
67 
68  //driver info
69  const DriverInfo* _getDriverInfo() const {
70  return resultSet_->_getDriverInfo();
71  }
72 
73  //these fetch info about a column
74  int _getNumericAttribute(unsigned int col, SQLUSMALLINT attr);
75  ODBCXX_STRING _getStringAttribute(unsigned int col, SQLUSMALLINT attr, unsigned int maxlen =255);
76 
77  //this loads the above values
78  void _fetchColumnInfo();
79 
80  public:
82  enum {
83  columnNoNulls = SQL_NO_NULLS,
84  columnNullable = SQL_NULLABLE,
85  columnNullableUnknown = SQL_NULLABLE_UNKNOWN
86  };
87 
89  int getColumnCount() const;
90 
94  const ODBCXX_STRING& getColumnName(int column) const;
95 
100  int getColumnType(int column) const;
101 
105  int getPrecision(int column) const;
106 
110  int getScale(int column) const;
111 
115  int getColumnDisplaySize(int column);
116 
120  ODBCXX_STRING getCatalogName(int column);
121 
125  ODBCXX_STRING getColumnLabel(int column);
126 
130  ODBCXX_STRING getColumnTypeName(int column);
131 
135  ODBCXX_STRING getSchemaName(int column);
136 
140  ODBCXX_STRING getTableName(int column);
141 
145  bool isAutoIncrement(int column);
146 
150  bool isCaseSensitive(int column);
151 
155  bool isCurrency(int column);
156 
160  bool isDefinitelyWritable(int column);
161 
165  int isNullable(int column);
166 
170  bool isReadOnly(int column);
171 
175  bool isSearchable(int column);
176 
180  bool isSigned(int column);
181 
185  bool isWritable(int column);
186  };
187 
188 
189 
190 } // namespace odbc
191 
192 
193 #endif // __ODBCXX_RESULTSETMETADATA_H

Go back to the libodbc++ homepage