1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_STATEMENT_HXX
21 #define INCLUDED_MYSQLC_SOURCE_MYSQLC_STATEMENT_HXX
23 #include "mysqlc_connection.hxx"
24 #include "mysqlc_subcomponent.hxx"
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/sdbc/SQLWarning.hpp>
28 #include <com/sun/star/sdbc/XBatchExecution.hpp>
29 #include <com/sun/star/sdbc/XCloseable.hpp>
30 #include <com/sun/star/sdbc/XMultipleResults.hpp>
31 #include <com/sun/star/sdbc/XStatement.hpp>
32 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
33 #include <com/sun/star/util/XCancellable.hpp>
35 #include <cppconn/statement.h>
36 #include <cppuhelper/compbase5.hxx>
39 namespace connectivity
43 using ::com::sun::star::sdbc::SQLWarning
;
44 using ::com::sun::star::sdbc::SQLException
;
45 using ::com::sun::star::uno::Any
;
46 using ::com::sun::star::uno::RuntimeException
;
48 typedef ::cppu::WeakComponentImplHelper5
< ::com::sun::star::sdbc::XStatement
,
49 ::com::sun::star::sdbc::XWarningsSupplier
,
50 ::com::sun::star::util::XCancellable
,
51 ::com::sun::star::sdbc::XCloseable
,
52 ::com::sun::star::sdbc::XMultipleResults
> OCommonStatement_IBase
;
54 class OCommonStatement
;
55 typedef OSubComponent
< OCommonStatement
, OCommonStatement_IBase
> OStatement_CBase
;
58 //************ Class: OCommonStatement
59 // is a base class for the normal statement and for the prepared statement
61 class OCommonStatement
:public OBase_Mutex
62 ,public OCommonStatement_IBase
63 ,public ::cppu::OPropertySetHelper
64 ,public OPropertyArrayUsageHelper
<OCommonStatement
>
65 ,public OStatement_CBase
68 friend class OSubComponent
< OCommonStatement
, OCommonStatement_IBase
>;
71 SQLWarning m_aLastWarning
;
74 ::std::list
< rtl::OUString
> m_aBatchList
;
76 OConnection
* m_pConnection
; // The owning Connection object
78 sql::Statement
*cppStatement
;
81 void disposeResultSet();
83 // OPropertyArrayUsageHelper
84 ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const SAL_OVERRIDE
;
87 ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() SAL_OVERRIDE
;
88 sal_Bool SAL_CALL
convertFastPropertyValue(Any
& rConvertedValue
, Any
& rOldValue
,
89 sal_Int32 nHandle
, const Any
& rValue
)
90 throw (::com::sun::star::lang::IllegalArgumentException
) SAL_OVERRIDE
;
92 void SAL_CALL
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle
, const Any
& rValue
)
93 throw(::com::sun::star::uno::Exception
, std::exception
) SAL_OVERRIDE
;
95 void SAL_CALL
getFastPropertyValue(Any
& rValue
, sal_Int32 nHandle
) const SAL_OVERRIDE
;
96 virtual ~OCommonStatement();
99 OCommonStatement(OConnection
* _pConnection
, sql::Statement
*_cppStatement
);
102 ::cppu::OBroadcastHelper
& rBHelper
;
103 using OCommonStatement_IBase::operator ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>;
106 void SAL_CALL
disposing() SAL_OVERRIDE
;
109 void SAL_CALL
release() throw() SAL_OVERRIDE
;
111 void SAL_CALL
acquire() throw() SAL_OVERRIDE
;
114 Any SAL_CALL
queryInterface(const ::com::sun::star::uno::Type
& rType
)
115 throw(RuntimeException
, std::exception
) SAL_OVERRIDE
;
118 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes()
119 throw(RuntimeException
, std::exception
) SAL_OVERRIDE
;
122 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo()
123 throw(RuntimeException
, std::exception
) SAL_OVERRIDE
;
126 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
> SAL_CALL
executeQuery(const rtl::OUString
& sql
)
127 throw(SQLException
, RuntimeException
, std::exception
) SAL_OVERRIDE
;
129 sal_Int32 SAL_CALL
executeUpdate(const rtl::OUString
& sql
)
130 throw(SQLException
, RuntimeException
, std::exception
) SAL_OVERRIDE
;
132 sal_Bool SAL_CALL
execute( const rtl::OUString
& sql
)
133 throw(SQLException
, RuntimeException
, std::exception
) SAL_OVERRIDE
;
135 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
> SAL_CALL
getConnection()
136 throw(SQLException
, RuntimeException
, std::exception
) SAL_OVERRIDE
;
139 Any SAL_CALL
getWarnings() throw(SQLException
, RuntimeException
, std::exception
) SAL_OVERRIDE
;
141 void SAL_CALL
clearWarnings() throw(SQLException
, RuntimeException
, std::exception
) SAL_OVERRIDE
;
144 void SAL_CALL
cancel() throw(RuntimeException
, std::exception
) SAL_OVERRIDE
;
147 void SAL_CALL
close() throw(SQLException
, RuntimeException
, std::exception
) SAL_OVERRIDE
;
150 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
> SAL_CALL
getResultSet()
151 throw(SQLException
, RuntimeException
, std::exception
) SAL_OVERRIDE
;
153 sal_Int32 SAL_CALL
getUpdateCount() throw(SQLException
, RuntimeException
, std::exception
) SAL_OVERRIDE
;
155 sal_Bool SAL_CALL
getMoreResults() throw(SQLException
, RuntimeException
, std::exception
) SAL_OVERRIDE
;
158 OConnection
* getOwnConnection() const { return m_pConnection
;}
161 using ::cppu::OPropertySetHelper::getFastPropertyValue
;
165 class OStatement
: public OCommonStatement
,
166 public ::com::sun::star::sdbc::XBatchExecution
,
167 public ::com::sun::star::lang::XServiceInfo
171 virtual ~OStatement(){}
174 // A constructor which is required for the return of the objects
175 OStatement(OConnection
* _pConnection
, sql::Statement
*_cppStatement
) :
176 OCommonStatement(_pConnection
, _cppStatement
) {}
178 virtual rtl::OUString SAL_CALL
getImplementationName()
179 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
181 virtual sal_Bool SAL_CALL
supportsService(
182 rtl::OUString
const & ServiceName
) throw (css::uno::RuntimeException
, std::exception
)
185 virtual css::uno::Sequence
<rtl::OUString
> SAL_CALL
186 getSupportedServiceNames() throw (css::uno::RuntimeException
, std::exception
)
189 Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
)
190 throw(RuntimeException
, std::exception
) SAL_OVERRIDE
;
192 void SAL_CALL
acquire() throw() SAL_OVERRIDE
;
193 void SAL_CALL
release() throw() SAL_OVERRIDE
;
196 void SAL_CALL
addBatch(const rtl::OUString
& sql
)
197 throw(SQLException
, RuntimeException
, std::exception
) SAL_OVERRIDE
;
199 void SAL_CALL
clearBatch() throw(SQLException
, RuntimeException
, std::exception
) SAL_OVERRIDE
;
201 ::com::sun::star::uno::Sequence
< sal_Int32
> SAL_CALL
executeBatch()
202 throw(SQLException
, RuntimeException
, std::exception
) SAL_OVERRIDE
;
207 #endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_STATEMENT_HXX
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */