Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / mysqlc / source / mysqlc_statement.hxx
bloba4e6335dde58a8e460c7dd7502163367cf3af505
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 MYSQLC_STATEMENT_HXX
21 #define 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>
37 #include <list>
39 namespace connectivity
41 namespace mysqlc
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;
47 using ::rtl::OUString;
49 typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::sdbc::XStatement,
50 ::com::sun::star::sdbc::XWarningsSupplier,
51 ::com::sun::star::util::XCancellable,
52 ::com::sun::star::sdbc::XCloseable,
53 ::com::sun::star::sdbc::XMultipleResults> OCommonStatement_IBase;
55 class OCommonStatement;
56 typedef OSubComponent< OCommonStatement, OCommonStatement_IBase > OStatement_CBase;
58 //**************************************************************
59 //************ Class: OCommonStatement
60 // is a base class for the normal statement and for the prepared statement
61 //**************************************************************
62 class OCommonStatement :public OBase_Mutex
63 ,public OCommonStatement_IBase
64 ,public ::cppu::OPropertySetHelper
65 ,public OPropertyArrayUsageHelper<OCommonStatement>
66 ,public OStatement_CBase
69 friend class OSubComponent< OCommonStatement, OCommonStatement_IBase >;
71 private:
72 SQLWarning m_aLastWarning;
74 protected:
75 ::std::list< OUString> m_aBatchList;
77 OConnection* m_pConnection; // The owning Connection object
79 sql::Statement *cppStatement;
81 protected:
82 void disposeResultSet();
84 // OPropertyArrayUsageHelper
85 ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
87 // OPropertySetHelper
88 ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
89 sal_Bool SAL_CALL convertFastPropertyValue(Any & rConvertedValue, Any & rOldValue,
90 sal_Int32 nHandle, const Any& rValue)
91 throw (::com::sun::star::lang::IllegalArgumentException);
93 void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue)
94 throw(::com::sun::star::uno::Exception);
96 void SAL_CALL getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const;
97 virtual ~OCommonStatement();
99 protected:
100 OCommonStatement(OConnection* _pConnection, sql::Statement *_cppStatement);
102 public:
103 ::cppu::OBroadcastHelper& rBHelper;
104 using OCommonStatement_IBase::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
106 // OComponentHelper
107 void SAL_CALL disposing(void);
109 // XInterface
110 void SAL_CALL release() throw();
112 void SAL_CALL acquire() throw();
114 // XInterface
115 Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type & rType)
116 throw(RuntimeException);
118 //XTypeProvider
119 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
120 throw(RuntimeException);
122 // XPropertySet
123 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
124 throw(RuntimeException);
126 // XStatement
127 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery(const OUString& sql)
128 throw(SQLException, RuntimeException);
130 sal_Int32 SAL_CALL executeUpdate(const OUString& sql)
131 throw(SQLException, RuntimeException);
133 sal_Bool SAL_CALL execute( const OUString& sql )
134 throw(SQLException, RuntimeException);
136 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection()
137 throw(SQLException, RuntimeException);
139 // XWarningsSupplier
140 Any SAL_CALL getWarnings() throw(SQLException, RuntimeException);
142 void SAL_CALL clearWarnings() throw(SQLException, RuntimeException);
144 // XCancellable
145 void SAL_CALL cancel() throw(RuntimeException);
147 // XCloseable
148 void SAL_CALL close() throw(SQLException, RuntimeException);
150 // XMultipleResults
151 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet()
152 throw(SQLException, RuntimeException);
154 sal_Int32 SAL_CALL getUpdateCount() throw(SQLException, RuntimeException);
156 sal_Bool SAL_CALL getMoreResults() throw(SQLException, RuntimeException);
158 // other methods
159 OConnection* getOwnConnection() const { return m_pConnection;}
161 private:
162 using ::cppu::OPropertySetHelper::getFastPropertyValue;
166 class OStatement : public OCommonStatement,
167 public ::com::sun::star::sdbc::XBatchExecution,
168 public ::com::sun::star::lang::XServiceInfo
171 protected:
172 virtual ~OStatement(){}
174 public:
175 // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
176 OStatement(OConnection* _pConnection, sql::Statement *_cppStatement) : OCommonStatement(_pConnection, _cppStatement) {}
177 DECLARE_SERVICE_INFO();
179 Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType )
180 throw(RuntimeException);
182 void SAL_CALL acquire() throw();
183 void SAL_CALL release() throw();
185 // XBatchExecution
186 void SAL_CALL addBatch(const OUString& sql)
187 throw(SQLException, RuntimeException);
189 void SAL_CALL clearBatch() throw(SQLException, RuntimeException);
191 ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch()
192 throw(SQLException, RuntimeException);
197 #endif // MYSQLC_STATEMENT_HXX
200 * Local variables:
201 * tab-width: 4
202 * c-basic-offset: 4
203 * End:
204 * vim600: noet sw=4 ts=4 fdm=marker
205 * vim<600: noet sw=4 ts=4
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */