build fix
[LibreOffice.git] / connectivity / source / drivers / mork / MStatement.hxx
blob8839575242308ff468ac0a271817aaf924ba29b8
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 INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MSTATEMENT_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MSTATEMENT_HXX
23 #include <comphelper/proparrhlp.hxx>
24 #include <connectivity/sqliterator.hxx>
25 #include <connectivity/sqlparse.hxx>
26 #include "TSortIndex.hxx"
27 #include "MTable.hxx"
29 #include <memory>
31 namespace connectivity
33 namespace mork
35 class OResultSet;
37 typedef ::cppu::WeakComponentImplHelper< css::sdbc::XStatement,
38 css::sdbc::XWarningsSupplier,
39 css::sdbc::XCloseable> OCommonStatement_IBASE;
42 //************ Class: OCommonStatement
43 // is a base class for the normal statement and for the prepared statement
45 class OCommonStatement;
46 typedef ::connectivity::OSubComponent< OCommonStatement, OCommonStatement_IBASE > OCommonStatement_SBASE;
48 class OCommonStatement :public cppu::BaseMutex
49 ,public OCommonStatement_IBASE
50 ,public ::cppu::OPropertySetHelper
51 ,public ::comphelper::OPropertyArrayUsageHelper< OCommonStatement >
52 ,public OCommonStatement_SBASE
54 friend class ::connectivity::OSubComponent< OCommonStatement, OCommonStatement_IBASE >;
56 private:
57 css::sdbc::SQLWarning m_aLastWarning;
59 protected:
60 css::uno::WeakReference< css::sdbc::XResultSet > m_xResultSet;
61 css::uno::Reference< css::sdbc::XDatabaseMetaData> m_xDBMetaData;
62 css::uno::Reference< css::container::XNameAccess> m_xColNames; // table columns
64 // for this Statement
66 OTable* m_pTable;
67 rtl::Reference<OConnection> m_pConnection; // The owning Connection object
69 OValueRow m_aRow;
71 connectivity::OSQLParser m_aParser;
72 std::shared_ptr< ::connectivity::OSQLParseTreeIterator >
73 m_pSQLIterator;
75 connectivity::OSQLParseNode* m_pParseTree;
77 ::std::vector<sal_Int32> m_aColMapping;
78 ::std::vector<sal_Int32> m_aOrderbyColumnNumber;
79 ::std::vector<TAscendingOrder> m_aOrderbyAscending;
81 protected:
83 // OPropertyArrayUsageHelper
84 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
85 // OPropertySetHelper
86 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
87 virtual sal_Bool SAL_CALL convertFastPropertyValue(
88 css::uno::Any & rConvertedValue,
89 css::uno::Any & rOldValue,
90 sal_Int32 nHandle,
91 const css::uno::Any& rValue )
92 throw (css::lang::IllegalArgumentException) override;
93 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
94 sal_Int32 nHandle,
95 const css::uno::Any& rValue) throw (css::uno::Exception, std::exception) override;
96 virtual void SAL_CALL getFastPropertyValue(
97 css::uno::Any& rValue,
98 sal_Int32 nHandle) const override;
99 virtual ~OCommonStatement() override;
101 protected:
103 // Driver Internal Methods
105 enum StatementType { eSelect, eCreateTable };
106 /** called to do the parsing of a to-be-executed SQL statement, and set all members as needed
108 virtual StatementType
109 parseSql( const OUString& sql , bool bAdjusted = false) throw ( css::sdbc::SQLException, css::uno::RuntimeException, std::exception );
110 /** called to initialize a result set, according to a previously parsed SQL statement
112 virtual void initializeResultSet( OResultSet* _pResult );
113 /** called when a possible cached instance of our last result set should be cleared
115 virtual void clearCachedResultSet();
116 /** caches a result set which has just been created by an execution of an SQL statement
118 virtual void cacheResultSet( const ::rtl::Reference< OResultSet >& _pResult );
121 /** executes the current query (the one which has been passed to the last parseSql call)
123 css::uno::Reference< css::sdbc::XResultSet >
124 impl_executeCurrentQuery();
126 void createColumnMapping();
127 void analyseSQL();
128 void setOrderbyColumn( connectivity::OSQLParseNode* pColumnRef,
129 connectivity::OSQLParseNode* pAscendingDescending);
131 public:
132 // other methods
133 OConnection* getOwnConnection() const { return m_pConnection.get(); }
135 explicit OCommonStatement(OConnection* _pConnection );
136 using OCommonStatement_IBASE::operator css::uno::Reference< css::uno::XInterface >;
138 // OComponentHelper
139 virtual void SAL_CALL disposing() override;
141 // XInterface
142 virtual void SAL_CALL release() throw() override;
143 virtual void SAL_CALL acquire() throw() override;
144 // XInterface
145 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception) override;
146 //XTypeProvider
147 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) throw(css::uno::RuntimeException, std::exception) override;
149 // XPropertySet
150 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(css::uno::RuntimeException, std::exception) override;
151 // XStatement
152 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery( const OUString& sql ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override ;
153 virtual sal_Int32 SAL_CALL executeUpdate( const OUString& sql ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override ;
154 virtual sal_Bool SAL_CALL execute( const OUString& sql ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override ;
155 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override ;
156 // XWarningsSupplier
157 virtual css::uno::Any SAL_CALL getWarnings( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
158 virtual void SAL_CALL clearWarnings( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
159 // XCloseable
160 virtual void SAL_CALL close( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception) override;
162 protected:
163 using OPropertySetHelper::getFastPropertyValue;
166 class OStatement : public OCommonStatement,
167 public css::lang::XServiceInfo
169 protected:
170 virtual ~OStatement() override {}
171 public:
172 // a constructor, for when the object needs to be returned:
173 explicit OStatement( OConnection* _pConnection);
174 DECLARE_SERVICE_INFO();
176 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException, std::exception) override;
177 virtual void SAL_CALL acquire() throw() override;
178 virtual void SAL_CALL release() throw() override;
183 #endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MSTATEMENT_HXX
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */