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 : * Version: MPL 1.1 / GPLv3+ / LGPLv2.1+
32 : *
33 : * The contents of this file are subject to the Mozilla Public License Version
34 : * 1.1 (the "License"); you may not use this file except in compliance with
35 : * the License or as specified alternatively below. You may obtain a copy of
36 : * the License at http://www.mozilla.org/MPL/
37 : *
38 : * Software distributed under the License is distributed on an "AS IS" basis,
39 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
40 : * for the specific language governing rights and limitations under the
41 : * License.
42 : *
43 : * Major Contributor(s):
44 : * [ Copyright (C) 2011 Lionel Elie Mamane <lionel@mamane.lu> ]
45 : *
46 : * All Rights Reserved.
47 : *
48 : * For minor contributions see the git repository.
49 : *
50 : * Alternatively, the contents of this file may be used under the terms of
51 : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
52 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPLv2.1+"),
53 : * in which case the provisions of the GPLv3+ or the LGPLv2.1+ are applicable
54 : * instead of those above.
55 : *
56 : ************************************************************************/
57 :
58 : #ifndef _PQ_RESULTSETMETADATA_HXX_
59 : #define _PQ_RESULTSETMETADATA_HXX_
60 : #include <vector>
61 :
62 : #include "pq_connection.hxx"
63 :
64 : #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
65 : #include <com/sun/star/beans/XPropertySet.hpp>
66 :
67 : #include <cppuhelper/implbase1.hxx>
68 :
69 : namespace pq_sdbc_driver
70 : {
71 :
72 0 : struct ColDesc
73 : {
74 : rtl::OUString name;
75 : sal_Int32 precision;
76 : sal_Int32 scale;
77 : sal_Int32 displaySize;
78 : Oid typeOid;
79 : rtl::OUString typeName;
80 : sal_Int32 type;
81 : };
82 :
83 : class ResultSet;
84 :
85 : typedef std::vector< ColDesc, Allocator< ColDesc > > ColDescVector;
86 :
87 :
88 0 : class ResultSetMetaData :
89 : public ::cppu::WeakImplHelper1 < com::sun::star::sdbc::XResultSetMetaData >
90 : {
91 : ::rtl::Reference< RefCountedMutex > m_refMutex;
92 : ConnectionSettings **m_ppSettings;
93 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_origin;
94 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_table;
95 : ::rtl::OUString m_tableName;
96 : ::rtl::OUString m_schemaName;
97 : ColDescVector m_colDesc;
98 : ResultSet *m_pResultSet;
99 :
100 : bool m_checkedForTable;
101 : bool m_checkedForTypes;
102 :
103 : sal_Int32 m_colCount;
104 :
105 : void checkClosed()
106 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
107 : void checkColumnIndex( sal_Int32 columnIndex )
108 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
109 : void checkTable();
110 : void checkForTypes();
111 : com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > getColumnByIndex( int index );
112 :
113 : sal_Int32 getIntColumnProperty( const rtl::OUString & name, int index, int def );
114 : sal_Bool getBoolColumnProperty( const rtl::OUString & name, int index, sal_Bool def );
115 :
116 : public:
117 : ResultSetMetaData(
118 : const ::rtl::Reference< RefCountedMutex > & reMutex,
119 : const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet > & origin,
120 : ResultSet *pResultSet,
121 : ConnectionSettings **pSettings,
122 : PGresult *pResult,
123 : const rtl::OUString &schemaName,
124 : const rtl::OUString &tableName );
125 :
126 : public:
127 : // Methods
128 : virtual sal_Int32 SAL_CALL getColumnCount( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
129 : virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
130 : virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
131 : virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
132 : virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
133 : virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
134 : virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
135 : virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
136 : virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
137 : virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
138 : virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
139 : virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
140 : virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
141 : virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
142 : virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
143 : virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
144 : virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
145 : virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
146 : virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
147 : virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
148 : virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
149 : };
150 :
151 : }
152 :
153 : #endif
|