xref: /AOO41X/main/connectivity/source/inc/odbc/OResultSetMetaData.hxx (revision caf5cd79edad04a48dcaf209068b3b89eae4622e)
1*caf5cd79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*caf5cd79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*caf5cd79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*caf5cd79SAndrew Rist  * distributed with this work for additional information
6*caf5cd79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*caf5cd79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*caf5cd79SAndrew Rist  * "License"); you may not use this file except in compliance
9*caf5cd79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*caf5cd79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*caf5cd79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*caf5cd79SAndrew Rist  * software distributed under the License is distributed on an
15*caf5cd79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*caf5cd79SAndrew Rist  * KIND, either express or implied.  See the License for the
17*caf5cd79SAndrew Rist  * specific language governing permissions and limitations
18*caf5cd79SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*caf5cd79SAndrew Rist  *************************************************************/
21*caf5cd79SAndrew Rist 
22*caf5cd79SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _CONNECTIVITY_ODBC_ORESULTSETMETADATA_HXX_
25cdf0e10cSrcweir #define _CONNECTIVITY_ODBC_ORESULTSETMETADATA_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
28cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
29cdf0e10cSrcweir #include "odbc/OFunctions.hxx"
30cdf0e10cSrcweir #include "odbc/odbcbasedllapi.hxx"
31cdf0e10cSrcweir #ifndef _VECTOR_
32cdf0e10cSrcweir #include <vector>
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir #include "odbc/OConnection.hxx"
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace connectivity
37cdf0e10cSrcweir {
38cdf0e10cSrcweir 	namespace odbc
39cdf0e10cSrcweir 	{
40cdf0e10cSrcweir 		//**************************************************************
41cdf0e10cSrcweir 		//************ Class: ResultSetMetaData
42cdf0e10cSrcweir 		//**************************************************************
43cdf0e10cSrcweir         typedef ::cppu::WeakImplHelper1<        ::com::sun::star::sdbc::XResultSetMetaData>   OResultSetMetaData_BASE;
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 		class OOO_DLLPUBLIC_ODBCBASE OResultSetMetaData :
46cdf0e10cSrcweir             public 	OResultSetMetaData_BASE
47cdf0e10cSrcweir 		{
48cdf0e10cSrcweir 		protected:
49cdf0e10cSrcweir 			::std::vector<sal_Int32> m_vMapping; // when not every column is needed
50cdf0e10cSrcweir             ::std::map<sal_Int32,sal_Int32> m_aColumnTypes;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 			SQLHANDLE		m_aStatementHandle;
53cdf0e10cSrcweir 			OConnection*	m_pConnection;
54cdf0e10cSrcweir 			sal_Int32		m_nColCount;
55cdf0e10cSrcweir 			sal_Bool		m_bUseODBC2Types;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir             ::rtl::OUString getCharColAttrib(sal_Int32 column,sal_Int32 ident) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
58cdf0e10cSrcweir             sal_Int32 getNumColAttrib(sal_Int32 column,sal_Int32 ident) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
59cdf0e10cSrcweir 		public:
60cdf0e10cSrcweir 			// ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
OResultSetMetaData(OConnection * _pConnection,SQLHANDLE _pStmt)61cdf0e10cSrcweir 			OResultSetMetaData(OConnection*	_pConnection, SQLHANDLE _pStmt )
62cdf0e10cSrcweir                 :m_aStatementHandle( _pStmt )
63cdf0e10cSrcweir 				,m_pConnection(_pConnection)
64cdf0e10cSrcweir 				,m_nColCount(-1)
65cdf0e10cSrcweir 				,m_bUseODBC2Types(sal_False)
66cdf0e10cSrcweir 			{}
OResultSetMetaData(OConnection * _pConnection,SQLHANDLE _pStmt,const::std::vector<sal_Int32> & _vMapping)67cdf0e10cSrcweir 			OResultSetMetaData(OConnection*	_pConnection, SQLHANDLE _pStmt ,const ::std::vector<sal_Int32> & _vMapping)
68cdf0e10cSrcweir                     :m_vMapping(_vMapping)
69cdf0e10cSrcweir                     ,m_aStatementHandle( _pStmt )
70cdf0e10cSrcweir                     ,m_pConnection(_pConnection)
71cdf0e10cSrcweir 					,m_nColCount(_vMapping.size()-1)
72cdf0e10cSrcweir 					,m_bUseODBC2Types(sal_False)
73cdf0e10cSrcweir 			{}
74cdf0e10cSrcweir 			virtual ~OResultSetMetaData();
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 
77cdf0e10cSrcweir             static SQLLEN getNumColAttrib(OConnection* _pConnection
78cdf0e10cSrcweir                                               ,SQLHANDLE _aStatementHandle
79cdf0e10cSrcweir                                               ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface
80cdf0e10cSrcweir                                               ,sal_Int32 _column
81cdf0e10cSrcweir                                               ,sal_Int32 ident) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
82cdf0e10cSrcweir 
83cdf0e10cSrcweir             static SQLSMALLINT getColumnODBCType(OConnection* _pConnection
84cdf0e10cSrcweir                                               ,SQLHANDLE _aStatementHandle
85cdf0e10cSrcweir                                               ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface
86cdf0e10cSrcweir                                               ,sal_Int32 column)
87cdf0e10cSrcweir                                                throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
88cdf0e10cSrcweir 
getOdbcFunction(sal_Int32 _nIndex) const89cdf0e10cSrcweir 			inline oslGenericFunction getOdbcFunction(sal_Int32 _nIndex)  const
90cdf0e10cSrcweir 			{
91cdf0e10cSrcweir 				return m_pConnection->getOdbcFunction(_nIndex);
92cdf0e10cSrcweir 			}
93cdf0e10cSrcweir 			/// Avoid ambigous cast error from the compiler.
operator ::com::sun::star::uno::Reference<::com::sun::star::sdbc::XResultSetMetaData>()94cdf0e10cSrcweir             inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw()
95cdf0e10cSrcweir 			{ return this; }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir             virtual sal_Int32 SAL_CALL getColumnCount(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
98cdf0e10cSrcweir             virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
99cdf0e10cSrcweir             virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
100cdf0e10cSrcweir             virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
101cdf0e10cSrcweir             virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
102cdf0e10cSrcweir             virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
103cdf0e10cSrcweir             virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
104cdf0e10cSrcweir             virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
105cdf0e10cSrcweir             virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
106cdf0e10cSrcweir             virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
107cdf0e10cSrcweir             virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
108cdf0e10cSrcweir             virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
109cdf0e10cSrcweir 			virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
110cdf0e10cSrcweir             virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
111cdf0e10cSrcweir             virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
112cdf0e10cSrcweir             virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
113cdf0e10cSrcweir             virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
114cdf0e10cSrcweir             virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
115cdf0e10cSrcweir             virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
116cdf0e10cSrcweir             virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
117cdf0e10cSrcweir             virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
118cdf0e10cSrcweir 		};
119cdf0e10cSrcweir 	}
120cdf0e10cSrcweir }
121cdf0e10cSrcweir #endif // _CONNECTIVITY_ODBC_ORESULTSETMETADATA_HXX_
122cdf0e10cSrcweir 
123