LibreOffice Module connectivity (master) 1
mysqlc_preparedstatement.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21#include "mysqlc_statement.hxx"
22#include "mysqlc_resultset.hxx"
23
24#include <com/sun/star/sdbc/XPreparedStatement.hpp>
25#include <com/sun/star/sdbc/XParameters.hpp>
26#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
27#include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
28#include <com/sun/star/io/XInputStream.hpp>
30
32{
33using ::com::sun::star::sdbc::XResultSetMetaData;
34using ::com::sun::star::uno::Any;
35using ::com::sun::star::uno::Reference;
36using ::com::sun::star::uno::Type;
37
38#if defined MYSQL_VERSION_ID && (MYSQL_VERSION_ID >= 80000) && !defined MARIADB_BASE_VERSION
39using my_bool = bool;
40#else
41using my_bool = char;
42#endif
43
45{
47 unsigned long length = 0;
48 my_bool error = false;
49};
50
51typedef ::cppu::ImplHelper4<css::sdbc::XPreparedStatement, css::sdbc::XParameters,
52 css::sdbc::XResultSetMetaDataSupplier, css::lang::XServiceInfo>
54
56{
57 unsigned int m_paramCount = 0; // number of placeholders
58 Reference<XResultSetMetaData> m_xMetaData;
59 MYSQL_STMT* m_pStmt;
60 std::vector<MYSQL_BIND> m_binds;
61 std::vector<BindMetaData> m_bindMetas;
62
63 void checkParameterIndex(sal_Int32 parameter);
64
65 void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue) override;
66 virtual ~OPreparedStatement() override;
67
68public:
69 virtual OUString SAL_CALL getImplementationName() override;
70
71 virtual sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override;
72
73 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
74
75 OPreparedStatement(OConnection* _pConnection, MYSQL_STMT* pStmt);
76
77 //XInterface
78 Any SAL_CALL queryInterface(const Type& rType) override;
79 void SAL_CALL acquire() noexcept override;
80 void SAL_CALL release() noexcept override;
81
82 //XTypeProvider
83 css::uno::Sequence<Type> SAL_CALL getTypes() override;
84
85 // XPreparedStatement
86 Reference<css::sdbc::XResultSet> SAL_CALL executeQuery() override;
87 sal_Int32 SAL_CALL executeUpdate() override;
88 sal_Bool SAL_CALL execute() override;
89 Reference<css::sdbc::XConnection> SAL_CALL getConnection() override;
90
91 // XParameters
92 void SAL_CALL setNull(sal_Int32 parameter, sal_Int32 sqlType) override;
93
94 void SAL_CALL setObjectNull(sal_Int32 parameter, sal_Int32 sqlType,
95 const OUString& typeName) override;
96
97 void SAL_CALL setBoolean(sal_Int32 parameter, sal_Bool x) override;
98
99 void SAL_CALL setByte(sal_Int32 parameter, sal_Int8 x) override;
100
101 void SAL_CALL setShort(sal_Int32 parameter, sal_Int16 x) override;
102
103 void SAL_CALL setInt(sal_Int32 parameter, sal_Int32 x) override;
104
105 void SAL_CALL setLong(sal_Int32 parameter, sal_Int64 x) override;
106
107 void SAL_CALL setFloat(sal_Int32 parameter, float x) override;
108
109 void SAL_CALL setDouble(sal_Int32 parameter, double x) override;
110
111 void SAL_CALL setString(sal_Int32 parameter, const OUString& x) override;
112
113 void SAL_CALL setBytes(sal_Int32 parameter, const css::uno::Sequence<sal_Int8>& x) override;
114
115 void SAL_CALL setDate(sal_Int32 parameter, const css::util::Date& x) override;
116
117 void SAL_CALL setTime(sal_Int32 parameter, const css::util::Time& x) override;
118 void SAL_CALL setTimestamp(sal_Int32 parameter, const css::util::DateTime& x) override;
119
120 void SAL_CALL setBinaryStream(sal_Int32 parameter, const Reference<css::io::XInputStream>& x,
121 sal_Int32 length) override;
122
123 void SAL_CALL setCharacterStream(sal_Int32 parameter, const Reference<css::io::XInputStream>& x,
124 sal_Int32 length) override;
125
126 void SAL_CALL setObject(sal_Int32 parameter, const Any& x) override;
127
128 void SAL_CALL setObjectWithInfo(sal_Int32 parameter, const Any& x, sal_Int32 targetSqlType,
129 sal_Int32 scale) override;
130
131 void SAL_CALL setRef(sal_Int32 parameter, const Reference<css::sdbc::XRef>& x) override;
132
133 void SAL_CALL setBlob(sal_Int32 parameter, const Reference<css::sdbc::XBlob>& x) override;
134
135 void SAL_CALL setClob(sal_Int32 parameter, const Reference<css::sdbc::XClob>& x) override;
136
137 void SAL_CALL setArray(sal_Int32 parameter, const Reference<css::sdbc::XArray>& x) override;
138
139 void SAL_CALL clearParameters() override;
140
141 // XPreparedBatchExecution
142 // void SAL_CALL addBatch() override;
143 // void SAL_CALL clearBatch() override;
144 // css::uno::Sequence<sal_Int32> SAL_CALL executeBatch() override;
145
146 // XCloseable
147 void SAL_CALL close() override;
148
149 // XResultSetMetaDataSupplier
150 Reference<css::sdbc::XResultSetMetaData> SAL_CALL getMetaData() override;
151};
152
153} /* connectivity::mysqlc */
154
155/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SAL_CALL setArray(sal_Int32 parameter, const Reference< css::sdbc::XArray > &x) override
void SAL_CALL setObject(sal_Int32 parameter, const Any &x) override
void SAL_CALL setBoolean(sal_Int32 parameter, sal_Bool x) override
OPreparedStatement(OConnection *_pConnection, MYSQL_STMT *pStmt)
void SAL_CALL setRef(sal_Int32 parameter, const Reference< css::sdbc::XRef > &x) override
void SAL_CALL setByte(sal_Int32 parameter, sal_Int8 x) override
void SAL_CALL setBlob(sal_Int32 parameter, const Reference< css::sdbc::XBlob > &x) override
void SAL_CALL setDate(sal_Int32 parameter, const css::util::Date &x) override
Reference< css::sdbc::XResultSet > SAL_CALL executeQuery() override
void SAL_CALL setFloat(sal_Int32 parameter, float x) override
void SAL_CALL setClob(sal_Int32 parameter, const Reference< css::sdbc::XClob > &x) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
void SAL_CALL setObjectWithInfo(sal_Int32 parameter, const Any &x, sal_Int32 targetSqlType, sal_Int32 scale) override
void SAL_CALL setObjectNull(sal_Int32 parameter, sal_Int32 sqlType, const OUString &typeName) override
void SAL_CALL setCharacterStream(sal_Int32 parameter, const Reference< css::io::XInputStream > &x, sal_Int32 length) override
void SAL_CALL setNull(sal_Int32 parameter, sal_Int32 sqlType) override
virtual sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
void SAL_CALL setBytes(sal_Int32 parameter, const css::uno::Sequence< sal_Int8 > &x) override
css::uno::Sequence< Type > SAL_CALL getTypes() override
void SAL_CALL setString(sal_Int32 parameter, const OUString &x) override
Any SAL_CALL queryInterface(const Type &rType) override
Reference< css::sdbc::XConnection > SAL_CALL getConnection() override
void SAL_CALL setBinaryStream(sal_Int32 parameter, const Reference< css::io::XInputStream > &x, sal_Int32 length) override
virtual OUString SAL_CALL getImplementationName() override
Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any &rValue) override
void SAL_CALL setLong(sal_Int32 parameter, sal_Int64 x) override
void SAL_CALL setTimestamp(sal_Int32 parameter, const css::util::DateTime &x) override
void SAL_CALL setDouble(sal_Int32 parameter, double x) override
void SAL_CALL setTime(sal_Int32 parameter, const css::util::Time &x) override
void SAL_CALL setInt(sal_Int32 parameter, sal_Int32 x) override
void SAL_CALL setShort(sal_Int32 parameter, sal_Int16 x) override
Type
::cppu::ImplHelper4< css::sdbc::XPreparedStatement, css::sdbc::XParameters, css::sdbc::XResultSetMetaDataSupplier, css::lang::XServiceInfo > OPreparedStatement_BASE
OUString typeName
sal_Int32 scale
Definition: pq_statics.cxx:62
unsigned char sal_Bool
signed char sal_Int8