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 #ifndef CONNECTIVITY_SRESULSETMETADATA_HXX
23 #define CONNECTIVITY_SRESULSETMETADATA_HXX
24 
25 #include "mysqlc_connection.hxx"
26 
27 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
28 
29 #include <cppuhelper/implbase1.hxx>
30 #include <preextstl.h>
31 #include <cppconn/resultset_metadata.h>
32 #include <postextstl.h>
33 
34 namespace connectivity
35 {
36 	namespace mysqlc
37 	{
38 		using ::com::sun::star::sdbc::SQLException;
39 		using ::com::sun::star::uno::RuntimeException;
40 		using ::rtl::OUString;
41 		//**************************************************************
42 		//************ Class: ResultSetMetaData
43 		//**************************************************************
44 		typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> OResultSetMetaData_BASE;
45 
46 		class OResultSetMetaData : public OResultSetMetaData_BASE
47 		{
48 			sql::ResultSetMetaData * meta;
49             rtl_TextEncoding        m_encoding;
50 		protected:
51 			virtual ~OResultSetMetaData();
52 		public:
OResultSetMetaData(sql::ResultSetMetaData * _meta,rtl_TextEncoding _encoding)53 			OResultSetMetaData( sql::ResultSetMetaData * _meta, rtl_TextEncoding _encoding )
54                 :meta(_meta)
55                 ,m_encoding( _encoding )
56             {
57             }
58 
convert(const::ext_std::string & _string) const59             inline ::rtl::OUString convert( const ::ext_std::string& _string ) const
60             {
61                 return ::rtl::OUString( _string.c_str(), _string.size(), m_encoding );
62             }
63 
64 			/// Avoid ambigous cast error from the compiler.
operator ::com::sun::star::uno::Reference<::com::sun::star::sdbc::XResultSetMetaData>()65 			inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw()
66 			{ return this; }
67 
68 			sal_Int32 SAL_CALL getColumnCount()						throw(SQLException, RuntimeException);
69 
70 			sal_Bool SAL_CALL isAutoIncrement(sal_Int32 column)		throw(SQLException, RuntimeException);
71 
72 			sal_Bool SAL_CALL isCaseSensitive(sal_Int32 column)		throw(SQLException, RuntimeException);
73 
74 			sal_Bool SAL_CALL isSearchable(sal_Int32 column)		throw(SQLException, RuntimeException);
75 
76 			sal_Bool SAL_CALL isCurrency(sal_Int32 column)			throw(SQLException, RuntimeException);
77 
78 			sal_Int32 SAL_CALL isNullable(sal_Int32 column)			throw(SQLException, RuntimeException);
79 
80 			sal_Bool SAL_CALL isSigned(sal_Int32 column)			throw(SQLException, RuntimeException);
81 
82 			sal_Int32 SAL_CALL getColumnDisplaySize(sal_Int32 column)throw(SQLException, RuntimeException);
83 
84 			OUString SAL_CALL getColumnLabel(sal_Int32 column)		throw(SQLException, RuntimeException);
85 
86 			OUString SAL_CALL getColumnName(sal_Int32 column)		throw(SQLException, RuntimeException);
87 
88 			OUString SAL_CALL getSchemaName(sal_Int32 column)		throw(SQLException, RuntimeException);
89 
90 			sal_Int32 SAL_CALL getPrecision(sal_Int32 column)		throw(SQLException, RuntimeException);
91 
92 			sal_Int32 SAL_CALL getScale(sal_Int32 column)			throw(SQLException, RuntimeException);
93 
94 			OUString SAL_CALL getTableName(sal_Int32 column)		throw(SQLException, RuntimeException);
95 
96 			OUString SAL_CALL getCatalogName(sal_Int32 column)		throw(SQLException, RuntimeException);
97 
98 			sal_Int32 SAL_CALL getColumnType(sal_Int32 column)		throw(SQLException, RuntimeException);
99 
100 			OUString SAL_CALL getColumnTypeName(sal_Int32 column) 	throw(SQLException, RuntimeException);
101 
102 			sal_Bool SAL_CALL isReadOnly(sal_Int32 column)			throw(SQLException, RuntimeException);
103 
104 			sal_Bool SAL_CALL isWritable(sal_Int32 column)			throw(SQLException, RuntimeException);
105 
106 			sal_Bool SAL_CALL isDefinitelyWritable(sal_Int32 column)throw(SQLException, RuntimeException);
107 
108 			OUString SAL_CALL getColumnServiceName(sal_Int32 column)throw(SQLException, RuntimeException);
109 
110 			void checkColumnIndex(sal_Int32 columnIndex)			throw (SQLException, RuntimeException);
111 		};
112 	}
113 }
114 
115 #endif // CONNECTIVITY_SRESULSETMETADATA_HXX
116