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