Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / odk / examples / DevelopersGuide / Database / DriverSkeleton / SStatement.hxx
blobc870048d81461cabe80e962d5ad6d57ccd163924
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
5 * the BSD license.
7 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * All rights reserved.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
29 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
31 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
32 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *************************************************************************/
36 #ifndef INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SSTATEMENT_HXX
37 #define INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SSTATEMENT_HXX
39 #include <com/sun/star/sdbc/XStatement.hpp>
40 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
41 #include <com/sun/star/sdbc/XMultipleResults.hpp>
42 #include <com/sun/star/sdbc/XBatchExecution.hpp>
43 #include <com/sun/star/sdbc/XCloseable.hpp>
44 #include <com/sun/star/sdbc/SQLWarning.hpp>
45 #include <com/sun/star/util/XCancellable.hpp>
46 #include <cppuhelper/compbase5.hxx>
47 #include "SConnection.hxx"
48 #include <vector>
49 #include "OSubComponent.hxx"
50 #include <com/sun/star/lang/XServiceInfo.hpp>
52 namespace connectivity
54 namespace skeleton
57 typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::sdbc::XStatement,
58 ::com::sun::star::sdbc::XWarningsSupplier,
59 ::com::sun::star::util::XCancellable,
60 ::com::sun::star::sdbc::XCloseable,
61 ::com::sun::star::sdbc::XMultipleResults> OStatement_BASE;
63 // A base class for the normal statement and for the prepared statement
64 class OStatement_Base : public OBase_Mutex,
65 public OStatement_BASE,
66 public ::cppu::OPropertySetHelper,
67 public OPropertyArrayUsageHelper<OStatement_Base>
70 ::com::sun::star::sdbc::SQLWarning m_aLastWarning;
71 protected:
72 ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
73 // for this Statement
75 ::std::vector< ::rtl::OUString> m_aBatchVector;
77 OConnection* m_pConnection; // The owning Connection object
78 protected:
80 void disposeResultSet();
82 // OPropertyArrayUsageHelper
83 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
84 // OPropertySetHelper
85 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
86 virtual sal_Bool SAL_CALL convertFastPropertyValue(
87 ::com::sun::star::uno::Any & rConvertedValue,
88 ::com::sun::star::uno::Any & rOldValue,
89 sal_Int32 nHandle,
90 const ::com::sun::star::uno::Any& rValue )
91 throw (::com::sun::star::lang::IllegalArgumentException);
92 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
93 sal_Int32 nHandle,
94 const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
95 virtual void SAL_CALL getFastPropertyValue(
96 ::com::sun::star::uno::Any& rValue,
97 sal_Int32 nHandle) const;
98 virtual ~OStatement_Base();
100 public:
101 ::cppu::OBroadcastHelper& rBHelper;
102 OStatement_Base(OConnection* _pConnection );
103 using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
105 // OComponentHelper
106 virtual void SAL_CALL disposing(){OStatement_BASE::disposing();}
107 // XInterface
108 virtual void SAL_CALL release() throw();
109 virtual void SAL_CALL acquire() throw();
110 // XInterface
111 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
112 //XTypeProvider
113 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
115 // XPropertySet
116 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
117 // XStatement
118 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
119 virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
120 virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
121 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
122 // XWarningsSupplier
123 virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
124 virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
125 // XCancellable
126 virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException);
127 // XCloseable
128 virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
129 // XMultipleResults
130 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
131 virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
132 virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
134 // other methods
135 OConnection* getOwnConnection() const { return m_pConnection;}
138 class OStatement_BASE2 :public OStatement_Base
139 ,public OSubComponent<OStatement_BASE2, OStatement_BASE>
142 friend class OSubComponent<OStatement_BASE2, OStatement_BASE>;
143 public:
144 OStatement_BASE2(OConnection* _pConnection ) : OStatement_Base(_pConnection ),
145 OSubComponent<OStatement_BASE2, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this){}
146 // OComponentHelper
147 virtual void SAL_CALL disposing();
148 // XInterface
149 virtual void SAL_CALL release() throw();
152 class OStatement : public OStatement_BASE2,
153 public ::com::sun::star::sdbc::XBatchExecution,
154 public ::com::sun::star::lang::XServiceInfo
156 protected:
157 virtual ~OStatement(){}
158 public:
159 // a constructor, which is required for returning objects:
160 OStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection){}
161 DECLARE_SERVICE_INFO();
163 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
164 virtual void SAL_CALL acquire() throw();
165 virtual void SAL_CALL release() throw();
166 // XBatchExecution
167 virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
168 virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
169 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
174 #endif // INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SSTATEMENT_HXX
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */