Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * Effective License of whole file:
5 : *
6 : * This library is free software; you can redistribute it and/or
7 : * modify it under the terms of the GNU Lesser General Public
8 : * License version 2.1, as published by the Free Software Foundation.
9 : *
10 : * This library is distributed in the hope that it will be useful,
11 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 : * Lesser General Public License for more details.
14 : *
15 : * You should have received a copy of the GNU Lesser General Public
16 : * License along with this library; if not, write to the Free Software
17 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18 : * MA 02111-1307 USA
19 : *
20 : * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
21 : *
22 : * The Contents of this file are made available subject to the terms of
23 : * the GNU Lesser General Public License Version 2.1
24 : *
25 : * Copyright: 2000 by Sun Microsystems, Inc.
26 : *
27 : * Contributor(s): Joerg Budischewski
28 : *
29 : * All parts contributed on or after August 2011:
30 : *
31 : * This Source Code Form is subject to the terms of the Mozilla Public
32 : * License, v. 2.0. If a copy of the MPL was not distributed with this
33 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
34 : *
35 : ************************************************************************/
36 :
37 : #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_RESULTSETMETADATA_HXX
38 : #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_RESULTSETMETADATA_HXX
39 : #include <vector>
40 :
41 : #include "pq_connection.hxx"
42 :
43 : #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
44 : #include <com/sun/star/beans/XPropertySet.hpp>
45 :
46 : #include <cppuhelper/implbase1.hxx>
47 :
48 : namespace pq_sdbc_driver
49 : {
50 :
51 0 : struct ColDesc
52 : {
53 : OUString name;
54 : sal_Int32 precision;
55 : sal_Int32 scale;
56 : sal_Int32 displaySize;
57 : Oid typeOid;
58 : OUString typeName;
59 : sal_Int32 type;
60 : };
61 :
62 : class ResultSet;
63 :
64 : typedef std::vector< ColDesc > ColDescVector;
65 :
66 :
67 0 : class ResultSetMetaData :
68 : public ::cppu::WeakImplHelper1 < com::sun::star::sdbc::XResultSetMetaData >
69 : {
70 : ::rtl::Reference< RefCountedMutex > m_refMutex;
71 : ConnectionSettings **m_ppSettings;
72 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_origin;
73 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_table;
74 : OUString m_tableName;
75 : OUString m_schemaName;
76 : ColDescVector m_colDesc;
77 : ResultSet *m_pResultSet;
78 :
79 : bool m_checkedForTable;
80 : bool m_checkedForTypes;
81 :
82 : sal_Int32 m_colCount;
83 :
84 : void checkClosed()
85 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
86 : void checkColumnIndex( sal_Int32 columnIndex )
87 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
88 : void checkTable();
89 : void checkForTypes();
90 : com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > getColumnByIndex( int index );
91 :
92 : sal_Int32 getIntColumnProperty( const OUString & name, int index, int def );
93 : bool getBoolColumnProperty( const OUString & name, int index, bool def );
94 :
95 : public:
96 : ResultSetMetaData(
97 : const ::rtl::Reference< RefCountedMutex > & reMutex,
98 : const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet > & origin,
99 : ResultSet *pResultSet,
100 : ConnectionSettings **pSettings,
101 : PGresult *pResult,
102 : const OUString &schemaName,
103 : const OUString &tableName );
104 :
105 : public:
106 : // Methods
107 : virtual sal_Int32 SAL_CALL getColumnCount( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
108 : virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
109 : virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
110 : virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
111 : virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
112 : virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
113 : virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
114 : virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 : virtual OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
116 : virtual OUString SAL_CALL getColumnName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
117 : virtual OUString SAL_CALL getSchemaName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
118 : virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 : virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
120 : virtual OUString SAL_CALL getTableName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
121 : virtual OUString SAL_CALL getCatalogName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
122 : virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
123 : virtual OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
124 : virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
125 : virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
126 : virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
127 : virtual OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
128 : };
129 :
130 : }
131 :
132 : #endif
133 :
134 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|